Optional
_fields: BaseCallbackHandlerInputProtected
runProtected
runProtected
usesA map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.
A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.
The final serialized identifier for the module.
A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.
A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.
A manual list of keys that should be serialized. If not overridden, all fields passed into the constructor will be serialized.
Protected
_Optional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Create and add a run to the run map for chain start events. This must sometimes be done synchronously to avoid race conditions when callbacks are backgrounded, so we expose it as a separate method here.
Optional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
runType: stringOptional
name: stringOptional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Create and add a run to the run map for chat model start events. This must sometimes be done synchronously to avoid race conditions when callbacks are backgrounded, so we expose it as a separate method here.
Optional
parentRunId: stringOptional
extraParams: KVMapOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Create and add a run to the run map for LLM start events. This must sometimes be done synchronously to avoid race conditions when callbacks are backgrounded, so we expose it as a separate method here.
Optional
parentRunId: stringOptional
extraParams: KVMapOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Create and add a run to the run map for retriever start events. This must sometimes be done synchronously to avoid race conditions when callbacks are backgrounded, so we expose it as a separate method here.
Optional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Create and add a run to the run map for tool start events. This must sometimes be done synchronously to avoid race conditions when callbacks are backgrounded, so we expose it as a separate method here.
Optional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
dotted_order?: stringThe dotted order for the run.
This is a string composed of {time}{run-uuid}.* so that a trace can be sorted in the order it was executed.
Example:
Optional
end_time?: numberThe epoch time at which the run ended, if applicable.
Events like 'start', 'end' linked to the run.
Optionally, a unique identifier for the run.
The epoch time at which the run started, if available.
Optional
trace_id?: stringUnique ID assigned to every run within this nested trace. *
Protected
_Protected
_Method used to get a string representation of the run's lineage, which is used in logging.
The run whose lineage is to be retrieved.
A string representation of the run's lineage.
Protected
getOptional
runId: stringCalled when an agent is about to execute an action, with the action and the run ID.
Called when an agent finishes execution, before it exits. with the final output and the run ID.
Called at the end of a Chain run, with the outputs and the run ID.
Optional
_parentRunId: stringOptional
_tags: string[]Optional
kwargs: { inputs?: Record<string, unknown> }Called if a Chain run encounters an error
Optional
_parentRunId: stringOptional
_tags: string[]Optional
kwargs: { inputs?: Record<string, unknown> }Called at the start of a Chain run, with the chain name and inputs and the run ID.
Optional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
runType: stringOptional
name: stringCalled at the start of a Chat Model run, with the prompt(s) and the run ID.
Optional
parentRunId: stringOptional
extraParams: KVMapOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
handleCalled if an LLM/ChatModel run encounters an error
Optional
_parentRunId: stringOptional
_tags: string[]Optional
extraParams: Record<string, unknown>Called when an LLM/ChatModel in streaming
mode produces a new token
idx.prompt is the index of the prompt that produced the token (if there are multiple prompts) idx.completion is the index of the completion that produced the token (if multiple completions per prompt are requested)
Optional
_parentRunId: stringOptional
_tags: string[]Optional
fields: HandleLLMNewTokenCallbackFieldsCalled at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.
Optional
parentRunId: stringOptional
extraParams: KVMapOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringOptional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringCalled at the end of a Tool run, with the tool output and the run ID.
Called at the start of a Tool run, with the tool name and input and the run ID.
Optional
parentRunId: stringOptional
tags: string[]Optional
metadata: KVMapOptional
name: stringMethod used to log the action selected by the agent.
The run in which the agent action occurred.
void
Optional
onMethod used to log the end of a chain run.
The chain run that has ended.
void
Method used to log any errors of a chain run.
The chain run that has errored.
void
Method used to log the start of a chain run.
The chain run that has started.
void
Method used to log the end of an LLM run.
The LLM run that has ended.
void
Method used to log any errors of an LLM run.
The LLM run that has errored.
void
Optional
onOptional
kwargs: { chunk: any }Method used to log the start of an LLM run.
The LLM run that has started.
void
Method used to log the end of a retriever run.
The retriever run that has ended.
void
Method used to log any errors of a retriever run.
The retriever run that has errored.
void
Method used to log the start of a retriever run.
The retriever run that has started.
void
Optional
onOptional
onOptional
onMethod used to log the end of a tool run.
The tool run that has ended.
void
Method used to log any errors of a tool run.
The tool run that has errored.
void
Method used to log the start of a tool run.
The tool run that has started.
void
Protected
persistMethod used to persist the run. In this case, it simply returns a resolved promise as there's no persistence logic.
The run to persist.
A resolved promise.
Protected
stringifyStatic
fromStatic
lc_The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.
Implemented as a static method to support loading logic.
A tracer that logs all events to the console. It extends from the
BaseTracer
class and overrides its methods to provide custom logging functionality.Example