Class: GalileoCallback

Defined in: src/handlers/langchain.ts:62 Langchain callback handler for logging traces to the Galileo platform.

Extends

  • BaseCallbackHandler

Implements

  • CallbackHandlerMethods

Constructors

Constructor

new GalileoCallback(
   galileoLogger?: GalileoLogger,
   startNewTrace?: boolean,
   flushOnChainEnd?: boolean): GalileoCallback;
Defined in: src/handlers/langchain.ts:73

Parameters

galileoLogger?
GalileoLogger
startNewTrace?
boolean = true
flushOnChainEnd?
boolean = true

Returns

GalileoCallback

Overrides

BaseCallbackHandler.constructor;

Properties

_flushOnChainEnd

_flushOnChainEnd: boolean;
Defined in: src/handlers/langchain.ts:68

_galileoLogger

_galileoLogger: GalileoLogger;
Defined in: src/handlers/langchain.ts:66

_nodes

_nodes: Record<string, Node> = {};
Defined in: src/handlers/langchain.ts:69

_startNewTrace

_startNewTrace: boolean;
Defined in: src/handlers/langchain.ts:67

awaitHandlers

awaitHandlers: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:177

Inherited from

BaseCallbackHandler.awaitHandlers;

ignoreAgent

ignoreAgent: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:173

Inherited from

BaseCallbackHandler.ignoreAgent;

ignoreChain

ignoreChain: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:172

Inherited from

BaseCallbackHandler.ignoreChain;

ignoreCustomEvent

ignoreCustomEvent: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:175

Inherited from

BaseCallbackHandler.ignoreCustomEvent;

ignoreLLM

ignoreLLM: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:171

Inherited from

BaseCallbackHandler.ignoreLLM;

ignoreRetriever

ignoreRetriever: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:174

Inherited from

BaseCallbackHandler.ignoreRetriever;

lc_kwargs

lc_kwargs: SerializedFields;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:169

Inherited from

BaseCallbackHandler.lc_kwargs;

lc_serializable

lc_serializable: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:147

Inherited from

BaseCallbackHandler.lc_serializable;

name

name: string = "GalileoCallback";
Defined in: src/handlers/langchain.ts:71

Overrides

BaseCallbackHandler.name;

raiseError

raiseError: boolean;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:176

Inherited from

BaseCallbackHandler.raiseError;

Accessors

lc_aliases

Get Signature

get lc_aliases():
  | undefined
  | {
[key: string]: string;
};
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:155 A 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.
Returns
| undefined | { [key: string]: string; }

Inherited from

BaseCallbackHandler.lc_aliases;

lc_attributes

Get Signature

get lc_attributes():
  | undefined
  | {
[key: string]: string;
};
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:152 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.
Returns
| undefined | { [key: string]: string; }

Inherited from

BaseCallbackHandler.lc_attributes;

lc_id

Get Signature

get lc_id(): string[];
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:168 The final serialized identifier for the module.
Returns
string[]

Inherited from

BaseCallbackHandler.lc_id;

lc_namespace

Get Signature

get lc_namespace(): ["langchain_core", "callbacks", string];
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:148 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.
Returns
["langchain_core", "callbacks", string]

Inherited from

BaseCallbackHandler.lc_namespace;

lc_secrets

Get Signature

get lc_secrets():
  | undefined
  | {
[key: string]: string;
};
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:149 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.
Returns
| undefined | { [key: string]: string; }

Inherited from

BaseCallbackHandler.lc_secrets;

Methods

copy()

copy(): BaseCallbackHandler;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:179

Returns

BaseCallbackHandler

Inherited from

BaseCallbackHandler.copy;

handleAgentAction()?

optional handleAgentAction(
   action: AgentAction,
   runId: string,
   parentRunId?: string,
tags?: string[]): void | Promise<void>;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:115 Called when an agent is about to execute an action, with the action and the run ID.

Parameters

action
AgentAction
runId
string
parentRunId?
string
tags?
string[]

Returns

void | Promise<void>

Implementation of

CallbackHandlerMethods.handleAgentAction;

Inherited from

BaseCallbackHandler.handleAgentAction;

handleAgentEnd()

