syndisco.Logs
- class Logs
Bases:
objectStores and serializes the log entries of a discussion.
Each entry is a dict with keys
name,text, andmodel. The class can be constructed incrementally viaappend(), or built all at once from plain lists via thefrom_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
DiscussionLogsfrom a JSON file previously written byto_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
DiscussionLogsinstance.- 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
timestampfield, 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.