import { AgentAction, AgentFinish, ChainValues, LLMResult } from "../schema/index.js"; type Error = any; export interface BaseCallbackHandlerInput { ignoreLLM?: boolean; ignoreChain?: boolean; ignoreAgent?: boolean; } declare abstract class BaseCallbackHandlerMethodsClass { /** * Called at the start of an LLM or Chat Model run, with the prompt(s) * and the run ID. */ handleLLMStart?(llm: { name: string; }, prompts: string[], runId: string, parentRunId?: string): Promise | void; /** * Called when an LLM/ChatModel in `streaming` mode produces a new token */ handleLLMNewToken?(token: string, runId: string, parentRunId?: string): Promise | void; /** * Called if an LLM/ChatModel run encounters an error */ handleLLMError?(err: Error, runId: string, parentRunId?: string): Promise | void; /** * Called at the end of an LLM/ChatModel run, with the output and the run ID. */ handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string): Promise | void; /** * Called at the start of a Chain run, with the chain name and inputs * and the run ID. */ handleChainStart?(chain: { name: string; }, inputs: ChainValues, runId: string, parentRunId?: string): Promise | void; /** * Called if a Chain run encounters an error */ handleChainError?(err: Error, runId: string, parentRunId?: string): Promise | void; /** * Called at the end of a Chain run, with the outputs and the run ID. */ handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string): Promise | void; /** * Called at the start of a Tool run, with the tool name and input * and the run ID. */ handleToolStart?(tool: { name: string; }, input: string, runId: string, parentRunId?: string): Promise | void; /** * Called if a Tool run encounters an error */ handleToolError?(err: Error, runId: string, parentRunId?: string): Promise | void; /** * Called at the end of a Tool run, with the tool output and the run ID. */ handleToolEnd?(output: string, runId: string, parentRunId?: string): Promise | void; handleText?(text: string, runId: string, parentRunId?: string): Promise | void; /** * Called when an agent is about to execute an action, * with the action and the run ID. */ handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string): Promise | void; /** * Called when an agent finishes execution, before it exits. * with the final output and the run ID. */ handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string): Promise | void; } /** * Base interface for callbacks. All methods are optional. If a method is not * implemented, it will be ignored. If a method is implemented, it will be * called at the appropriate time. All methods are called with the run ID of * the LLM/ChatModel/Chain that is running, which is generated by the * CallbackManager. * * @interface */ export type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass; export declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput { abstract name: string; ignoreLLM: boolean; ignoreChain: boolean; ignoreAgent: boolean; constructor(input?: BaseCallbackHandlerInput); copy(): BaseCallbackHandler; static fromMethods(methods: CallbackHandlerMethods): { name: string; ignoreLLM: boolean; ignoreChain: boolean; ignoreAgent: boolean; copy(): BaseCallbackHandler; /** * Called at the start of an LLM or Chat Model run, with the prompt(s) * and the run ID. */ handleLLMStart?(llm: { name: string; }, prompts: string[], runId: string, parentRunId?: string | undefined): void | Promise; /** * Called when an LLM/ChatModel in `streaming` mode produces a new token */ handleLLMNewToken?(token: string, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called if an LLM/ChatModel run encounters an error */ handleLLMError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called at the end of an LLM/ChatModel run, with the output and the run ID. */ handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called at the start of a Chain run, with the chain name and inputs * and the run ID. */ handleChainStart?(chain: { name: string; }, inputs: ChainValues, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called if a Chain run encounters an error */ handleChainError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called at the end of a Chain run, with the outputs and the run ID. */ handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called at the start of a Tool run, with the tool name and input * and the run ID. */ handleToolStart?(tool: { name: string; }, input: string, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called if a Tool run encounters an error */ handleToolError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called at the end of a Tool run, with the tool output and the run ID. */ handleToolEnd?(output: string, runId: string, parentRunId?: string | undefined): void | Promise; handleText?(text: string, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called when an agent is about to execute an action, * with the action and the run ID. */ handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined): void | Promise; /** * Called when an agent finishes execution, before it exits. * with the final output and the run ID. */ handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined): void | Promise; }; } export {};