@langchain/core 1.0.0-alpha.7 → 1.0.1

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 ADDED
@@ -0,0 +1,131 @@
1
+ # @langchain/core
2
+
3
+ ## 1.0.0
4
+
5
+ 🎉 **LangChain v1.0** is here! This release provides a focused, production-ready foundation for building agents with significant improvements to the core abstractions and APIs. See the [release notes](https://docs.langchain.com/oss/javascript/releases/langchain-v1) for more details.
6
+
7
+ ### ✨ Major Features
8
+
9
+ #### Standard content blocks
10
+
11
+ A new unified API for accessing modern LLM features across all providers:
12
+
13
+ - **New `contentBlocks` property**: Provides provider-agnostic access to reasoning traces, citations, built-in tools (web search, code interpreters, etc.), and other advanced LLM features
14
+ - **Type-safe**: Full TypeScript support with type hints for all content block types
15
+ - **Backward compatible**: Content blocks can be loaded lazily with no breaking changes to existing code
16
+
17
+ Example:
18
+
19
+ ```typescript
20
+ const response = await model.invoke([
21
+ { role: "user", content: "What is the weather in Tokyo?" },
22
+ ]);
23
+
24
+ // Access structured content blocks
25
+ for (const block of response.contentBlocks) {
26
+ if (block.type === "thinking") {
27
+ console.log("Model reasoning:", block.thinking);
28
+ } else if (block.type === "text") {
29
+ console.log("Response:", block.text);
30
+ }
31
+ }
32
+ ```
33
+
34
+ For more information, see our guide on [content blocks](https://docs.langchain.com/oss/javascript/langchain/messages#content).
35
+
36
+ #### Enhanced Message API
37
+
38
+ Improvements to the core message types:
39
+
40
+ - **Structured content**: Better support for multimodal content with the new content blocks API
41
+ - **Provider compatibility**: Consistent message format across all LLM providers
42
+ - **Rich metadata**: Enhanced metadata support for tracking message provenance and transformations
43
+
44
+ ### 🔧 Improvements
45
+
46
+ - **Better structured output generation**: Core abstractions for generating structured outputs in the main agent loop
47
+ - **Improved type safety**: Enhanced TypeScript definitions across all core abstractions
48
+ - **Performance optimizations**: Reduced overhead in message processing and runnable composition
49
+ - **Better error handling**: More informative error messages and better error recovery
50
+
51
+ ### 📦 Package Changes
52
+
53
+ The `@langchain/core` package remains focused on essential abstractions:
54
+
55
+ - Core message types and content blocks
56
+ - Base runnable abstractions
57
+ - Tool definitions and schemas
58
+ - Middleware infrastructure
59
+ - Callback system
60
+ - Output parsers
61
+ - Prompt templates
62
+
63
+ ### 🔄 Migration Notes
64
+
65
+ **Backward Compatibility**: This release maintains backward compatibility with existing code. Content blocks are loaded lazily, so no changes are required to existing applications.
66
+
67
+ **New Features**: To take advantage of new features like content blocks and middleware:
68
+
69
+ 1. Update to `@langchain/core@next`:
70
+
71
+ ```bash
72
+ npm install @langchain/core@1.0.0
73
+ ```
74
+
75
+ 2. Use the new `contentBlocks` property to access rich content:
76
+
77
+ ```typescript
78
+ const response = await model.invoke(messages);
79
+ console.log(response.contentBlocks); // New API
80
+ console.log(response.content); // Legacy API still works
81
+ ```
82
+
83
+ 3. For middleware and `createAgent`, install `langchain@next`:
84
+
85
+ ```bash
86
+ npm install langchain@1.0.0 @langchain/core@1.0.0
87
+ ```
88
+
89
+ ### 📚 Additional Resources
90
+
91
+ - [LangChain 1.0 Announcement](https://blog.langchain.com/langchain-langchain-1-0-alpha-releases/)
92
+ - [Migration Guide](https://docs.langchain.com/oss/javascript/migrate/langchain-v1)
93
+ - [Content Blocks Documentation](https://docs.langchain.com/oss/javascript/langchain/messages#content)
94
+ - [Agents Documentation](https://docs.langchain.com/oss/javascript/langchain/agents)
95
+
96
+ ---
97
+
98
+ ## 0.3.78
99
+
100
+ ### Patch Changes
101
+
102
+ - 1519a97: update chunk concat logic to match on missing ID fields
103
+ - 079e11d: omit tool call chunks without tool call id
104
+
105
+ ## 0.3.76
106
+
107
+ ### Patch Changes
108
+
109
+ - 41bd944: support base64 embeddings format
110
+ - e90bc0a: fix(core): prevent tool call chunks from merging incorrectly in AIMes…
111
+ - 3a99a40: Fix deserialization of RemoveMessage if represented as a plain object
112
+ - 58e9522: make mustache prompt with nested object working correctly
113
+ - e44dc1b: handle backticks in structured output
114
+
115
+ ## 0.3.75
116
+
117
+ ### Patch Changes
118
+
119
+ - d6d841f: fix(core): Fix deep nesting of runnables within traceables
120
+
121
+ ## 0.3.74
122
+
123
+ ### Patch Changes
124
+
125
+ - 4e53005: fix(core): Always inherit parent run id onto callback manager from context
126
+
127
+ ## 0.3.73
128
+
129
+ ### Patch Changes
130
+
131
+ - a5a2e10: add root export to satisfy bundler requirements
package/README.md CHANGED
@@ -72,27 +72,10 @@ leigh
72
72
  Note that for compatibility, all used LangChain packages (including the base LangChain package, which itself depends on core!) must share the same version of `@langchain/core`.
73
73
  This means that you may need to install/resolve a specific version of `@langchain/core` that matches the dependencies of your used packages.
74
74
 
75
- ## 📕 Releases & Versioning
76
-
77
- `@langchain/core` is currently on version `0.3.x`.
78
-
79
- As `@langchain/core` contains the base abstractions and runtime for the whole LangChain ecosystem, we will communicate any breaking changes with advance notice and version bumps. The exception for this is anything in `@langchain/core/beta`. The reason for `@langchain/core/beta` is that given the rate of change of the field, being able to move quickly is still a priority, and this module is our attempt to do so.
80
-
81
- Minor version increases will occur for:
82
-
83
- - Breaking changes for any public interfaces NOT in `@langchain/core/beta`
84
-
85
- Patch version increases will occur for:
86
-
87
- - Bug fixes
88
- - New features
89
- - Any changes to private interfaces
90
- - Any changes to `@langchain/core/beta`
91
-
92
75
  ## 📦 Creating your own package
93
76
 
94
77
  Other LangChain packages should add this package as a dependency and extend the classes within.
95
- For an example, see the [@langchain/anthropic](https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic) in this repo.
78
+ For an example, see the [@langchain/anthropic](https://github.com/langchain-ai/langchainjs/tree/main/libs/providers/langchain-anthropic) in this repo.
96
79
 
97
80
  Because all used packages must share the same version of core, packages should never directly depend on `@langchain/core`. Instead they should have core as a peer dependency and a dev dependency. We suggest using a tilde dependency to allow for different (backwards-compatible) patch versions:
98
81
 
@@ -116,12 +99,8 @@ Because all used packages must share the same version of core, packages should n
116
99
  }
117
100
  ```
118
101
 
119
- This recommendation will change to a caret once a major version (1.x.x) release has occurred.
120
-
121
102
  We suggest making all packages cross-compatible with ESM and CJS using a build step like the one in
122
- [@langchain/anthropic](https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic), then running `pnpm build` before running `npm publish`.
123
-
124
- We will be exploring how to make this process easier in the future.
103
+ [@langchain/anthropic](https://github.com/langchain-ai/langchainjs/tree/main/libs/providers/langchain-anthropic), then running `pnpm build` before running `npm publish`.
125
104
 
126
105
  ## 💁 Contributing
127
106
 
@@ -1 +1 @@
1
- {"version":3,"file":"base.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_js1","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.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"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;WAE8B,UAFd,gBAAA,IAE6G,YAAjJ,gBAAA,IAAwP,gBAAzJ,gBAAA,IAA0P,aAAnJ,gBAAA,IAAsP,cAArJ,gBAAA,IAAoP,YAAjJ,gBAAA;;;;;iBAKpaW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;AAAsEA,uBAWxCY,SAXwCZ,CAAAA,IAW1BD,UAX0BC,EAAAA,CAAAA,CAAAA;EAAgB,UAAA,UAAA,EAY5DF,cAZ4D;EAEc;;;;;;EAAuS,qBAAA,CAAA,YAAA,EAiBnWA,cAjBmW,CAAA,EAAA,IAAA;EAAlD,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAkBpSgB,OAlBoS,CAkB5RD,CAlB4R,GAAA,IAAA,CAAA;EAAqJ,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAmBnbA,CAnBmb,CAAA,EAmB/aC,OAnB+a,CAAA,IAAA,CAAA;;;AAA6C;AAK3hB;AAA2C,cAmBtBC,aAnBsB,CAAA,IAmBJhB,UAnBI,EAAA,CAAA,SAmBkBa,SAnBlB,CAmB4BC,CAnB5B,CAAA,CAAA;EAAA,QAAad,KAAAA;EAAU,WAAGC,CAAAA,GAAAA,CAAAA,EAqB/CgB,GArB+ChB,CAAAA,MAAAA,EAqBnCa,CArBmCb,CAAAA;EAAgB;AAIrF;;;;;;EAS8D,MAATc,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAgBTA,OAhBSA,CAgBDD,CAhBCC,GAAAA,IAAAA,CAAAA;EAAO;;AACU;AAKtE;;;EAAiD,MAAsBD,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
1
+ {"version":3,"file":"base.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/base.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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,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
@@ -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\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\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}\n// TODO: Add all additional callback fields here\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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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 }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\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, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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 /**\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 readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly 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 name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;;KAQKY,KAAAA;;AAF6D;AAQlE;AAaA;AAKA;AAA2C,UAlB1BC,wBAAAA,CAkB0B;EAAA,SAC/BR,CAAAA,EAAAA,OAAAA;EAAe,WAAGD,CAAAA,EAAAA,OAAAA;EAAmB,WAAA,CAAA,EAAA,OAAA;EAO1BY,eAAAA,CAAAA,EAAAA,OAAAA;EAA+B,iBAAA,CAAA,EAAA,OAAA;EAAA,aAK7BR,CAAAA,EAAAA,OAAAA;EAAU,UAAwES,CAAAA,EAAAA,OAAAA;;;;;;AAiBlFL,UAnCRE,eAAAA,CAmCQF;EAAK,MAAsEK,EAAAA,MAAAA;EAAM,UACtGC,EAAAA,MAAAA;;;AAKAA,KApCQH,+BAAAA,GAoCRG;EAAO,KAKoBV,CAAAA,EAxCnBH,eAwCmBG,GAxCDJ,mBAwCCI;CAAU;;;;;;uBAjClBQ,+BAAAA,CAuCwGC;EAAM;;;;EAQ1H,cAIkBjB,CAAAA,CAAAA,GAAAA,EA9CJQ,UA8CIR,EAAAA,OAAAA,EAAAA,MAAAA,EAAAA,EAAAA,KAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA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YAQHY;cACEd;4BACcC;;;;cAIXiB"}
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\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\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}\n// TODO: Add all additional callback fields here\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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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 }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\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, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 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 /**\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 readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly 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 name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;;KAQKY,KAAAA;;AAF6D;AAQlE;AAaA;AAKA;AAA2C,UAlB1BC,wBAAAA,CAkB0B;EAAA,SAC/BR,CAAAA,EAAAA,OAAAA;EAAe,WAAGD,CAAAA,EAAAA,OAAAA;EAAmB,WAAA,CAAA,EAAA,OAAA;EAO1BY,eAAAA,CAAAA,EAAAA,OAAAA;EAA+B,iBAAA,CAAA,EAAA,OAAA;EAAA,aAK7BR,CAAAA,EAAAA,OAAAA;EAAU,UAAwES,CAAAA,EAAAA,OAAAA;;;;;;AAiBlFL,UAnCRE,eAAAA,CAmCQF;EAAK,MAAsEK,EAAAA,MAAAA;EAAM,UACtGC,EAAAA,MAAAA;;;AAKAA,KApCQH,+BAAAA,GAoCRG;EAAO,KAKoBV,CAAAA,EAxCnBH,eAwCmBG,GAxCDJ,mBAwCCI;CAAU;;;;;;uBAjClBQ,+BAAAA,CAuCwGC;EAAM;;;;EAQ1H,cAIkBjB,CAAAA,CAAAA,GAAAA,EA9CJQ,UA8CIR,EAAAA,OAAAA,EAAAA,MAAAA,EAAAA,EAAAA,KAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA,EA9C8EiB,MA8C9EjB,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA,EAAAA,QAAAA,CAA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require("node:async_hooks"));
7
7
 
8
8
  //#region src/callbacks/dispatch/index.ts
9
- var dispatch_exports = {};
10
- require_rolldown_runtime.__export(dispatch_exports, { dispatchCustomEvent: () => dispatchCustomEvent$1 });
11
9
  require_index.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new node_async_hooks.AsyncLocalStorage());
12
10
  /**
13
11
  * Dispatch a custom event.
@@ -49,10 +47,4 @@ async function dispatchCustomEvent$1(eventName, payload, config) {
49
47
 
50
48
  //#endregion
51
49
  exports.dispatchCustomEvent = dispatchCustomEvent$1;
52
- Object.defineProperty(exports, 'dispatch_exports', {
53
- enumerable: true,
54
- get: function () {
55
- return dispatch_exports;
56
- }
57
- });
58
50
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["AsyncLocalStorageProviderSingleton","AsyncLocalStorage","dispatchCustomEvent","eventName: string","payload: any","config?: RunnableConfig","ensureConfig","dispatchCustomEventWeb"],"sources":["../../../src/callbacks/dispatch/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dispatchCustomEvent as dispatchCustomEventWeb } from \"./web.js\";\nimport { type RunnableConfig, ensureConfig } from \"../../runnables/config.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../../singletons/index.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\n/**\n * Dispatch a custom event.\n *\n * Note: this method is only supported in non-web environments\n * due to usage of async_hooks to infer config.\n *\n * If you are using this method in the browser, please import and use\n * from \"@langchain/core/callbacks/dispatch/web\".\n *\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Optional config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string) => {\n * await dispatchCustomEvent(\"my_custom_event\", { arbitraryField: \"someval\" });\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n const ensuredConfig = ensureConfig(config);\n await dispatchCustomEventWeb(eventName, payload, ensuredConfig);\n}\n"],"mappings":";;;;;;;;;;AAOAA,iDAAmC,yBACjC,IAAIC,qCACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,eAAsBC,sBACpBC,WAEAC,SACAC,QACA;CACA,MAAM,gBAAgBC,4BAAa,OAAO;CAC1C,MAAMC,mDAAuB,WAAW,SAAS,cAAc;AAChE"}
1
+ {"version":3,"file":"index.cjs","names":["AsyncLocalStorageProviderSingleton","AsyncLocalStorage","dispatchCustomEvent","eventName: string","payload: any","config?: RunnableConfig","ensureConfig","dispatchCustomEventWeb"],"sources":["../../../src/callbacks/dispatch/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dispatchCustomEvent as dispatchCustomEventWeb } from \"./web.js\";\nimport { type RunnableConfig, ensureConfig } from \"../../runnables/config.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../../singletons/index.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\n/**\n * Dispatch a custom event.\n *\n * Note: this method is only supported in non-web environments\n * due to usage of async_hooks to infer config.\n *\n * If you are using this method in the browser, please import and use\n * from \"@langchain/core/callbacks/dispatch/web\".\n *\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Optional config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string) => {\n * await dispatchCustomEvent(\"my_custom_event\", { arbitraryField: \"someval\" });\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n const ensuredConfig = ensureConfig(config);\n await dispatchCustomEventWeb(eventName, payload, ensuredConfig);\n}\n"],"mappings":";;;;;;;;AAOAA,iDAAmC,yBACjC,IAAIC,qCACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,eAAsBC,sBACpBC,WAEAC,SACAC,QACA;CACA,MAAM,gBAAgBC,4BAAa,OAAO;CAC1C,MAAMC,mDAAuB,WAAW,SAAS,cAAc;AAChE"}
@@ -1,4 +1,3 @@
1
- import { __export } from "../../_virtual/rolldown_runtime.js";
2
1
  import { AsyncLocalStorageProviderSingleton } from "../../singletons/async_local_storage/index.js";
3
2
  import "../../singletons/index.js";
4
3
  import { ensureConfig } from "../../runnables/config.js";
@@ -6,8 +5,6 @@ import { dispatchCustomEvent } from "./web.js";
6
5
  import { AsyncLocalStorage } from "node:async_hooks";
7
6
 
8
7
  //#region src/callbacks/dispatch/index.ts
9
- var dispatch_exports = {};
10
- __export(dispatch_exports, { dispatchCustomEvent: () => dispatchCustomEvent$1 });
11
8
  AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
12
9
  /**
13
10
  * Dispatch a custom event.
@@ -48,5 +45,5 @@ async function dispatchCustomEvent$1(eventName, payload, config) {
48
45
  }
49
46
 
50
47
  //#endregion
51
- export { dispatchCustomEvent$1 as dispatchCustomEvent, dispatch_exports };
48
+ export { dispatchCustomEvent$1 as dispatchCustomEvent };
52
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["dispatchCustomEvent","eventName: string","payload: any","config?: RunnableConfig","dispatchCustomEventWeb"],"sources":["../../../src/callbacks/dispatch/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dispatchCustomEvent as dispatchCustomEventWeb } from \"./web.js\";\nimport { type RunnableConfig, ensureConfig } from \"../../runnables/config.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../../singletons/index.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\n/**\n * Dispatch a custom event.\n *\n * Note: this method is only supported in non-web environments\n * due to usage of async_hooks to infer config.\n *\n * If you are using this method in the browser, please import and use\n * from \"@langchain/core/callbacks/dispatch/web\".\n *\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Optional config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string) => {\n * await dispatchCustomEvent(\"my_custom_event\", { arbitraryField: \"someval\" });\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n const ensuredConfig = ensureConfig(config);\n await dispatchCustomEventWeb(eventName, payload, ensuredConfig);\n}\n"],"mappings":";;;;;;;;;;AAOA,mCAAmC,yBACjC,IAAI,oBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,eAAsBA,sBACpBC,WAEAC,SACAC,QACA;CACA,MAAM,gBAAgB,aAAa,OAAO;CAC1C,MAAMC,oBAAuB,WAAW,SAAS,cAAc;AAChE"}
1
+ {"version":3,"file":"index.js","names":["dispatchCustomEvent","eventName: string","payload: any","config?: RunnableConfig","dispatchCustomEventWeb"],"sources":["../../../src/callbacks/dispatch/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { dispatchCustomEvent as dispatchCustomEventWeb } from \"./web.js\";\nimport { type RunnableConfig, ensureConfig } from \"../../runnables/config.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../../singletons/index.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\n/**\n * Dispatch a custom event.\n *\n * Note: this method is only supported in non-web environments\n * due to usage of async_hooks to infer config.\n *\n * If you are using this method in the browser, please import and use\n * from \"@langchain/core/callbacks/dispatch/web\".\n *\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Optional config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string) => {\n * await dispatchCustomEvent(\"my_custom_event\", { arbitraryField: \"someval\" });\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n const ensuredConfig = ensureConfig(config);\n await dispatchCustomEventWeb(eventName, payload, ensuredConfig);\n}\n"],"mappings":";;;;;;;AAOA,mCAAmC,yBACjC,IAAI,oBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,eAAsBA,sBACpBC,WAEAC,SACAC,QACA;CACA,MAAM,gBAAgB,aAAa,OAAO;CAC1C,MAAMC,oBAAuB,WAAW,SAAS,cAAc;AAChE"}
@@ -1,9 +1,6 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
1
  const require_config = require('../../runnables/config.cjs');
3
2
 
4
3
  //#region src/callbacks/dispatch/web.ts
5
- var web_exports = {};
6
- require_rolldown_runtime.__export(web_exports, { dispatchCustomEvent: () => dispatchCustomEvent });
7
4
  /**
8
5
  * Dispatch a custom event. Requires an explicit config object.
9
6
  * @param name The name of the custom event.
@@ -53,10 +50,4 @@ async function dispatchCustomEvent(name, payload, config) {
53
50
 
54
51
  //#endregion
55
52
  exports.dispatchCustomEvent = dispatchCustomEvent;
56
- Object.defineProperty(exports, 'web_exports', {
57
- enumerable: true,
58
- get: function () {
59
- return web_exports;
60
- }
61
- });
62
53
  //# sourceMappingURL=web.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.cjs","names":["name: string","payload: any","config?: RunnableConfig","getCallbackManagerForConfig"],"sources":["../../../src/callbacks/dispatch/web.ts"],"sourcesContent":["import {\n type RunnableConfig,\n getCallbackManagerForConfig,\n} from \"../../runnables/config.js\";\n\n/**\n * Dispatch a custom event. Requires an explicit config object.\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string, config?: RunnableConfig) => {\n * await dispatchCustomEvent(\n * \"my_custom_event\",\n * { arbitraryField: \"someval\" },\n * config\n * );\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n if (config === undefined) {\n throw new Error(\n [\n \"Unable to dispatch a custom event without a parent run id.\",\n `\"dispatchCustomEvent\" can only be called from within an existing run (e.g.,`,\n \"inside a tool or a RunnableLambda).\",\n `\\n\\nIf you continue to see this error, please import from \"@langchain/core/callbacks/dispatch/web\"`,\n \"and explicitly pass in a config parameter.\",\n `\\n\\nOr, if you are calling this from a custom tool, ensure you're using the \"tool\" helper constructor as documented here:`,\n \"\\n |\",\n \"\\n └-> https://js.langchain.com/docs/how_to/custom_tools#tool-function\",\n \"\\n\",\n ].join(\" \")\n );\n }\n const callbackManager = await getCallbackManagerForConfig(config);\n const parentRunId = callbackManager?.getParentRunId();\n // We pass parent id as the current run id here intentionally since events dispatch\n // from within things like RunnableLambda\n if (callbackManager !== undefined && parentRunId !== undefined) {\n await callbackManager.handleCustomEvent?.(name, payload, parentRunId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,oBACpBA,MAEAC,SACAC,QACA;AACA,KAAI,WAAW,OACb,OAAM,IAAI,MACR;EACE;EACA,CAAC,2EAA2E,CAAC;EAC7E;EACA,CAAC,kGAAkG,CAAC;EACpG;EACA,CAAC,yHAAyH,CAAC;EAC3H;EACA;EACA;CACD,EAAC,KAAK,IAAI;CAGf,MAAM,kBAAkB,MAAMC,2CAA4B,OAAO;CACjE,MAAM,cAAc,iBAAiB,gBAAgB;AAGrD,KAAI,oBAAoB,UAAa,gBAAgB,QACnD,MAAM,gBAAgB,oBAAoB,MAAM,SAAS,YAAY;AAExE"}
1
+ {"version":3,"file":"web.cjs","names":["name: string","payload: any","config?: RunnableConfig","getCallbackManagerForConfig"],"sources":["../../../src/callbacks/dispatch/web.ts"],"sourcesContent":["import {\n type RunnableConfig,\n getCallbackManagerForConfig,\n} from \"../../runnables/config.js\";\n\n/**\n * Dispatch a custom event. Requires an explicit config object.\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string, config?: RunnableConfig) => {\n * await dispatchCustomEvent(\n * \"my_custom_event\",\n * { arbitraryField: \"someval\" },\n * config\n * );\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n if (config === undefined) {\n throw new Error(\n [\n \"Unable to dispatch a custom event without a parent run id.\",\n `\"dispatchCustomEvent\" can only be called from within an existing run (e.g.,`,\n \"inside a tool or a RunnableLambda).\",\n `\\n\\nIf you continue to see this error, please import from \"@langchain/core/callbacks/dispatch/web\"`,\n \"and explicitly pass in a config parameter.\",\n `\\n\\nOr, if you are calling this from a custom tool, ensure you're using the \"tool\" helper constructor as documented here:`,\n \"\\n |\",\n \"\\n └-> https://js.langchain.com/docs/how_to/custom_tools#tool-function\",\n \"\\n\",\n ].join(\" \")\n );\n }\n const callbackManager = await getCallbackManagerForConfig(config);\n const parentRunId = callbackManager?.getParentRunId();\n // We pass parent id as the current run id here intentionally since events dispatch\n // from within things like RunnableLambda\n if (callbackManager !== undefined && parentRunId !== undefined) {\n await callbackManager.handleCustomEvent?.(name, payload, parentRunId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,oBACpBA,MAEAC,SACAC,QACA;AACA,KAAI,WAAW,OACb,OAAM,IAAI,MACR;EACE;EACA,CAAC,2EAA2E,CAAC;EAC7E;EACA,CAAC,kGAAkG,CAAC;EACpG;EACA,CAAC,yHAAyH,CAAC;EAC3H;EACA;EACA;CACD,EAAC,KAAK,IAAI;CAGf,MAAM,kBAAkB,MAAMC,2CAA4B,OAAO;CACjE,MAAM,cAAc,iBAAiB,gBAAgB;AAGrD,KAAI,oBAAoB,UAAa,gBAAgB,QACnD,MAAM,gBAAgB,oBAAoB,MAAM,SAAS,YAAY;AAExE"}
@@ -1,9 +1,6 @@
1
- import { __export } from "../../_virtual/rolldown_runtime.js";
2
1
  import { getCallbackManagerForConfig } from "../../runnables/config.js";
3
2
 
4
3
  //#region src/callbacks/dispatch/web.ts
5
- var web_exports = {};
6
- __export(web_exports, { dispatchCustomEvent: () => dispatchCustomEvent });
7
4
  /**
8
5
  * Dispatch a custom event. Requires an explicit config object.
9
6
  * @param name The name of the custom event.
@@ -52,5 +49,5 @@ async function dispatchCustomEvent(name, payload, config) {
52
49
  }
53
50
 
54
51
  //#endregion
55
- export { dispatchCustomEvent, web_exports };
52
+ export { dispatchCustomEvent };
56
53
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","names":["name: string","payload: any","config?: RunnableConfig"],"sources":["../../../src/callbacks/dispatch/web.ts"],"sourcesContent":["import {\n type RunnableConfig,\n getCallbackManagerForConfig,\n} from \"../../runnables/config.js\";\n\n/**\n * Dispatch a custom event. Requires an explicit config object.\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string, config?: RunnableConfig) => {\n * await dispatchCustomEvent(\n * \"my_custom_event\",\n * { arbitraryField: \"someval\" },\n * config\n * );\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n if (config === undefined) {\n throw new Error(\n [\n \"Unable to dispatch a custom event without a parent run id.\",\n `\"dispatchCustomEvent\" can only be called from within an existing run (e.g.,`,\n \"inside a tool or a RunnableLambda).\",\n `\\n\\nIf you continue to see this error, please import from \"@langchain/core/callbacks/dispatch/web\"`,\n \"and explicitly pass in a config parameter.\",\n `\\n\\nOr, if you are calling this from a custom tool, ensure you're using the \"tool\" helper constructor as documented here:`,\n \"\\n |\",\n \"\\n └-> https://js.langchain.com/docs/how_to/custom_tools#tool-function\",\n \"\\n\",\n ].join(\" \")\n );\n }\n const callbackManager = await getCallbackManagerForConfig(config);\n const parentRunId = callbackManager?.getParentRunId();\n // We pass parent id as the current run id here intentionally since events dispatch\n // from within things like RunnableLambda\n if (callbackManager !== undefined && parentRunId !== undefined) {\n await callbackManager.handleCustomEvent?.(name, payload, parentRunId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,oBACpBA,MAEAC,SACAC,QACA;AACA,KAAI,WAAW,OACb,OAAM,IAAI,MACR;EACE;EACA,CAAC,2EAA2E,CAAC;EAC7E;EACA,CAAC,kGAAkG,CAAC;EACpG;EACA,CAAC,yHAAyH,CAAC;EAC3H;EACA;EACA;CACD,EAAC,KAAK,IAAI;CAGf,MAAM,kBAAkB,MAAM,4BAA4B,OAAO;CACjE,MAAM,cAAc,iBAAiB,gBAAgB;AAGrD,KAAI,oBAAoB,UAAa,gBAAgB,QACnD,MAAM,gBAAgB,oBAAoB,MAAM,SAAS,YAAY;AAExE"}
1
+ {"version":3,"file":"web.js","names":["name: string","payload: any","config?: RunnableConfig"],"sources":["../../../src/callbacks/dispatch/web.ts"],"sourcesContent":["import {\n type RunnableConfig,\n getCallbackManagerForConfig,\n} from \"../../runnables/config.js\";\n\n/**\n * Dispatch a custom event. Requires an explicit config object.\n * @param name The name of the custom event.\n * @param payload The data for the custom event.\n * Ideally should be JSON serializable to avoid serialization issues downstream, but not enforced.\n * @param config Config object.\n *\n * @example\n * ```typescript\n * import { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\n *\n * const foo = RunnableLambda.from(async (input: string, config?: RunnableConfig) => {\n * await dispatchCustomEvent(\n * \"my_custom_event\",\n * { arbitraryField: \"someval\" },\n * config\n * );\n * return input;\n * });\n *\n * const callbacks = [{\n * handleCustomEvent: (eventName: string, payload: any) => {\n * // Logs \"my_custom_event\" and { arbitraryField: \"someval\" }\n * console.log(eventName, payload);\n * }\n * }];\n *\n * await foo.invoke(\"hi\", { callbacks })\n * ```\n */\nexport async function dispatchCustomEvent(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload: any,\n config?: RunnableConfig\n) {\n if (config === undefined) {\n throw new Error(\n [\n \"Unable to dispatch a custom event without a parent run id.\",\n `\"dispatchCustomEvent\" can only be called from within an existing run (e.g.,`,\n \"inside a tool or a RunnableLambda).\",\n `\\n\\nIf you continue to see this error, please import from \"@langchain/core/callbacks/dispatch/web\"`,\n \"and explicitly pass in a config parameter.\",\n `\\n\\nOr, if you are calling this from a custom tool, ensure you're using the \"tool\" helper constructor as documented here:`,\n \"\\n |\",\n \"\\n └-> https://js.langchain.com/docs/how_to/custom_tools#tool-function\",\n \"\\n\",\n ].join(\" \")\n );\n }\n const callbackManager = await getCallbackManagerForConfig(config);\n const parentRunId = callbackManager?.getParentRunId();\n // We pass parent id as the current run id here intentionally since events dispatch\n // from within things like RunnableLambda\n if (callbackManager !== undefined && parentRunId !== undefined) {\n await callbackManager.handleCustomEvent?.(name, payload, parentRunId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,oBACpBA,MAEAC,SACAC,QACA;AACA,KAAI,WAAW,OACb,OAAM,IAAI,MACR;EACE;EACA,CAAC,2EAA2E,CAAC;EAC7E;EACA,CAAC,kGAAkG,CAAC;EACpG;EACA,CAAC,yHAAyH,CAAC;EAC3H;EACA;EACA;CACD,EAAC,KAAK,IAAI;CAGf,MAAM,kBAAkB,MAAM,4BAA4B,OAAO;CACjE,MAAM,cAAc,iBAAiB,gBAAgB;AAGrD,KAAI,oBAAoB,UAAa,gBAAgB,QACnD,MAAM,gBAAgB,oBAAoB,MAAM,SAAS,YAAY;AAExE"}
package/dist/context.cjs CHANGED
@@ -5,23 +5,10 @@ require('./singletons/index.cjs');
5
5
  const node_async_hooks = require_rolldown_runtime.__toESM(require("node:async_hooks"));
6
6
 
7
7
  //#region src/context.ts
8
- var context_exports = {};
9
- require_rolldown_runtime.__export(context_exports, {
10
- foo: () => foo,
11
- getContextVariable: () => require_context.getContextVariable,
12
- registerConfigureHook: () => require_context.registerConfigureHook,
13
- setContextVariable: () => require_context.setContextVariable
14
- });
15
8
  require_index.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new node_async_hooks.AsyncLocalStorage());
16
9
  const foo = "bar";
17
10
 
18
11
  //#endregion
19
- Object.defineProperty(exports, 'context_exports', {
20
- enumerable: true,
21
- get: function () {
22
- return context_exports;
23
- }
24
- });
25
12
  exports.foo = foo;
26
13
  exports.getContextVariable = require_context.getContextVariable;
27
14
  exports.registerConfigureHook = require_context.registerConfigureHook;
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","names":["AsyncLocalStorageProviderSingleton","AsyncLocalStorage"],"sources":["../src/context.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n/**\n * This file exists as a convenient public entrypoint for functionality\n * related to context variables.\n *\n * Because it automatically initializes AsyncLocalStorage, internal\n * functionality SHOULD NEVER import from this file outside of tests.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { AsyncLocalStorageProviderSingleton } from \"./singletons/index.js\";\nimport {\n getContextVariable,\n setContextVariable,\n type ConfigureHook,\n registerConfigureHook,\n} from \"./singletons/async_local_storage/context.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\nexport {\n getContextVariable,\n setContextVariable,\n registerConfigureHook,\n type ConfigureHook,\n};\n\nexport const foo = \"bar\";\n"],"mappings":";;;;;;;;;;;;;;AAmBAA,iDAAmC,yBACjC,IAAIC,qCACL;AASD,MAAa,MAAM"}
1
+ {"version":3,"file":"context.cjs","names":["AsyncLocalStorageProviderSingleton","AsyncLocalStorage"],"sources":["../src/context.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n/**\n * This file exists as a convenient public entrypoint for functionality\n * related to context variables.\n *\n * Because it automatically initializes AsyncLocalStorage, internal\n * functionality SHOULD NEVER import from this file outside of tests.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { AsyncLocalStorageProviderSingleton } from \"./singletons/index.js\";\nimport {\n getContextVariable,\n setContextVariable,\n type ConfigureHook,\n registerConfigureHook,\n} from \"./singletons/async_local_storage/context.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\nexport {\n getContextVariable,\n setContextVariable,\n registerConfigureHook,\n type ConfigureHook,\n};\n\nexport const foo = \"bar\";\n"],"mappings":";;;;;;;AAmBAA,iDAAmC,yBACjC,IAAIC,qCACL;AASD,MAAa,MAAM"}
package/dist/context.js CHANGED
@@ -1,20 +1,12 @@
1
- import { __export } from "./_virtual/rolldown_runtime.js";
2
1
  import { getContextVariable, registerConfigureHook, setContextVariable } from "./singletons/async_local_storage/context.js";
3
2
  import { AsyncLocalStorageProviderSingleton } from "./singletons/async_local_storage/index.js";
4
3
  import "./singletons/index.js";
5
4
  import { AsyncLocalStorage } from "node:async_hooks";
6
5
 
7
6
  //#region src/context.ts
8
- var context_exports = {};
9
- __export(context_exports, {
10
- foo: () => foo,
11
- getContextVariable: () => getContextVariable,
12
- registerConfigureHook: () => registerConfigureHook,
13
- setContextVariable: () => setContextVariable
14
- });
15
7
  AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
16
8
  const foo = "bar";
17
9
 
18
10
  //#endregion
19
- export { context_exports, foo, getContextVariable, registerConfigureHook, setContextVariable };
11
+ export { foo, getContextVariable, registerConfigureHook, setContextVariable };
20
12
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n/**\n * This file exists as a convenient public entrypoint for functionality\n * related to context variables.\n *\n * Because it automatically initializes AsyncLocalStorage, internal\n * functionality SHOULD NEVER import from this file outside of tests.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { AsyncLocalStorageProviderSingleton } from \"./singletons/index.js\";\nimport {\n getContextVariable,\n setContextVariable,\n type ConfigureHook,\n registerConfigureHook,\n} from \"./singletons/async_local_storage/context.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\nexport {\n getContextVariable,\n setContextVariable,\n registerConfigureHook,\n type ConfigureHook,\n};\n\nexport const foo = \"bar\";\n"],"mappings":";;;;;;;;;;;;;;AAmBA,mCAAmC,yBACjC,IAAI,oBACL;AASD,MAAa,MAAM"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n/**\n * This file exists as a convenient public entrypoint for functionality\n * related to context variables.\n *\n * Because it automatically initializes AsyncLocalStorage, internal\n * functionality SHOULD NEVER import from this file outside of tests.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { AsyncLocalStorageProviderSingleton } from \"./singletons/index.js\";\nimport {\n getContextVariable,\n setContextVariable,\n type ConfigureHook,\n registerConfigureHook,\n} from \"./singletons/async_local_storage/context.js\";\n\nAsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n);\n\nexport {\n getContextVariable,\n setContextVariable,\n registerConfigureHook,\n type ConfigureHook,\n};\n\nexport const foo = \"bar\";\n"],"mappings":";;;;;;AAmBA,mCAAmC,yBACjC,IAAI,oBACL;AASD,MAAa,MAAM"}
@@ -55,6 +55,9 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
55
55
  ];
56
56
  disableStreaming = false;
57
57
  outputVersion;
58
+ get callKeys() {
59
+ return [...super.callKeys, "outputVersion"];
60
+ }
58
61
  constructor(fields) {
59
62
  super(fields);
60
63
  this.outputVersion = require_utils$1.iife(() => {
@@ -99,6 +102,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
99
102
  invocation_params: this?.invocationParams(callOptions),
100
103
  batch_size: 1
101
104
  };
105
+ const outputVersion = callOptions.outputVersion ?? this.outputVersion;
102
106
  const runManagers = await callbackManager_?.handleChatModelStart(this.toJSON(), [_formatForTracing(messages)], runnableConfig.runId, void 0, extra, void 0, void 0, runnableConfig.runName);
103
107
  let generationChunk;
104
108
  let llmOutput;
@@ -112,7 +116,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
112
116
  ...chunk.generationInfo,
113
117
  ...chunk.message.response_metadata
114
118
  };
115
- if (this.outputVersion === "v1") yield require_utils$1.castStandardMessageContent(chunk.message);
119
+ if (outputVersion === "v1") yield require_utils$1.castStandardMessageContent(chunk.message);
116
120
  else yield chunk.message;
117
121
  if (!generationChunk) generationChunk = chunk;
118
122
  else generationChunk = generationChunk.concat(chunk);
@@ -158,6 +162,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
158
162
  };
159
163
  runManagers = await callbackManager_?.handleChatModelStart(this.toJSON(), baseMessages.map(_formatForTracing), handledOptions.runId, void 0, extra, void 0, void 0, handledOptions.runName);
160
164
  }
165
+ const outputVersion = parsedOptions.outputVersion ?? this.outputVersion;
161
166
  const generations = [];
162
167
  const llmOutputs = [];
163
168
  const hasStreamingHandler = !!runManagers?.[0].handlers.find(require_callbacks_base.callbackHandlerPrefersStreaming);
@@ -194,7 +199,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
194
199
  ...parsedOptions,
195
200
  promptIndex: i
196
201
  }, runManagers?.[i]);
197
- if (this.outputVersion === "v1") for (const generation of generateResults.generations) generation.message = require_utils$1.castStandardMessageContent(generation.message);
202
+ if (outputVersion === "v1") for (const generation of generateResults.generations) generation.message = require_utils$1.castStandardMessageContent(generation.message);
198
203
  return generateResults;
199
204
  }));
200
205
  await Promise.all(results.map(async (pResult, i) => {
@@ -260,6 +265,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
260
265
  result,
261
266
  runManager: runManagers?.[index]
262
267
  })).filter(({ result }) => result.status === "fulfilled" && result.value != null || result.status === "rejected");
268
+ const outputVersion = parsedOptions.outputVersion ?? this.outputVersion;
263
269
  const generations = [];
264
270
  await Promise.all(cachedResults.map(async ({ result: promiseResult, runManager }, i) => {
265
271
  if (promiseResult.status === "fulfilled") {
@@ -271,7 +277,7 @@ var BaseChatModel = class BaseChatModel extends require_language_models_base.Bas
271
277
  output_tokens: 0,
272
278
  total_tokens: 0
273
279
  };
274
- if (this.outputVersion === "v1") result$1.message = require_utils$1.castStandardMessageContent(result$1.message);
280
+ if (outputVersion === "v1") result$1.message = require_utils$1.castStandardMessageContent(result$1.message);
275
281
  }
276
282
  result$1.generationInfo = {
277
283
  ...result$1.generationInfo,