generator_state_logger#

Classes

GeneratorStateLogger([save_dir, ...])

Log the generator states especially the prompt states update history to a file.

GeneratorStatesRecord(prompt_states, Any] =, ...)

class GeneratorStatesRecord(prompt_states: Dict[str, Any] = <factory>, time_stamp: str = <factory>)[source]#

Bases: DataClass

prompt_states: Dict[str, Any]#
time_stamp: str#
class GeneratorStateLogger(save_dir: str | None = None, project_name: str | None = None, filename: str | None = None)[source]#

Bases: object

Log the generator states especially the prompt states update history to a file.

Each generator should has its unique and identifiable name to be logged. One file can log multiple generators’ states.

We use _trace_map to store the states and track any changes and updates and save it to a file.

Parameters:
  • save_dir (str, optional) – The directory to save the trace file. Default is “./traces/”

  • project_name (str, optional) – The project name. Default is None.

  • filename (str, optional) – The file path to save the trace. Default is “generator_state_trace.json”

get_log_location() str[source]#
property generator_names#
log_prompt(generator: Generator, name: str)[source]#

Log the prompt states of the generator with the given name.

save(filepath: str)[source]#
load(filepath: str)[source]#