aix.calllog¶
An opt-in log of aix model calls: the resolved model, the caller, the outcome.
Off by default. Nothing is recorded unless a logger is installed, so a failing model choice (a typo’d alias, a retired model, a missing key) can go unnoticed only when you have not asked to see it. Three ways to turn it on, from narrowest to widest:
per call, a keyword-only callback:
chat("hi", on_call=print);per process or block,
set_call_logger(fn)/with call_logger(fn): ...;from the environment,
AIX_CALL_LOG=/path/to/calls.jsonlwrites one JSON line per call withjsonl_logger()(the prompt and the reply are never recorded).
A logger is any fn(record: CallRecord) -> None. It runs after the call, and an
exception inside it is swallowed so logging can never break a model call.
>>> seen = []
>>> with call_logger(seen.append):
... with _record("chat", "gpt-x", None):
... pass
>>> seen[0].function, seen[0].model, seen[0].ok
('chat', 'gpt-x', True)
Module Attributes
Environment variable holding the path of a JSON-lines file; setting it enables logging. |
Functions
|
Install |
|
Log calls made inside the |
|
A logger that appends one JSON line per call to |
Classes
|
One aix call: which function, the model it resolved to, who called, how it ended. |
- class aix.calllog.CallRecord(function, model, caller, ok, seconds, error=None, time=0.0)[source]¶
Bases:
objectOne aix call: which function, the model it resolved to, who called, how it ended.
- aix.calllog.ENV_VAR = 'AIX_CALL_LOG'¶
Environment variable holding the path of a JSON-lines file; setting it enables logging.
- aix.calllog.jsonl_logger(path)[source]¶
A logger that appends one JSON line per call to
path.- Return type:
Callable[[CallRecord],None]