Manual Usage
If your application requires more flexibility and you can't use the wrap
helpers, you can use the trackEvent
method directly.
The trackEvent
method is used to track and log runs in your application. It takes three parameters: type
, event
, and data
.
Parameters:
Parameter | Type | Description |
---|---|---|
type | agent , tool , llm or chain | The type of the run |
event | start , end , error or feedback | The name of the event. |
data | Partial<RunEvent> | Data associated with the run. |
The RunEvent
type is composed of the following properties:
Field | Type | Description | Required |
---|---|---|---|
runId | string | Unique identifier | Yes |
input | JSON | Input data | No |
output | JSON | Output data | No |
tokensUsage | { completion: number, prompt: number } | Number of tokens used in the run. | No |
userId | string | The user ID. | No |
userProps | JSON | The user properties. | No |
parentRunId | string | The parent run ID. | No |
extra | JSON | Any extra data associated with the event. | No |
tags | string[] | Tags associated with the event. | No |
error | { message: string, stack?: string } | Error object if an error occurred. | No |
Example to track an agent:
Using the parentRunId
parameter
To create traces with sub-agents, you can use the parentRunId
parameter to link child runs.