handleAgentEnd(finish: AgentFinish, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:397 Called when an agent finishes execution, before it exits. with the final output and the run ID.

Parameters

finish
AgentFinish
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleAgentEnd;

Overrides

BaseCallbackHandler.handleAgentEnd;

handleChainEnd()

handleChainEnd(
   outputs: ChainValues,
   runId: string,
   parentRunId?: string,
   tags?: string[],
kwargs?: object): Promise<void>;
Defined in: src/handlers/langchain.ts:378 Called at the end of a Chain run, with the outputs and the run ID.

Parameters

outputs
ChainValues
runId
string
parentRunId?
string
tags?
string[]
kwargs?
inputs?
Record<string, unknown>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleChainEnd;

Overrides

BaseCallbackHandler.handleChainEnd;

handleChainError()

handleChainError(err: AxiosError, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:371 Called if a Chain run encounters an error

Parameters

err
AxiosError
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleChainError;

Overrides

BaseCallbackHandler.handleChainError;

handleChainStart()

handleChainStart(
   chain: undefined | Serialized,
   inputs: ChainValues,
   runId: string,
   parentRunId?: string,
   tags?: string[],
metadata?: Record<string, any>): Promise<void>;
Defined in: src/handlers/langchain.ts:318 Called at the start of a Chain run, with the chain name and inputs and the run ID.

Parameters

chain
undefined | Serialized
inputs
ChainValues
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, any>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleChainStart;

Overrides

BaseCallbackHandler.handleChainStart;

handleChatModelStart()

handleChatModelStart(
   llm: undefined | Serialized,
   messages: BaseMessage[][],
   runId: string,
   parentRunId?: string,
   extraParams?: Record<string, unknown>,
   tags?: string[],
metadata?: Record<string, any>): Promise<void>;
Defined in: src/handlers/langchain.ts:462 Called at the start of a Chat Model run, with the prompt(s) and the run ID.

Parameters

llm
undefined | Serialized
messages
BaseMessage[][]
runId
string
parentRunId?
string
extraParams?
Record<string, unknown>
tags?
string[]
metadata?
Record<string, any>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleChatModelStart;

Overrides

BaseCallbackHandler.handleChatModelStart;

handleCustomEvent()?

optional handleCustomEvent(
   eventName: string,
   data: any,
   runId: string,
   tags?: string[],
   metadata?: Record<string, any>): any;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:127

Parameters

eventName
string
data
any
runId
string
tags?
string[]
metadata?
Record<string, any>

Returns

any

Implementation of

CallbackHandlerMethods.handleCustomEvent;

Inherited from

BaseCallbackHandler.handleCustomEvent;

handleLLMEnd()

handleLLMEnd(output: LLMResult, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:511 Called at the end of an LLM/ChatModel run, with the output and the run ID.

Parameters

output
LLMResult
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleLLMEnd;

Overrides

BaseCallbackHandler.handleLLMEnd;

handleLLMError()

handleLLMError(err: AxiosError, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:436 Called if an LLM/ChatModel run encounters an error

Parameters

err
AxiosError
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleLLMError;

Overrides

BaseCallbackHandler.handleLLMError;

handleLLMNewToken()

handleLLMNewToken(
   token: string,
   idx: NewTokenIndices,
runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:443 Called when an LLM/ChatModel in streaming mode produces a new token

Parameters

token
string
idx
NewTokenIndices
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleLLMNewToken;

Overrides

BaseCallbackHandler.handleLLMNewToken;

handleLLMStart()

handleLLMStart(
   llm: undefined | Serialized,
   prompts: string[],
   runId: string,
   parentRunId?: string,
   extraParams?: Record<string, unknown>,
   tags?: string[],
metadata?: Record<string, any>): Promise<void>;
Defined in: src/handlers/langchain.ts:404 Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.

Parameters

llm
undefined | Serialized
prompts
string[]
runId
string
parentRunId?
string
extraParams?
Record<string, unknown>
tags?
string[]
metadata?
Record<string, any>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleLLMStart;

Overrides

BaseCallbackHandler.handleLLMStart;

handleRetrieverEnd()

handleRetrieverEnd(documents: DocumentInterface<Record<string, unknown>>[], runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:599

Parameters

documents
DocumentInterface<Record<string, unknown>>[]
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleRetrieverEnd;

Overrides

BaseCallbackHandler.handleRetrieverEnd;

handleRetrieverError()

handleRetrieverError(err: AxiosError, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:589

Parameters

err
AxiosError
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleRetrieverError;

Overrides

BaseCallbackHandler.handleRetrieverError;

handleRetrieverStart()

handleRetrieverStart(
   retriever: undefined | Serialized,
   query: string,
   runId: string,
   parentRunId?: string,
   tags?: string[],
metadata?: Record<string, any>): Promise<void>;
Defined in: src/handlers/langchain.ts:573

Parameters

retriever
undefined | Serialized
query
string
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, any>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleRetrieverStart;

Overrides

BaseCallbackHandler.handleRetrieverStart;

handleText()?

optional handleText(
   text: string,
   runId: string,
   parentRunId?: string,
tags?: string[]): void | Promise<void>;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:110

Parameters

text
string
runId
string
parentRunId?
string
tags?
string[]

Returns

void | Promise<void>

Implementation of

CallbackHandlerMethods.handleText;

Inherited from

BaseCallbackHandler.handleText;

handleToolEnd()

handleToolEnd(output: any, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:562 Called at the end of a Tool run, with the tool output and the run ID.

Parameters

output
any
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleToolEnd;

Overrides

BaseCallbackHandler.handleToolEnd;

handleToolError()

handleToolError(err: AxiosError, runId: string): Promise<void>;
Defined in: src/handlers/langchain.ts:555 Called if a Tool run encounters an error

Parameters

err
AxiosError
runId
string

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleToolError;

Overrides

BaseCallbackHandler.handleToolError;

handleToolStart()

handleToolStart(
   tool: undefined | Serialized,
   input: string,
   runId: string,
   parentRunId?: string,
   tags?: string[],
metadata?: Record<string, any>): Promise<void>;
Defined in: src/handlers/langchain.ts:534 Called at the start of a Tool run, with the tool name and input and the run ID.

Parameters

tool
undefined | Serialized
input
string
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, any>

Returns

Promise<void>

Implementation of

CallbackHandlerMethods.handleToolStart;

Overrides

BaseCallbackHandler.handleToolStart;

toJSON()

toJSON(): Serialized;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:180

Returns

Serialized

Inherited from

BaseCallbackHandler.toJSON;

toJSONNotImplemented()

toJSONNotImplemented(): SerializedNotImplemented;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:181

Returns

SerializedNotImplemented

Inherited from

BaseCallbackHandler.toJSONNotImplemented;

fromMethods()

static fromMethods(methods: BaseCallbackHandlerMethodsClass): object;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:182

Parameters

methods
BaseCallbackHandlerMethodsClass

Returns

awaitHandlers
awaitHandlers: boolean;
ignoreAgent
ignoreAgent: boolean;
ignoreChain
ignoreChain: boolean;
ignoreCustomEvent
ignoreCustomEvent: boolean;
ignoreLLM
ignoreLLM: boolean;
ignoreRetriever
ignoreRetriever: boolean;
lc_aliases
readonly lc_aliases:
  | undefined
  | {
[key: string]: string;
};
lc_attributes
readonly lc_attributes:
  | undefined
  | {
[key: string]: string;
};
lc_id
readonly lc_id: string[];
The final serialized identifier for the module.
lc_kwargs
lc_kwargs: SerializedFields;
lc_namespace
readonly lc_namespace: ["langchain_core", "callbacks", string];
lc_secrets
readonly lc_secrets:
  | undefined
  | {
[key: string]: string;
};
lc_serializable
lc_serializable: boolean;
name
name: string;
raiseError
raiseError: boolean;
copy()
copy(): BaseCallbackHandler;
Returns
BaseCallbackHandler
handleAgentAction()?
optional handleAgentAction(
   action: AgentAction,
   runId: string,
   parentRunId?: string,
tags?: string[]): void | Promise<void>;
Called when an agent is about to execute an action, with the action and the run ID.
Parameters
action
AgentAction
runId
string
parentRunId?
string
tags?
string[]
Returns
void | Promise<void>
handleAgentEnd()?
optional handleAgentEnd(
   action: AgentFinish,
   runId: string,
   parentRunId?: string,
tags?: string[]): void | Promise<void>;
Called when an agent finishes execution, before it exits. with the final output and the run ID.
Parameters
action
AgentFinish
runId
string
parentRunId?
string
tags?
string[]
Returns
void | Promise<void>
handleChainEnd()?
optional handleChainEnd(
   outputs: ChainValues,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   kwargs?: object): any;
Called at the end of a Chain run, with the outputs and the run ID.
Parameters
outputs
ChainValues
runId
string
parentRunId?
string
tags?
string[]
kwargs?
inputs?
Record<string, unknown>
Returns
any
handleChainError()?
optional handleChainError(
   err: any,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   kwargs?: object): any;
Called if a Chain run encounters an error
Parameters
err
any
runId
string
parentRunId?
string
tags?
string[]
kwargs?
inputs?
Record<string, unknown>
Returns
any
handleChainStart()?
optional handleChainStart(
   chain: Serialized,
   inputs: ChainValues,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   metadata?: Record<string, unknown>,
   runType?: string,
   runName?: string): any;
Called at the start of a Chain run, with the chain name and inputs and the run ID.
Parameters
chain
Serialized
inputs
ChainValues
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, unknown>
runType?
string
runName?
string
Returns
any
handleChatModelStart()?
optional handleChatModelStart(
   llm: Serialized,
   messages: BaseMessage[][],
   runId: string,
   parentRunId?: string,
   extraParams?: Record<string, unknown>,
   tags?: string[],
   metadata?: Record<string, unknown>,
   runName?: string): any;
Called at the start of a Chat Model run, with the prompt(s) and the run ID.
Parameters
llm
Serialized
messages
BaseMessage[][]
runId
string
parentRunId?
string
extraParams?
Record<string, unknown>
tags?
string[]
metadata?
Record<string, unknown>
runName?
string
Returns
any
handleCustomEvent()?
optional handleCustomEvent(
   eventName: string,
   data: any,
   runId: string,
   tags?: string[],
   metadata?: Record<string, any>): any;
Parameters
eventName
string
data
any
runId
string
tags?
string[]
metadata?
Record<string, any>
Returns
any
handleLLMEnd()?
optional handleLLMEnd(
   output: LLMResult,
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Called at the end of an LLM/ChatModel run, with the output and the run ID.
Parameters
output
LLMResult
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleLLMError()?
optional handleLLMError(
   err: any,
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Called if an LLM/ChatModel run encounters an error
Parameters
err
any
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleLLMNewToken()?
optional handleLLMNewToken(
   token: string,
   idx: NewTokenIndices,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   fields?: HandleLLMNewTokenCallbackFields): any;
Called when an LLM/ChatModel in streaming mode produces a new token
Parameters
token
string
idx
NewTokenIndices
runId
string
parentRunId?
string
tags?
string[]
fields?
HandleLLMNewTokenCallbackFields
Returns
any
handleLLMStart()?
optional handleLLMStart(
   llm: Serialized,
   prompts: string[],
   runId: string,
   parentRunId?: string,
   extraParams?: Record<string, unknown>,
   tags?: string[],
   metadata?: Record<string, unknown>,
   runName?: string): any;
Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.
Parameters
llm
Serialized
prompts
string[]
runId
string
parentRunId?
string
extraParams?
Record<string, unknown>
tags?
string[]
metadata?
Record<string, unknown>
runName?
string
Returns
any
handleRetrieverEnd()?
optional handleRetrieverEnd(
   documents: DocumentInterface<Record<string, any>>[],
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Parameters
documents
DocumentInterface<Record<string, any>>[]
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleRetrieverError()?
optional handleRetrieverError(
   err: any,
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Parameters
err
any
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleRetrieverStart()?
optional handleRetrieverStart(
   retriever: Serialized,
   query: string,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   metadata?: Record<string, unknown>,
   name?: string): any;
Parameters
retriever
Serialized
query
string
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, unknown>
name?
string
Returns
any
handleText()?
optional handleText(
   text: string,
   runId: string,
   parentRunId?: string,
tags?: string[]): void | Promise<void>;
Parameters
text
string
runId
string
parentRunId?
string
tags?
string[]
Returns
void | Promise<void>
handleToolEnd()?
optional handleToolEnd(
   output: any,
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Called at the end of a Tool run, with the tool output and the run ID.
Parameters
output
any
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleToolError()?
optional handleToolError(
   err: any,
   runId: string,
   parentRunId?: string,
   tags?: string[]): any;
Called if a Tool run encounters an error
Parameters
err
any
runId
string
parentRunId?
string
tags?
string[]
Returns
any
handleToolStart()?
optional handleToolStart(
   tool: Serialized,
   input: string,
   runId: string,
   parentRunId?: string,
   tags?: string[],
   metadata?: Record<string, unknown>,
   runName?: string): any;
Called at the start of a Tool run, with the tool name and input and the run ID.
Parameters
tool
Serialized
input
string
runId
string
parentRunId?
string
tags?
string[]
metadata?
Record<string, unknown>
runName?
string
Returns
any
toJSON()
toJSON(): Serialized;
Returns
Serialized
toJSONNotImplemented()
toJSONNotImplemented(): SerializedNotImplemented;
Returns
SerializedNotImplemented

Inherited from

BaseCallbackHandler.fromMethods;

lc_name()

static lc_name(): string;
Defined in: node_modules/@langchain/core/dist/callbacks/base.d.ts:164 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.

Returns

string

Inherited from

BaseCallbackHandler.lc_name;