compass.utilities.event_log.EventLog#

class EventLog(path)[source]#

Bases: object

Append-only JSONL event stream for one jurisdiction

A log opened on a file that already holds events (an earlier step of a workflow run as separate search, collect, and extract steps) continues it: events are added after the existing ones, their sequence numbers and elapsed times carry on, and the IDs given out are marked with the run they belong to so they stay unique.

Parameters:

path (path-like) – File to write events to. It is created if it does not exist, and added to if it does.

Methods

emit(kind, **fields)

Append one event, with the current tags

graph_id(description)

ID for a decision-tree graph, recorded the first time

next_call_id()

ID linking an llm_request to its llm_response

next_id(prefix)

Sequential ID, e.g. linking a request to its response.

schema_id(response_format)

ID for a structured-output schema, recorded the first time

Attributes

is_new

Whether this log started a new file

is_new#

Whether this log started a new file

Type:

bool

emit(kind, **fields)[source]#

Append one event, with the current tags

next_id(prefix)[source]#

Sequential ID, e.g. linking a request to its response

next_call_id()[source]#

ID linking an llm_request to its llm_response

schema_id(response_format)[source]#

ID for a structured-output schema, recorded the first time

Schemas can be large and are often sent with many calls, so each distinct one is written once as an llm_schema event and referred to by ID afterwards.

graph_id(description)[source]#

ID for a decision-tree graph, recorded the first time

A tree’s graph (every question and branch, including those a run never reaches) is written once as a decision_tree_graph event; trees asking the same questions, such as one per page of a document, refer to it by ID.

Parameters:

description (dict) – nodes and edges of the graph, as built by compass.common.tree.describe_graph().