LLMonitor JS API Reference
Class: LLMonitor
Constructor
Method | Description |
---|---|
constructor() | Initializes the LLMonitor instance. |
Methods
Method | Description |
---|---|
init({ appId?: string, verbose?: boolean, apiUrl?: string }) | Initializes the LLMonitor with the provided options. |
trackEvent(type: string, event: string, data: RunEvent) | Tracks an event with the provided type, event name, and data. The data parameter is of type RunEvent , which has the following structure: |
Property | Description |
---|---|
type | The type of the event. It can be one of the following: "log", "tool", "agent", "llm", "convo", "chain", "retriever", "embed", "chat", "convo". |
event | The name of the event. It can be one of the following: "start", "end", "error", "info", "warn", "feedback". |
app | The ID of the app. |
timestamp | The timestamp of the event. |
userId | The ID of the user (optional). |
userProps | The properties of the user (optional). |
parentRunId | The ID of the parent run (optional). |
extra | Extra data (optional). |
tags | Tags associated with the event (optional). |
runtime | The runtime of the event (optional). |
error | The error object, if any, with properties message and stack (optional). |
runId | The ID of the run. |
input | The input data (optional). |
output | The output data (optional). |
tokensUsage | The token usage data (optional). |
Method | Description |
---|---|
wrapAgent(func: Function, params?: WrapParams) -> Promise | Wraps an agent's Promise to track its input, results, and any errors. Returns a Promise. |
wrapTool(func: Function, params?: WrapParams) -> Promise | Wraps a tool's Promise to track its input, results, and any errors. Returns a Promise. |
wrapModel(func: Function, params?: WrapParams) -> Promise | Wraps a model's Promise to track its input, results, and any errors. Returns a Promise. |
info(message: string, extra?: any) | Logs an informational message with optional extra data. |
log(message: string, extra?: any) | Alias for info . |
warn(message: string, extra?: any) | Logs a warning message with optional extra data. |
`error(message: string | any, error?: any)` |
flush() -> Promise | Ensures the event queue is flushed before exiting the program. Returns a Promise. |