syndisco.Logs

class Logs

Bases: object

Stores and serializes the log entries of a discussion.

Each entry is a dict with keys name, text, and model. The class can be constructed incrementally via append(), or built all at once from plain lists via the from_lists() class method.

append(name: str, text: str, model: str = 'hardcoded', prompt: str = '') None

Add a single log entry.

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

  • text (str) – The message text.

  • model (str) – The model (or "hardcoded" for seed entries).

  • prompt (str:) – The prompt given to the LLM user that generated the response. Empty string if the user is not an LLM.

export(output_path: str | Path, timestamp_format: str = '%y-%m-%d-%H-%M') None

Write the logs (and any extra metadata) to a JSON file.

Parameters:
  • output_path (str | Path) – Destination path for the JSON file.

  • timestamp_format (str, optional) – strftime format for the timestamp field.

classmethod from_file(path: str | Path) Logs

Load a DiscussionLogs from a JSON file previously written by to_json_file().

Parameters:

path (str | Path) – Path to the JSON file.

Raises:
  • FileNotFoundError – if path does not exist.

  • ValueError – if the JSON does not match the expected schema.

Returns:

A populated DiscussionLogs instance.

Return type:

DiscussionLogs

to_dict(timestamp_format: str = '%y-%m-%d-%H-%M') dict[str, Any]

Serialize the logs to a dict.

Parameters:

timestamp_format (str, optional) – strftime format for the timestamp field, defaults to "%y-%m-%d-%H-%M".

Returns:

A serializable dict representation of the logs.

Return type:

dict[str, Any]

to_list() list[dict[str, str]]

Return a shallow copy of the raw entry list.