generator_call_logger#

Classes

GeneratorCallLogger([save_dir, project_name])

Log the generator calls.

GeneratorCallRecord(prompt_kwargs, Any] =, ...)

class GeneratorCallRecord(prompt_kwargs: Dict[str, Any] = <factory>, model_kwargs: Dict[str, Any] = <factory>, input: Dict[str, Any] = <factory>, output: adalflow.core.types.GeneratorOutput = <factory>, metadata: Dict[str, Any] = <factory>, time_stamp: str = <factory>)[source]#

Bases: DataClass

prompt_kwargs: Dict[str, Any]#
model_kwargs: Dict[str, Any]#
input: Dict[str, Any]#
output: GeneratorOutput#
metadata: Dict[str, Any]#
time_stamp: str#
class GeneratorCallLogger(save_dir: str | None = None, project_name: str | None = None)[source]#

Bases: object

Log the generator calls.

Allow multiple generators to be logged, and each with its own jsonl file.

The log files are stored in the ./traces/ directory. If a project_name is provided, it will be stored in ./traces/{project_name}.

Parameters:
  • save_dir (str, optional) – The directory to save the log files. Defaults to “./traces/”.

  • project_name (str, optional) – The project name. Defaults to None.

reset()[source]#
property generator_names_to_files: Dict[str, str]#
get_log_location(name: str) str[source]#
get_calls(name: str) List[GeneratorCallRecord][source]#

Get the generator call records for generator with name.

register_generator(name: str, filename: str | None = None)[source]#

Register a generator with a name and a jsonl file to log its calls.

Parameters:
  • name (str) – The name of the generator.

  • filename (str, optional) – The jsonl filename to log the calls. Defaults to {name}_call.jsonl.

save_meta_data(file_path: str)[source]#

Save the _generator_names_to_files to a json file.

load_meta_data(file_path: str)[source]#

Load the _generator_names_to_files from a json file.

load(name: str) List[GeneratorCallRecord][source]#

Load the generator call records.

log_call(name: str, output: GeneratorOutput, input: Dict[str, Any] | None = None, prompt_kwargs: Dict[str, Any] | None = None, model_kwargs: Dict[str, Any] | None = None)[source]#

Log the generator call.