@langchain/core 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/caches/index.d.ts.map +1 -1
- package/dist/callbacks/base.cjs.map +1 -1
- package/dist/callbacks/base.d.cts +2 -2
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts +2 -2
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/callbacks/base.js.map +1 -1
- package/dist/callbacks/manager.cjs +3 -3
- package/dist/callbacks/manager.cjs.map +1 -1
- package/dist/callbacks/manager.d.cts +1 -1
- package/dist/callbacks/manager.d.cts.map +1 -1
- package/dist/callbacks/manager.d.ts +1 -1
- package/dist/callbacks/manager.d.ts.map +1 -1
- package/dist/callbacks/manager.js +3 -3
- package/dist/callbacks/manager.js.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/load/import_map.cjs +2 -0
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +2 -0
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/index.cjs +85 -25
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.d.cts +113 -3
- package/dist/load/index.d.cts.map +1 -1
- package/dist/load/index.d.ts +113 -3
- package/dist/load/index.d.ts.map +1 -1
- package/dist/load/index.js +85 -25
- package/dist/load/index.js.map +1 -1
- package/dist/load/serializable.cjs +6 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.d.cts +15 -1
- package/dist/load/serializable.d.cts.map +1 -1
- package/dist/load/serializable.d.ts +15 -1
- package/dist/load/serializable.d.ts.map +1 -1
- package/dist/load/serializable.js +6 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/load/validation.cjs +98 -0
- package/dist/load/validation.cjs.map +1 -0
- package/dist/load/validation.js +95 -0
- package/dist/load/validation.js.map +1 -0
- package/dist/messages/base.cjs +1 -0
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +2 -3
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +2 -3
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +1 -0
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts +34 -1
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts +34 -1
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/runnables/base.cjs +1 -1
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.js +1 -1
- package/dist/runnables/base.js.map +1 -1
- package/dist/tracers/base.cjs +5 -2
- package/dist/tracers/base.cjs.map +1 -1
- package/dist/tracers/base.d.cts +1 -1
- package/dist/tracers/base.d.cts.map +1 -1
- package/dist/tracers/base.d.ts +1 -1
- package/dist/tracers/base.d.ts.map +1 -1
- package/dist/tracers/base.js +5 -2
- package/dist/tracers/base.js.map +1 -1
- package/dist/tracers/tracer_langchain.cjs +31 -3
- package/dist/tracers/tracer_langchain.cjs.map +1 -1
- package/dist/tracers/tracer_langchain.d.cts +8 -7
- package/dist/tracers/tracer_langchain.d.cts.map +1 -1
- package/dist/tracers/tracer_langchain.d.ts +8 -7
- package/dist/tracers/tracer_langchain.d.ts.map +1 -1
- package/dist/tracers/tracer_langchain.js +31 -3
- package/dist/tracers/tracer_langchain.js.map +1 -1
- package/dist/utils/context.cjs +107 -0
- package/dist/utils/context.cjs.map +1 -0
- package/dist/utils/context.d.cts +44 -0
- package/dist/utils/context.d.cts.map +1 -0
- package/dist/utils/context.d.ts +44 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +101 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/event_source_parse.d.cts.map +1 -1
- package/dist/utils/stream.d.cts.map +1 -1
- package/dist/vectorstores.d.cts.map +1 -1
- package/package.json +13 -2
- package/utils/context.cjs +1 -0
- package/utils/context.d.cts +1 -0
- package/utils/context.d.ts +1 -0
- package/utils/context.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @langchain/core
|
|
2
2
|
|
|
3
|
+
## 1.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#9707](https://github.com/langchain-ai/langchainjs/pull/9707) [`e5063f9`](https://github.com/langchain-ai/langchainjs/commit/e5063f9c6e9989ea067dfdff39262b9e7b6aba62) Thanks [@hntrl](https://github.com/hntrl)! - add security hardening for `load`
|
|
8
|
+
|
|
9
|
+
- [#9684](https://github.com/langchain-ai/langchainjs/pull/9684) [`8996647`](https://github.com/langchain-ai/langchainjs/commit/89966470e8c0b112ce4f9a326004af6a4173f9e6) Thanks [@christian-bromann](https://github.com/christian-bromann)! - fix(core): document purpose of name in base message
|
|
10
|
+
|
|
11
|
+
## 1.1.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#9686](https://github.com/langchain-ai/langchainjs/pull/9686) [`df9c42b`](https://github.com/langchain-ai/langchainjs/commit/df9c42b3ab61b85309ab47256e1d93c3188435ee) Thanks [@hntrl](https://github.com/hntrl)! - add usage_metadata to metadata in LangChainTracer
|
|
16
|
+
|
|
17
|
+
- [#9665](https://github.com/langchain-ai/langchainjs/pull/9665) [`8d2982b`](https://github.com/langchain-ai/langchainjs/commit/8d2982bb94c0f4e4314ace3cc98a1ae87571b1ed) Thanks [@jacoblee93](https://github.com/jacoblee93)! - feat(core): Make runnable transform trace in a single payload in LangChainTracer
|
|
18
|
+
|
|
19
|
+
- [#9675](https://github.com/langchain-ai/langchainjs/pull/9675) [`af664be`](https://github.com/langchain-ai/langchainjs/commit/af664becc0245b2315ea2f784c9a6c1d7622dbb4) Thanks [@jacoblee93](https://github.com/jacoblee93)! - Bump LangSmith dep to 0.4.0
|
|
20
|
+
|
|
21
|
+
- [#9673](https://github.com/langchain-ai/langchainjs/pull/9673) [`ffb2402`](https://github.com/langchain-ai/langchainjs/commit/ffb24026cd93e58219519ee24c6e23ea57cb5bde) Thanks [@hntrl](https://github.com/hntrl)! - add `context` utility
|
|
22
|
+
|
|
3
23
|
## 1.1.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","___messages_message_js0","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/index.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\nexport declare const defaultHashKeyEncoder: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/chat.js\").ChatMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/function.js\").FunctionMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/human.js\").HumanMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/system.js\").SystemMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/tool.js\").ToolMessage<import(\"../messages/message.js\").MessageStructure>;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;;;;;;iBAO9CW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;uBAW8BY,cAAcb;wBAClBD;;;;;;;sCAOcA;mDACagB,QAAQD;yDACFA,IAAIC;;AAnB4d;AAK3hB;AAIA;AAA4Cf,cAevBgB,aAfuBhB,CAAAA,IAeLA,UAfKA,EAAAA,CAAAA,SAeiBa,SAfjBb,CAe2Bc,CAf3Bd,CAAAA,CAAAA;EAClBD,QAAAA,KAAAA;EAOcA,WAAAA,CAAAA,GAAAA,CAAAA,EASlBkB,GATkBlB,CAAAA,MAAAA,EASNe,CATMf,CAAAA;EACqBe;;;;AACS;AAKtE;;EAAuEA,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAU3BC,OAV2BD,CAUnBA,CAVmBA,GAAAA,IAAAA,CAAAA;EAErCA;;;;;;EAqBbE,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAN6BF,CAM7BE,CAAAA,EANiCD,OAMjCC,CAAAA,IAAAA,CAAAA;EAvBwCH;AAAS;;;;mBAuBjDG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["x: BaseCallbackHandler","get_lc_unique_name","getEnvironmentVariable","input?: BaseCallbackHandlerInput","Serializable","methods: CallbackHandlerMethods","x: unknown"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\nabstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n token: string,\n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runType?: string,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C,CA4N9C;AAsBD,SAAgB,gCAAgCA,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;AACxC;;;;;;;AAQD,IAAsB,sBAAtB,cACU,gCAEV;CACE,kBAAkB;CAElB,IAAI,eAAwD;AAC1D,SAAO;GAAC;GAAkB;GAAa,KAAK;EAAK;CAClD;CAED,IAAI,aAAoD;AACtD,SAAO;CACR;CAED,IAAI,gBAAuD;AACzD,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO;CACR;CAED,IAAI,uBAA6C;AAC/C,SAAO;CACR;;;;;;;CAQD,OAAO,UAAkB;AACvB,SAAO,KAAK;CACb;;;;CAKD,IAAI,QAAkB;AACpB,SAAO,CACL,GAAG,KAAK,cACRC,6CAAmB,KAAK,YAA0C,AACnE;CACF;CAED;CAIA,YAAY;CAEZ,cAAc;CAEd,cAAc;CAEd,kBAAkB;CAElB,oBAAoB;CAEpB,aAAa;CAEb,gBACEC,yCAAuB,iCAAiC,KAAK;CAE/D,YAAYC,OAAkC;EAC5C,OAAO;EACP,KAAK,YAAY,SAAS,CAAE;AAC5B,MAAI,OAAO;GACT,KAAK,YAAY,MAAM,aAAa,KAAK;GACzC,KAAK,cAAc,MAAM,eAAe,KAAK;GAC7C,KAAK,cAAc,MAAM,eAAe,KAAK;GAC7C,KAAK,kBAAkB,MAAM,mBAAmB,KAAK;GACrD,KAAK,oBACH,MAAM,qBAAqB,KAAK;GAClC,KAAK,aAAa,MAAM,cAAc,KAAK;GAC3C,KAAK,gBACH,KAAK,eAAe,MAAM,iBAAiB,KAAK;EACnD;CACF;CAED,OAA4B;AAC1B,SAAO,IAAK,KAAK,YAES;CAC3B;CAED,SAAqB;AACnB,SAAOC,uCAAa,UAAU,OAAO,KAAK,KAAK;CAChD;CAED,uBAAiD;AAC/C,SAAOA,uCAAa,UAAU,qBAAqB,KAAK,KAAK;CAC9D;CAED,OAAO,YAAYC,SAAiC;EAClD,MAAM,gBAAgB,oBAAoB;GACxC,OAAO,KAAK,IAAI;GAEhB,cAAc;IACZ,OAAO;IACP,OAAO,OAAO,MAAM,QAAQ;GAC7B;EACF;AACD,SAAO,IAAI;CACZ;AACF;AAED,MAAa,wBAAwB,CAACC,MAAe;CACnD,MAAM,kBAAkB;AACxB,QACE,oBAAoB,UACpB,OAAO,gBAAgB,SAAS,cAChC,OAAO,gBAAgB,SAAS,YAChC,OAAO,gBAAgB,kBAAkB;AAE5C"}
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["x: BaseCallbackHandler","get_lc_unique_name","getEnvironmentVariable","input?: BaseCallbackHandlerInput","Serializable","methods: CallbackHandlerMethods","x: unknown"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\nabstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n token: string,\n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n runType?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n parentRunId?: string,\n extra?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C,CA6N9C;AAsBD,SAAgB,gCAAgCA,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;AACxC;;;;;;;AAQD,IAAsB,sBAAtB,cACU,gCAEV;CACE,kBAAkB;CAElB,IAAI,eAAwD;AAC1D,SAAO;GAAC;GAAkB;GAAa,KAAK;EAAK;CAClD;CAED,IAAI,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B,SAAS,YAChC,OAAO,gBAAgB,kBAAkB;AAE5C"}
|
|
@@ -73,7 +73,7 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
73
73
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
74
74
|
* and the run ID.
|
|
75
75
|
*/
|
|
76
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string,
|
|
76
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): Promise<any> | any;
|
|
77
77
|
/**
|
|
78
78
|
* Called if a Chain run encounters an error
|
|
79
79
|
*/
|
|
@@ -205,7 +205,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
205
205
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
206
206
|
* and the run ID.
|
|
207
207
|
*/
|
|
208
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string,
|
|
208
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined, parentRunId?: string | undefined, extra?: Record<string, unknown> | undefined): any;
|
|
209
209
|
/**
|
|
210
210
|
* Called if a Chain run encounters an error
|
|
211
211
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js5","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n name: string;\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;KAOKY,KAAAA;;;AAD6D;AAOlE;AAaA;AAIYG,UAjBKF,wBAAAA,CAiB0B;EAQpBG,SAAAA,CAAAA,EAAAA,OAAAA;EAKER,WAAAA,CAAAA,EAAAA,OAAAA;EAAkFS,WAAAA,CAAAA,EAAAA,OAAAA;EAAqDA,eAAAA,CAAAA,EAAAA,OAAAA;EAA4CC,iBAAAA,CAAAA,EAAAA,OAAAA;EAWnMJ,aAAAA,CAAAA,EAAAA,OAAAA;EAAgFC,UAAAA,CAAAA,EAAAA,OAAAA;;;;;;AAQgBE,UApCxFH,eAAAA,CAoCwFG;EAA0BC,MAAAA,EAAAA,MAAAA;EAKpGV,UAAAA,EAAAA,MAAAA;;AAA0FS,KArC7GF,+BAAAA,GAqC6GE;EAAqDA,KAAAA,CAAAA,EApClKZ,eAoCkKY,GApChJb,mBAoCgJa;CAA4CC;;;;;;uBA7BnMF,+BAAAA,CAuCNC;EACTC;;;;EAWmBV,cAAAA,CAAAA,CAAAA,GAAAA,EA9CFA,UA8CEA,EAAAA,OAAAA,EAAAA,MAAAA,EAAAA,EAAAA,KAAAA,EAAAA,MAAAA,EAAAA,WAAA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AA,EAAAA,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EA5BRK,OA4BQL,CAAAA,GAAAA,CAAAA,GAAAA,GAAAA;EAA0BN,iBAAAA,CAAAA,CAAAA,SAAAA,EAAAA,MAAAA,EAAAA,IAAAA,EAAAA,GAAAA,EAAAA,KAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA,EAAAA,QAAAA,CAAAA,EA3B/BU,MA2B+BV,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,EA3BTW,OA2BSX,CAAAA,GAAAA,CAAAA,GAAAA,GAAAA;AAAY;AAuI3I;;;;;;;;;KAvJYY,sBAAAA,GAAyBH;;;;;;UAMpBI,+BAAAA;;;iBAGOC,+BAAAA,IAAmCC;;;;;;;uBAO7BA,mBAAAA,SAA4BN,+BAAAA,YAA2CH,0BAA0BN;;;;;;;;;;;;;;;;;;;;;;;;aAwBhHG;;;;;;;;;sBASSG;UACZS;YACEd;0BACcC;8BACIU;;;;;;yBAMHX,8FAA8FS,6EAA6EA;;;;2CAIzJH,wGAAwGC;;;;0HAIzBE;;;;0BAIhGX,uGAAuGW;;;;;+BAKlGT,sBAAsBP,+GAAiLgB,6EAA6EA;;;;;6BAKtRT,oBAAoBR,sGAAsGiB;;;;;eAKtIA;;;;;6BAKYjB;eACZiB;;;;;;2BAMUT,oHAAoHS;;;;;;;;;oHAS3BC;;;;;+BAKrFhB,mGAAmGgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;cAGXiB"}
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js5","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n name: string;\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined, parentRunId?: string | undefined, extra?: Record<string, unknown> | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;KAOKY,KAAAA;;;AAD6D;AAOlE;AAaA;AAIYG,UAjBKF,wBAAAA,CAiB0B;EAQpBG,SAAAA,CAAAA,EAAAA,OAAAA;EAKER,WAAAA,CAAAA,EAAAA,OAAAA;EAAkFS,WAAAA,CAAAA,EAAAA,OAAAA;EAAqDA,eAAAA,CAAAA,EAAAA,OAAAA;EAA4CC,iBAAAA,CAAAA,EAAAA,OAAAA;EAWnMJ,aAAAA,CAAAA,EAAAA,OAAAA;EAAgFC,UAAAA,CAAAA,EAAAA,OAAAA;;;;;;AAQgBE,UApCxFH,eAAAA,CAoCwFG;EAA0BC,MAAAA,EAAAA,MAAAA;EAKpGV,UAAAA,EAAAA,MAAAA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B,6EAA6EA;;;;;6BAKtRT,oBAAoBR,kGAAkGiB,6GAA6GA;;;;;eAK/OA;;;;;6BAKYjB;eACZiB;;;;;;2BAMUT,oHAAoHS;;;;;;;;;oHAS3BC;;;;;+BAKrFhB,mGAAmGgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;cAGXiB"}
|
package/dist/callbacks/base.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
73
73
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
74
74
|
* and the run ID.
|
|
75
75
|
*/
|
|
76
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string,
|
|
76
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): Promise<any> | any;
|
|
77
77
|
/**
|
|
78
78
|
* Called if a Chain run encounters an error
|
|
79
79
|
*/
|
|
@@ -205,7 +205,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
205
205
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
206
206
|
* and the run ID.
|
|
207
207
|
*/
|
|
208
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string,
|
|
208
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined, parentRunId?: string | undefined, extra?: Record<string, unknown> | undefined): any;
|
|
209
209
|
/**
|
|
210
210
|
* Called if a Chain run encounters an error
|
|
211
211
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js0","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n name: string;\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;KAOKY,KAAAA;;;AAD6D;AAOlE;AAaA;AAIYG,UAjBKF,wBAAAA,CAiB0B;EAQpBG,SAAAA,CAAAA,EAAAA,OAAAA;EAKER,WAAAA,CAAAA,EAAAA,OAAAA;EAAkFS,WAAAA,CAAAA,EAAAA,OAAAA;EAAqDA,eAAAA,CAAAA,EAAAA,OAAAA;EAA4CC,iBAAAA,CAAAA,EAAAA,OAAAA;EAWnMJ,aAAAA,CAAAA,EAAAA,OAAAA;EAAgFC,UAAAA,CAAAA,EAAAA,OAAAA;;;;;;AAQgBE,UApCxFH,eAAAA,CAoCwFG;EAA0BC,MAAAA,EAAAA,MAAAA;EAKpGV,UAAAA,EAAAA,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GgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;cAGXiB"}
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js5","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n name: string;\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined, parentRunId?: string | undefined, extra?: Record<string, unknown> | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;KAOKY,KAAAA;;;AAD6D;AAOlE;AAaA;AAIYG,UAjBKF,wBAAAA,CAiB0B;EAQpBG,SAAAA,CAAAA,EAAAA,OAAAA;EAKER,WAAAA,CAAAA,EAAAA,OAAAA;EA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C,+BAAAA,IAAmCC;;;;;;;uBAO7BA,mBAAAA,SAA4BN,+BAAAA,YAA2CH,0BAA0BN;;;;;;;;;;;;;;;;;;;;;;;;aAwBhHG;;;;;;;;;sBASSG;UACZS;YACEd;0BACcC;8BACIU;;;;;;yBAMHX,8FAA8FS,6EAA6EA;;;;2CAIzJH,wGAAwGC;;;;0HAIzBE;;;;0BAIhGX,uGAAuGW;;;;;+BAKlGT,sBAAsBP,+GAAiLgB,6EAA6EA;;;;;6BAKtRT,oBAAoBR,kGAAkGiB,6GAA6GA;;;;;eAK/OA;;;;;6BAKYjB;eACZiB;;;;;;2BAMUT,oHAAoHS;;;;;;;;;oHAS3BC;;;;;+BAKrFhB,mGAAmGgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;cAGXiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":["x: BaseCallbackHandler","input?: BaseCallbackHandlerInput","methods: CallbackHandlerMethods","x: unknown"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\nabstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n token: string,\n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runType?: string,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C,CA4N9C;AAsBD,SAAgB,gCAAgCA,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;AACxC;;;;;;;AAQD,IAAsB,sBAAtB,cACU,gCAEV;CACE,kBAAkB;CAElB,IAAI,eAAwD;AAC1D,SAAO;GAAC;GAAkB;GAAa,KAAK;EAAK;CAClD;CAED,IAAI,aAAoD;AACtD,SAAO;CACR;CAED,IAAI,gBAAuD;AACzD,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO;CACR;CAED,IAAI,uBAA6C;AAC/C,SAAO;CACR;;;;;;;CAQD,OAAO,UAAkB;AACvB,SAAO,KAAK;CACb;;;;CAKD,IAAI,QAAkB;AACpB,SAAO,CACL,GAAG,KAAK,cACR,mBAAmB,KAAK,YAA0C,AACnE;CACF;CAED;CAIA,YAAY;CAEZ,cAAc;CAEd,cAAc;CAEd,kBAAkB;CAElB,oBAAoB;CAEpB,aAAa;CAEb,gBACE,uBAAuB,iCAAiC,KAAK;CAE/D,YAAYC,OAAkC;EAC5C,OAAO;EACP,KAAK,YAAY,SAAS,CAAE;AAC5B,MAAI,OAAO;GACT,KAAK,YAAY,MAAM,aAAa,KAAK;GACzC,KAAK,cAAc,MAAM,eAAe,KAAK;GAC7C,KAAK,cAAc,MAAM,eAAe,KAAK;GAC7C,KAAK,kBAAkB,MAAM,mBAAmB,KAAK;GACrD,KAAK,oBACH,MAAM,qBAAqB,KAAK;GAClC,KAAK,aAAa,MAAM,cAAc,KAAK;GAC3C,KAAK,gBACH,KAAK,eAAe,MAAM,iBAAiB,KAAK;EACnD;CACF;CAED,OAA4B;AAC1B,SAAO,IAAK,KAAK,YAES;CAC3B;CAED,SAAqB;AACnB,SAAO,aAAa,UAAU,OAAO,KAAK,KAAK;CAChD;CAED,uBAAiD;AAC/C,SAAO,aAAa,UAAU,qBAAqB,KAAK,KAAK;CAC9D;CAED,OAAO,YAAYC,SAAiC;EAClD,MAAM,gBAAgB,oBAAoB;GACxC,OAAO,KAAK,IAAI;GAEhB,cAAc;IACZ,OAAO;IACP,OAAO,OAAO,MAAM,QAAQ;GAC7B;EACF;AACD,SAAO,IAAI;CACZ;AACF;AAED,MAAa,wBAAwB,CAACC,MAAe;CACnD,MAAM,kBAAkB;AACxB,QACE,oBAAoB,UACpB,OAAO,gBAAgB,SAAS,cAChC,OAAO,gBAAgB,SAAS,YAChC,OAAO,gBAAgB,kBAAkB;AAE5C"}
|
|
1
|
+
{"version":3,"file":"base.js","names":["x: BaseCallbackHandler","input?: BaseCallbackHandlerInput","methods: CallbackHandlerMethods","x: unknown"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\nabstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n token: string,\n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n runType?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n parentRunId?: string,\n extra?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C,CA6N9C;AAsBD,SAAgB,gCAAgCA,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;AACxC;;;;;;;A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ACF;AAED,MAAa,wBAAwB,CAACC,MAAe;CACnD,MAAM,kBAAkB;AACxB,QACE,oBAAoB,UACpB,OAAO,gBAAgB,SAAS,cAChC,OAAO,gBAAgB,SAAS,YAChC,OAAO,gBAAgB,kBAAkB;AAE5C"}
|
|
@@ -323,13 +323,13 @@ var CallbackManager = class CallbackManager extends BaseCallbackManager {
|
|
|
323
323
|
return new CallbackManagerForLLMRun(runId_, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
|
|
324
324
|
}));
|
|
325
325
|
}
|
|
326
|
-
async handleChainStart(chain, inputs, runId = (0, uuid.v7)(), runType = void 0, _tags = void 0, _metadata = void 0, runName = void 0) {
|
|
326
|
+
async handleChainStart(chain, inputs, runId = (0, uuid.v7)(), runType = void 0, _tags = void 0, _metadata = void 0, runName = void 0, _parentRunId = void 0, extra = void 0) {
|
|
327
327
|
await Promise.all(this.handlers.map((handler) => {
|
|
328
328
|
if (handler.ignoreChain) return;
|
|
329
|
-
if (require_tracers_base.isBaseTracer(handler)) handler._createRunForChainStart(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName);
|
|
329
|
+
if (require_tracers_base.isBaseTracer(handler)) handler._createRunForChainStart(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName, extra);
|
|
330
330
|
return require_callbacks.consumeCallback(async () => {
|
|
331
331
|
try {
|
|
332
|
-
await handler.handleChainStart?.(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName);
|
|
332
|
+
await handler.handleChainStart?.(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName, extra);
|
|
333
333
|
} catch (err) {
|
|
334
334
|
const logFunction = handler.raiseError ? console.error : console.warn;
|
|
335
335
|
logFunction(`Error in handler ${handler.constructor.name}, handleChainStart: ${err}`);
|