langchain 1.1.5 → 1.1.6-dev-1765431816670
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/README.md +1 -1
- package/dist/agents/ReactAgent.d.cts +0 -2
- package/dist/agents/ReactAgent.d.cts.map +1 -0
- package/dist/agents/ReactAgent.d.ts +0 -2
- package/dist/agents/ReactAgent.d.ts.map +1 -0
- package/dist/agents/constants.d.cts.map +1 -0
- package/dist/agents/constants.d.ts.map +1 -0
- package/dist/agents/errors.d.cts.map +1 -0
- package/dist/agents/errors.d.ts.map +1 -0
- package/dist/agents/index.d.cts +0 -11
- package/dist/agents/index.d.cts.map +1 -0
- package/dist/agents/index.d.ts +0 -11
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/middleware/contextEditing.d.cts.map +1 -0
- package/dist/agents/middleware/contextEditing.d.ts.map +1 -0
- package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -0
- package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -0
- package/dist/agents/middleware/hitl.d.cts.map +1 -0
- package/dist/agents/middleware/hitl.d.ts.map +1 -0
- package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -0
- package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -0
- package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -0
- package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -0
- package/dist/agents/middleware/modelFallback.d.cts.map +1 -0
- package/dist/agents/middleware/modelFallback.d.ts.map +1 -0
- package/dist/agents/middleware/modelRetry.d.cts.map +1 -0
- package/dist/agents/middleware/modelRetry.d.ts.map +1 -0
- package/dist/agents/middleware/pii.d.cts.map +1 -0
- package/dist/agents/middleware/pii.d.ts.map +1 -0
- package/dist/agents/middleware/piiRedaction.d.cts.map +1 -0
- package/dist/agents/middleware/piiRedaction.d.ts.map +1 -0
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts.map +1 -0
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts.map +1 -0
- package/dist/agents/middleware/provider/openai/moderation.d.cts.map +1 -0
- package/dist/agents/middleware/provider/openai/moderation.d.ts.map +1 -0
- package/dist/agents/middleware/summarization.d.cts.map +1 -0
- package/dist/agents/middleware/summarization.d.ts.map +1 -0
- package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -0
- package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -0
- package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -0
- package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -0
- package/dist/agents/middleware/toolEmulator.d.cts.map +1 -0
- package/dist/agents/middleware/toolEmulator.d.ts.map +1 -0
- package/dist/agents/middleware/toolRetry.d.cts.map +1 -0
- package/dist/agents/middleware/toolRetry.d.ts.map +1 -0
- package/dist/agents/middleware/types.d.cts.map +1 -0
- package/dist/agents/middleware/types.d.ts.map +1 -0
- package/dist/agents/middleware/utils.d.cts.map +1 -0
- package/dist/agents/middleware/utils.d.ts.map +1 -0
- package/dist/agents/middleware.d.cts.map +1 -0
- package/dist/agents/middleware.d.ts.map +1 -0
- package/dist/agents/nodes/types.d.cts.map +1 -0
- package/dist/agents/nodes/types.d.ts.map +1 -0
- package/dist/agents/responses.d.cts +0 -2
- package/dist/agents/responses.d.cts.map +1 -0
- package/dist/agents/responses.d.ts +0 -2
- package/dist/agents/responses.d.ts.map +1 -0
- package/dist/agents/runtime.d.cts +1 -3
- package/dist/agents/runtime.d.cts.map +1 -0
- package/dist/agents/runtime.d.ts +1 -3
- package/dist/agents/runtime.d.ts.map +1 -0
- package/dist/agents/tests/utils.d.cts +0 -4
- package/dist/agents/tests/utils.d.cts.map +1 -0
- package/dist/agents/tests/utils.d.ts +0 -4
- package/dist/agents/tests/utils.d.ts.map +1 -0
- package/dist/agents/types.d.cts.map +1 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/chat_models/universal.d.cts +4 -21
- package/dist/chat_models/universal.d.cts.map +1 -0
- package/dist/chat_models/universal.d.ts +4 -21
- package/dist/chat_models/universal.d.ts.map +1 -0
- package/dist/hub/base.d.cts.map +1 -0
- package/dist/hub/base.d.ts.map +1 -0
- package/dist/hub/index.d.cts +0 -1
- package/dist/hub/index.d.cts.map +1 -0
- package/dist/hub/index.d.ts +0 -1
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/node.cjs +22 -2
- package/dist/hub/node.cjs.map +1 -1
- package/dist/hub/node.d.cts.map +1 -0
- package/dist/hub/node.d.ts.map +1 -0
- package/dist/hub/node.js +22 -2
- package/dist/hub/node.js.map +1 -1
- package/dist/load/import_type.d.cts +0 -1
- package/dist/load/import_type.d.cts.map +1 -0
- package/dist/load/import_type.d.ts +0 -1
- package/dist/load/import_type.d.ts.map +1 -0
- package/dist/load/index.d.cts +1 -7
- package/dist/load/index.d.cts.map +1 -0
- package/dist/load/index.d.ts +1 -7
- package/dist/load/index.d.ts.map +1 -0
- package/dist/storage/encoder_backed.d.cts +0 -1
- package/dist/storage/encoder_backed.d.cts.map +1 -0
- package/dist/storage/encoder_backed.d.ts +0 -1
- package/dist/storage/encoder_backed.d.ts.map +1 -0
- package/dist/storage/file_system.d.cts.map +1 -0
- package/dist/storage/file_system.d.ts.map +1 -0
- package/package.json +8 -7
- package/chat_models/universal.cjs +0 -1
- package/chat_models/universal.d.cts +0 -1
- package/chat_models/universal.d.ts +0 -1
- package/chat_models/universal.js +0 -1
- package/hub/node.cjs +0 -1
- package/hub/node.d.cts +0 -1
- package/hub/node.d.ts +0 -1
- package/hub/node.js +0 -1
- package/hub.cjs +0 -1
- package/hub.d.cts +0 -1
- package/hub.d.ts +0 -1
- package/hub.js +0 -1
- package/load/serializable.cjs +0 -1
- package/load/serializable.d.cts +0 -1
- package/load/serializable.d.ts +0 -1
- package/load/serializable.js +0 -1
- package/load.cjs +0 -1
- package/load.d.cts +0 -1
- package/load.d.ts +0 -1
- package/load.js +0 -1
- package/storage/encoder_backed.cjs +0 -1
- package/storage/encoder_backed.d.cts +0 -1
- package/storage/encoder_backed.d.ts +0 -1
- package/storage/encoder_backed.js +0 -1
- package/storage/file_system.cjs +0 -1
- package/storage/file_system.d.cts +0 -1
- package/storage/file_system.d.ts +0 -1
- package/storage/file_system.js +0 -1
- package/storage/in_memory.cjs +0 -1
- package/storage/in_memory.d.cts +0 -1
- package/storage/in_memory.d.ts +0 -1
- package/storage/in_memory.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":["CallbackManagerForLLMRun","BaseChatModel","BaseChatModelParams","BindToolsInput","ToolChoice","StructuredTool","BaseMessage","AIMessage","HumanMessage","BaseMessageFields","AIMessageFields","ToolMessage","ToolMessageFields","ChatResult","Runnable","RunnableConfig","RunnableLambda","RunnableBinding","MemorySaver","Checkpoint","CheckpointMetadata","BaseCheckpointSaver","LanguageModelLike","z","_AnyIdAIMessage","_AnyIdHumanMessage","_AnyIdToolMessage","FakeConfigurableModel","Record","Promise","FakeToolCallingChatModel","RunOutput","MemorySaverAssertImmutable","Uint8Array","ToolCall","FakeToolCallingModelFields","createCheckpointer","FakeToolCallingModel","toolCalls","toolStyle","index","structuredResponse","indexRef","SearchAPI","ZodString","ZodTypeAny","ZodObject","infer"],"sources":["../../../src/agents/tests/utils.d.ts"],"sourcesContent":["import { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { BaseChatModel, BaseChatModelParams, BindToolsInput, ToolChoice } from \"@langchain/core/language_models/chat_models\";\nimport { StructuredTool } from \"@langchain/core/tools\";\nimport { BaseMessage, AIMessage, HumanMessage, BaseMessageFields, AIMessageFields, ToolMessage, ToolMessageFields } from \"@langchain/core/messages\";\nimport { ChatResult } from \"@langchain/core/outputs\";\nimport { Runnable, RunnableConfig, RunnableLambda, RunnableBinding } from \"@langchain/core/runnables\";\nimport { MemorySaver, Checkpoint, CheckpointMetadata, type BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { z } from \"zod/v3\";\nexport declare class _AnyIdAIMessage extends AIMessage {\n get lc_id(): string[];\n constructor(fields: AIMessageFields | string);\n}\nexport declare class _AnyIdHumanMessage extends HumanMessage {\n get lc_id(): string[];\n constructor(fields: BaseMessageFields | string);\n}\nexport declare class _AnyIdToolMessage extends ToolMessage {\n get lc_id(): string[];\n constructor(fields: ToolMessageFields);\n}\nexport declare class FakeConfigurableModel extends BaseChatModel {\n _queuedMethodOperations: Record<string, any>;\n _chatModel: LanguageModelLike;\n constructor(fields: {\n model: LanguageModelLike;\n } & BaseChatModelParams);\n _llmType(): string;\n _generate(_messages: BaseMessage[], _options: this[\"ParsedCallOptions\"], _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n _model(): Promise<LanguageModelLike>;\n bindTools(tools: BindToolsInput[]): FakeConfigurableModel;\n}\nexport declare class FakeToolCallingChatModel extends BaseChatModel {\n sleep?: number;\n responses?: BaseMessage[];\n thrownErrorString?: string;\n idx: number;\n toolStyle: \"openai\" | \"anthropic\" | \"bedrock\" | \"google\";\n structuredResponse?: Record<string, unknown>;\n structuredOutputMessages: BaseMessage[][];\n constructor(fields: {\n sleep?: number;\n responses?: BaseMessage[];\n thrownErrorString?: string;\n toolStyle?: \"openai\" | \"anthropic\" | \"bedrock\" | \"google\";\n structuredResponse?: Record<string, unknown>;\n } & BaseChatModelParams);\n _llmType(): string;\n _generate(messages: BaseMessage[], _options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n bindTools(tools: BindToolsInput[]): Runnable<any>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_: unknown): Runnable<any>;\n}\nexport declare class MemorySaverAssertImmutable extends MemorySaver {\n storageForCopies: Record<string, Record<string, Uint8Array>>;\n constructor();\n put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise<RunnableConfig>;\n}\ninterface ToolCall {\n name: string;\n args: Record<string, any>;\n id: string;\n type?: \"tool_call\";\n}\ninterface FakeToolCallingModelFields {\n toolCalls?: ToolCall[][];\n toolStyle?: \"openai\" | \"anthropic\";\n index?: number;\n structuredResponse?: any;\n}\nexport declare function createCheckpointer(): BaseCheckpointSaver;\n/**\n * Fake chat model for testing tool calling functionality\n */\nexport declare class FakeToolCallingModel extends BaseChatModel {\n toolCalls: ToolCall[][];\n toolStyle: \"openai\" | \"anthropic\";\n private indexRef;\n structuredResponse?: any;\n private tools;\n constructor({ toolCalls, toolStyle, index, structuredResponse, indexRef, ...rest }?: FakeToolCallingModelFields & {\n indexRef?: {\n current: number;\n };\n });\n get index(): number;\n set index(value: number);\n _llmType(): string;\n _combineLLMOutput(): never[];\n bindTools(tools: StructuredTool[]): FakeToolCallingModel | RunnableBinding<any, any, any & {\n tool_choice?: ToolChoice | undefined;\n }>;\n withStructuredOutput(_schema: any): RunnableLambda<unknown, any, RunnableConfig<Record<string, any>>>;\n _generate(messages: BaseMessage[], _options?: this[\"ParsedCallOptions\"], _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n}\nexport declare class SearchAPI extends StructuredTool {\n name: string;\n description: string;\n schema: z.ZodObject<{\n query: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n query: string;\n }, {\n query: string;\n }>;\n _call(input: z.infer<typeof this.schema>): Promise<string>;\n}\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;;;UAyDUkC,UAAAA;;QAEAN;;;;UAIAO,0BAAAA;cACMD;;;;;;;;cASKG,oBAAAA,SAA6BpC,aAAAA;aACnCiC;;;;;;;;;;;;MAK0EC;;;;;;;;;mBASpE9B,mBAAmBgC,uBAAuBpB;kBACzCb;;sCAEkBY,6BAA6BD,eAAea;sBAC5DtB,mEAAmEN,2BAA2B6B,QAAQhB"}
|
|
@@ -22,15 +22,12 @@ interface FakeToolCallingModelFields {
|
|
|
22
22
|
index?: number;
|
|
23
23
|
structuredResponse?: any;
|
|
24
24
|
}
|
|
25
|
-
// Helper function to create checkpointer
|
|
26
|
-
|
|
27
25
|
/**
|
|
28
26
|
* Fake chat model for testing tool calling functionality
|
|
29
27
|
*/
|
|
30
28
|
declare class FakeToolCallingModel extends BaseChatModel {
|
|
31
29
|
toolCalls: ToolCall$1[][];
|
|
32
30
|
toolStyle: "openai" | "anthropic";
|
|
33
|
-
// Use a shared reference object so the index persists across bindTools calls
|
|
34
31
|
private indexRef;
|
|
35
32
|
structuredResponse?: any;
|
|
36
33
|
private tools;
|
|
@@ -46,7 +43,6 @@ declare class FakeToolCallingModel extends BaseChatModel {
|
|
|
46
43
|
current: number;
|
|
47
44
|
};
|
|
48
45
|
});
|
|
49
|
-
// Getter/setter for backwards compatibility
|
|
50
46
|
get index(): number;
|
|
51
47
|
set index(value: number);
|
|
52
48
|
_llmType(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":["CallbackManagerForLLMRun","BaseChatModel","BaseChatModelParams","BindToolsInput","ToolChoice","StructuredTool","BaseMessage","AIMessage","HumanMessage","BaseMessageFields","AIMessageFields","ToolMessage","ToolMessageFields","ChatResult","Runnable","RunnableConfig","RunnableLambda","RunnableBinding","MemorySaver","Checkpoint","CheckpointMetadata","BaseCheckpointSaver","LanguageModelLike","z","_AnyIdAIMessage","_AnyIdHumanMessage","_AnyIdToolMessage","FakeConfigurableModel","Record","Promise","FakeToolCallingChatModel","RunOutput","MemorySaverAssertImmutable","Uint8Array","ToolCall","FakeToolCallingModelFields","createCheckpointer","FakeToolCallingModel","toolCalls","toolStyle","index","structuredResponse","indexRef","SearchAPI","ZodString","ZodTypeAny","ZodObject","infer"],"sources":["../../../src/agents/tests/utils.d.ts"],"sourcesContent":["import { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { BaseChatModel, BaseChatModelParams, BindToolsInput, ToolChoice } from \"@langchain/core/language_models/chat_models\";\nimport { StructuredTool } from \"@langchain/core/tools\";\nimport { BaseMessage, AIMessage, HumanMessage, BaseMessageFields, AIMessageFields, ToolMessage, ToolMessageFields } from \"@langchain/core/messages\";\nimport { ChatResult } from \"@langchain/core/outputs\";\nimport { Runnable, RunnableConfig, RunnableLambda, RunnableBinding } from \"@langchain/core/runnables\";\nimport { MemorySaver, Checkpoint, CheckpointMetadata, type BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { z } from \"zod/v3\";\nexport declare class _AnyIdAIMessage extends AIMessage {\n get lc_id(): string[];\n constructor(fields: AIMessageFields | string);\n}\nexport declare class _AnyIdHumanMessage extends HumanMessage {\n get lc_id(): string[];\n constructor(fields: BaseMessageFields | string);\n}\nexport declare class _AnyIdToolMessage extends ToolMessage {\n get lc_id(): string[];\n constructor(fields: ToolMessageFields);\n}\nexport declare class FakeConfigurableModel extends BaseChatModel {\n _queuedMethodOperations: Record<string, any>;\n _chatModel: LanguageModelLike;\n constructor(fields: {\n model: LanguageModelLike;\n } & BaseChatModelParams);\n _llmType(): string;\n _generate(_messages: BaseMessage[], _options: this[\"ParsedCallOptions\"], _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n _model(): Promise<LanguageModelLike>;\n bindTools(tools: BindToolsInput[]): FakeConfigurableModel;\n}\nexport declare class FakeToolCallingChatModel extends BaseChatModel {\n sleep?: number;\n responses?: BaseMessage[];\n thrownErrorString?: string;\n idx: number;\n toolStyle: \"openai\" | \"anthropic\" | \"bedrock\" | \"google\";\n structuredResponse?: Record<string, unknown>;\n structuredOutputMessages: BaseMessage[][];\n constructor(fields: {\n sleep?: number;\n responses?: BaseMessage[];\n thrownErrorString?: string;\n toolStyle?: \"openai\" | \"anthropic\" | \"bedrock\" | \"google\";\n structuredResponse?: Record<string, unknown>;\n } & BaseChatModelParams);\n _llmType(): string;\n _generate(messages: BaseMessage[], _options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n bindTools(tools: BindToolsInput[]): Runnable<any>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_: unknown): Runnable<any>;\n}\nexport declare class MemorySaverAssertImmutable extends MemorySaver {\n storageForCopies: Record<string, Record<string, Uint8Array>>;\n constructor();\n put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise<RunnableConfig>;\n}\ninterface ToolCall {\n name: string;\n args: Record<string, any>;\n id: string;\n type?: \"tool_call\";\n}\ninterface FakeToolCallingModelFields {\n toolCalls?: ToolCall[][];\n toolStyle?: \"openai\" | \"anthropic\";\n index?: number;\n structuredResponse?: any;\n}\nexport declare function createCheckpointer(): BaseCheckpointSaver;\n/**\n * Fake chat model for testing tool calling functionality\n */\nexport declare class FakeToolCallingModel extends BaseChatModel {\n toolCalls: ToolCall[][];\n toolStyle: \"openai\" | \"anthropic\";\n private indexRef;\n structuredResponse?: any;\n private tools;\n constructor({ toolCalls, toolStyle, index, structuredResponse, indexRef, ...rest }?: FakeToolCallingModelFields & {\n indexRef?: {\n current: number;\n };\n });\n get index(): number;\n set index(value: number);\n _llmType(): string;\n _combineLLMOutput(): never[];\n bindTools(tools: StructuredTool[]): FakeToolCallingModel | RunnableBinding<any, any, any & {\n tool_choice?: ToolChoice | undefined;\n }>;\n withStructuredOutput(_schema: any): RunnableLambda<unknown, any, RunnableConfig<Record<string, any>>>;\n _generate(messages: BaseMessage[], _options?: this[\"ParsedCallOptions\"], _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n}\nexport declare class SearchAPI extends StructuredTool {\n name: string;\n description: string;\n schema: z.ZodObject<{\n query: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n query: string;\n }, {\n query: string;\n }>;\n _call(input: z.infer<typeof this.schema>): Promise<string>;\n}\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;;;UAyDUkC,UAAAA;;QAEAN;;;;UAIAO,0BAAAA;cACMD;;;;;;;;cASKG,oBAAAA,SAA6BpC,aAAAA;aACnCiC;;;;;;;;;;;;MAK0EC;;;;;;;;;mBASpE9B,mBAAmBgC,uBAAuBpB;kBACzCb;;sCAEkBY,6BAA6BD,eAAea;sBAC5DtB,mEAAmEN,2BAA2B6B,QAAQhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":["InteropZodObject","InteropZodType","START","END","StateGraph","LanguageModelLike","BaseMessage","SystemMessage","BaseCheckpointSaver","BaseStore","Messages","ClientTool","ServerTool","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","JsonSchemaFormat","ResponseFormatUndefined","AgentMiddleware","AnyAnnotationRoot","InferSchemaInput","JumpToTarget","N","Interrupt","TValue","BuiltInState","UserInput","TStateSchema","ToolCall","Record","ToolResult","JumpTo","ExecutedToolCall","CreateAgentParams","StructuredResponseType","StateSchema","ContextSchema","ResponseFormatType","AbortSignal","ExtractZodArrayTypes","T","Rest","A","WithStateGraphNodes","K","Graph","SD","S","U","I","O","C"],"sources":["../../src/agents/types.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { START, END, StateGraph } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage, SystemMessage } from \"@langchain/core/messages\";\nimport type { BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Messages } from \"@langchain/langgraph/\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, JsonSchemaFormat, ResponseFormatUndefined } from \"./responses.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot, InferSchemaInput } from \"./middleware/types.js\";\nimport type { JumpToTarget } from \"./constants.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\n/**\n * Represents information about an interrupt.\n */\nexport interface Interrupt<TValue = unknown> {\n /**\n * The ID of the interrupt.\n */\n id: string;\n /**\n * The requests for human input.\n */\n value: TValue;\n}\nexport interface BuiltInState {\n messages: BaseMessage[];\n __interrupt__?: Interrupt[];\n /**\n * Optional property to control routing after afterModel middleware execution.\n * When set by middleware, the agent will jump to the specified node instead of\n * following normal routing logic. The property is automatically cleared after use.\n *\n * - \"model_request\": Jump back to the model for another LLM call\n * - \"tools\": Jump to tool execution (requires tools to be available)\n */\n jumpTo?: JumpToTarget;\n}\n/**\n * Base input type for `.invoke` and `.stream` methods.\n */\nexport type UserInput<TStateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined> = InferSchemaInput<TStateSchema> & {\n messages: Messages;\n};\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n /**\n * The result of the tool call.\n */\n result?: unknown;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * jump targets (internal)\n */\nexport type JumpTo = \"model_request\" | \"tools\" | typeof END;\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, StateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /**\n * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model\n * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * const agent = createAgent({\n * model: new ChatOpenAI({ model: \"gpt-4o\" }),\n * // ...\n * });\n * ```\n */\n model: string | LanguageModelLike;\n /**\n * A list of tools or a ToolNode.\n *\n * @example\n * ```ts\n * import { tool } from \"langchain\";\n *\n * const weatherTool = tool(() => \"Sunny!\", {\n * name: \"get_weather\",\n * description: \"Get the weather for a location\",\n * schema: z.object({\n * location: z.string().describe(\"The location to get weather for\"),\n * }),\n * });\n *\n * const agent = createAgent({\n * tools: [weatherTool],\n * // ...\n * });\n * ```\n */\n tools?: (ServerTool | ClientTool)[];\n /**\n * An optional system message for the model.\n *\n * **Use a `string`** for simple, static system prompts. This is the most common use case\n * and works well with template literals for dynamic content. When a string is provided,\n * it's converted to a single text block internally.\n *\n * **Use a `SystemMessage`** when you need advanced features that require structured content:\n * - **Anthropic cache control**: Use `SystemMessage` with array content to enable per-block\n * cache control settings (e.g., `cache_control: { type: \"ephemeral\" }`). This allows you\n * to have different cache settings for different parts of your system prompt.\n * - **Multiple content blocks**: When you need multiple text blocks with different metadata\n * or formatting requirements.\n * - **Integration with existing code**: When working with code that already produces\n * `SystemMessage` instances.\n *\n * @example Using a string (recommended for most cases)\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: \"You are a helpful assistant.\",\n * // ...\n * });\n * ```\n *\n * @example Using a string with template literals\n * ```ts\n * const userRole = \"premium\";\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: `You are a helpful assistant for ${userRole} users.`,\n * // ...\n * });\n * ```\n *\n * @example Using SystemMessage with cache control (Anthropic)\n * ```ts\n * import { SystemMessage } from \"@langchain/core/messages\";\n *\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: new SystemMessage({\n * content: [\n * {\n * type: \"text\",\n * text: \"You are a helpful assistant.\",\n * },\n * {\n * type: \"text\",\n * text: \"Today's date is 2024-06-01.\",\n * cache_control: { type: \"ephemeral\" },\n * },\n * ],\n * }),\n * // ...\n * });\n * ```\n *\n * @example Using SystemMessage (simple)\n * ```ts\n * import { SystemMessage } from \"@langchain/core/messages\";\n *\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: new SystemMessage(\"You are a helpful assistant.\"),\n * // ...\n * });\n * ```\n */\n systemPrompt?: string | SystemMessage;\n /**\n * An optional schema for the agent state. It allows you to define custom state properties that persist\n * across agent invocations and can be accessed in hooks, middleware, and throughout the agent's execution.\n * The state is persisted when using a checkpointer and can be updated by middleware or during execution.\n *\n * As opposed to the context (defined in `contextSchema`), the state is persisted between agent invocations\n * when using a checkpointer, making it suitable for maintaining conversation history, user preferences,\n * or any other data that should persist across multiple interactions.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { createAgent } from \"@langchain/langgraph\";\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getWeather],\n * stateSchema: z.object({\n * userPreferences: z.object({\n * temperatureUnit: z.enum([\"celsius\", \"fahrenheit\"]).default(\"celsius\"),\n * location: z.string().optional(),\n * }).optional(),\n * conversationCount: z.number().default(0),\n * }),\n * prompt: (state, config) => {\n * const unit = state.userPreferences?.temperatureUnit || \"celsius\";\n * return [\n * new SystemMessage(`You are a helpful assistant. Use ${unit} for temperature.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new HumanMessage(\"What's the weather like?\"),\n * ],\n * userPreferences: {\n * temperatureUnit: \"fahrenheit\",\n * location: \"New York\",\n * },\n * conversationCount: 1,\n * });\n * ```\n */\n stateSchema?: StateSchema;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /**\n * An optional checkpoint saver to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/persistence | Checkpointing}\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n /**\n * An optional store to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}\n */\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n *\n * @see {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Type helper to extract union type from an array of Zod schemas\n */\nexport type ExtractZodArrayTypes<T extends readonly InteropZodType<any>[]> = T extends readonly [InteropZodType<infer A>, ...infer Rest] ? Rest extends readonly InteropZodType<any>[] ? A | ExtractZodArrayTypes<Rest> : A : never;\nexport type WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<infer SD, infer S, infer U, infer N, infer I, infer O, infer C> ? StateG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KAUEI,iDAAiDJ,sBAAsBA,yCAAyCV,oBAAoBpB,gEAAgEoB,oBAAoBpB,mBAAmBoB,wCAAwCnB,eAAekC,0BAA0BlC,4BAA4BgB,mBAAmBA,qBAAqBJ,iBAAiBE,kBAAkBoB,0BAA0BrB,aAAaqB,0BAA0BnB,iBAAiBmB,0BAA0BjB;;;;;;;;;;;;;;;;;;;;;;;;kBAwBvgBb;;;;;;;;;;;;;;;;;;;;;;WAsBPO,aAAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsEEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA6CV6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkCEC;;;;;iBAKD7B;;;;;UAKPC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDS6B;;;;;;;wBAOKnB;;;;;;;;;;;;;;;;;;;;WAoBboB;;;;;;;;;;;;;;;;;KAiBDC,wCAAwCvC,yBAAyBwC,oBAAoBxC,0CAA0CyC,sBAAsBzC,wBAAwB0C,IAAIH,qBAAqBE,QAAQC;KAC9MC,+CAA+CE,cAAc1C,6EAA6EA,WAAW2C,IAAIC,GAAGC,GAAG1B,IAAIsB,GAAGK,GAAGC,GAAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["InteropZodObject","InteropZodType","START","END","StateGraph","LanguageModelLike","BaseMessage","SystemMessage","BaseCheckpointSaver","BaseStore","Messages","ClientTool","ServerTool","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","JsonSchemaFormat","ResponseFormatUndefined","AgentMiddleware","AnyAnnotationRoot","InferSchemaInput","JumpToTarget","N","Interrupt","TValue","BuiltInState","UserInput","TStateSchema","ToolCall","Record","ToolResult","JumpTo","ExecutedToolCall","CreateAgentParams","StructuredResponseType","StateSchema","ContextSchema","ResponseFormatType","AbortSignal","ExtractZodArrayTypes","T","Rest","A","WithStateGraphNodes","K","Graph","SD","S","U","I","O","C"],"sources":["../../src/agents/types.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { START, END, StateGraph } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage, SystemMessage } from \"@langchain/core/messages\";\nimport type { BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Messages } from \"@langchain/langgraph/\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, JsonSchemaFormat, ResponseFormatUndefined } from \"./responses.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot, InferSchemaInput } from \"./middleware/types.js\";\nimport type { JumpToTarget } from \"./constants.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\n/**\n * Represents information about an interrupt.\n */\nexport interface Interrupt<TValue = unknown> {\n /**\n * The ID of the interrupt.\n */\n id: string;\n /**\n * The requests for human input.\n */\n value: TValue;\n}\nexport interface BuiltInState {\n messages: BaseMessage[];\n __interrupt__?: Interrupt[];\n /**\n * Optional property to control routing after afterModel middleware execution.\n * When set by middleware, the agent will jump to the specified node instead of\n * following normal routing logic. The property is automatically cleared after use.\n *\n * - \"model_request\": Jump back to the model for another LLM call\n * - \"tools\": Jump to tool execution (requires tools to be available)\n */\n jumpTo?: JumpToTarget;\n}\n/**\n * Base input type for `.invoke` and `.stream` methods.\n */\nexport type UserInput<TStateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined> = InferSchemaInput<TStateSchema> & {\n messages: Messages;\n};\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n /**\n * The result of the tool call.\n */\n result?: unknown;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * jump targets (internal)\n */\nexport type JumpTo = \"model_request\" | \"tools\" | typeof END;\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, StateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /**\n * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model\n * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * const agent = createAgent({\n * model: new ChatOpenAI({ model: \"gpt-4o\" }),\n * // ...\n * });\n * ```\n */\n model: string | LanguageModelLike;\n /**\n * A list of tools or a ToolNode.\n *\n * @example\n * ```ts\n * import { tool } from \"langchain\";\n *\n * const weatherTool = tool(() => \"Sunny!\", {\n * name: \"get_weather\",\n * description: \"Get the weather for a location\",\n * schema: z.object({\n * location: z.string().describe(\"The location to get weather for\"),\n * }),\n * });\n *\n * const agent = createAgent({\n * tools: [weatherTool],\n * // ...\n * });\n * ```\n */\n tools?: (ServerTool | ClientTool)[];\n /**\n * An optional system message for the model.\n *\n * **Use a `string`** for simple, static system prompts. This is the most common use case\n * and works well with template literals for dynamic content. When a string is provided,\n * it's converted to a single text block internally.\n *\n * **Use a `SystemMessage`** when you need advanced features that require structured content:\n * - **Anthropic cache control**: Use `SystemMessage` with array content to enable per-block\n * cache control settings (e.g., `cache_control: { type: \"ephemeral\" }`). This allows you\n * to have different cache settings for different parts of your system prompt.\n * - **Multiple content blocks**: When you need multiple text blocks with different metadata\n * or formatting requirements.\n * - **Integration with existing code**: When working with code that already produces\n * `SystemMessage` instances.\n *\n * @example Using a string (recommended for most cases)\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: \"You are a helpful assistant.\",\n * // ...\n * });\n * ```\n *\n * @example Using a string with template literals\n * ```ts\n * const userRole = \"premium\";\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: `You are a helpful assistant for ${userRole} users.`,\n * // ...\n * });\n * ```\n *\n * @example Using SystemMessage with cache control (Anthropic)\n * ```ts\n * import { SystemMessage } from \"@langchain/core/messages\";\n *\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: new SystemMessage({\n * content: [\n * {\n * type: \"text\",\n * text: \"You are a helpful assistant.\",\n * },\n * {\n * type: \"text\",\n * text: \"Today's date is 2024-06-01.\",\n * cache_control: { type: \"ephemeral\" },\n * },\n * ],\n * }),\n * // ...\n * });\n * ```\n *\n * @example Using SystemMessage (simple)\n * ```ts\n * import { SystemMessage } from \"@langchain/core/messages\";\n *\n * const agent = createAgent({\n * model: \"anthropic:claude-3-5-sonnet\",\n * systemPrompt: new SystemMessage(\"You are a helpful assistant.\"),\n * // ...\n * });\n * ```\n */\n systemPrompt?: string | SystemMessage;\n /**\n * An optional schema for the agent state. It allows you to define custom state properties that persist\n * across agent invocations and can be accessed in hooks, middleware, and throughout the agent's execution.\n * The state is persisted when using a checkpointer and can be updated by middleware or during execution.\n *\n * As opposed to the context (defined in `contextSchema`), the state is persisted between agent invocations\n * when using a checkpointer, making it suitable for maintaining conversation history, user preferences,\n * or any other data that should persist across multiple interactions.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { createAgent } from \"@langchain/langgraph\";\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getWeather],\n * stateSchema: z.object({\n * userPreferences: z.object({\n * temperatureUnit: z.enum([\"celsius\", \"fahrenheit\"]).default(\"celsius\"),\n * location: z.string().optional(),\n * }).optional(),\n * conversationCount: z.number().default(0),\n * }),\n * prompt: (state, config) => {\n * const unit = state.userPreferences?.temperatureUnit || \"celsius\";\n * return [\n * new SystemMessage(`You are a helpful assistant. Use ${unit} for temperature.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new HumanMessage(\"What's the weather like?\"),\n * ],\n * userPreferences: {\n * temperatureUnit: \"fahrenheit\",\n * location: \"New York\",\n * },\n * conversationCount: 1,\n * });\n * ```\n */\n stateSchema?: StateSchema;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /**\n * An optional checkpoint saver to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/persistence | Checkpointing}\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n /**\n * An optional store to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}\n */\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n *\n * @see {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Type helper to extract union type from an array of Zod schemas\n */\nexport type ExtractZodArrayTypes<T extends readonly InteropZodType<any>[]> = T extends readonly [InteropZodType<infer A>, ...infer Rest] ? Rest extends readonly InteropZodType<any>[] ? A | ExtractZodArrayTypes<Rest> : A : never;\nexport type WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<infer SD, infer S, infer U, infer N, infer I, infer O, infer C> ? StateGraph<SD, S, U, N | K, I, O, C> : never;\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;;;;;;KAUYuB,CAAAA,UAAWrB;;AAAvB;AAIA;AAUiBwB,UAVAF,SAUY,CAAA,SAAA,OAAA,CAAA,CAAA;EACflB;;;EAUW,EAAA,EAAA,MAAA;EAKbqB;;;EAAgHC,KAAAA,EAlBjHH,MAkBiHG;;AAC9GlB,UAjBGgB,YAAAA,CAiBHhB;EAAQ,QAAA,EAhBRJ,WAgBQ,EAAA;EAKLuB,aAAQ,CAAA,EApBLL,SAoBK,EAYfM;EAaOC;AAiBjB;AAIA;AAkBA;;;;;EAAgNX,MAAAA,CAAAA,EA3EnME,YA2EmMF;;;;;AAAwHnB,KAtE5T0B,SAsE4T1B,CAAAA,qBAtE7RmB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BAkCEC;;;;;iBAKD7B;;;;;UAKPC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDS6B;;;;;;;wBAOKnB;;;;;;;;;;;;;;;;;;;;WAoBboB;;;;;;;;;;;;;;;;;KAiBDC,wCAAwCvC,yBAAyBwC,oBAAoBxC,0CAA0CyC,sBAAsBzC,wBAAwB0C,IAAIH,qBAAqBE,QAAQC;KAC9MC,+CAA+CE,cAAc1C,6EAA6EA,WAAW2C,IAAIC,GAAGC,GAAG1B,IAAIsB,GAAGK,GAAGC,GAAGC"}
|
|
@@ -10,12 +10,10 @@ import { ChatResult } from "@langchain/core/outputs";
|
|
|
10
10
|
import { ModelProfile } from "@langchain/core/language_models/profile";
|
|
11
11
|
|
|
12
12
|
//#region src/chat_models/universal.d.ts
|
|
13
|
-
// TODO: remove once `EventStreamCallbackHandlerInput` is exposed in core
|
|
14
13
|
interface EventStreamCallbackHandlerInput extends Omit<LogStreamCallbackHandlerInput, "_schemaFormat"> {}
|
|
15
14
|
interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions {
|
|
16
15
|
tools?: (StructuredToolInterface | Record<string, unknown> | ToolDefinition | RunnableToolLike)[];
|
|
17
16
|
}
|
|
18
|
-
// Configuration map for model providers
|
|
19
17
|
declare const MODEL_PROVIDER_CONFIG: {
|
|
20
18
|
readonly openai: {
|
|
21
19
|
readonly package: "@langchain/openai";
|
|
@@ -113,7 +111,6 @@ declare function getChatModelByClassName(className: string): Promise<any>;
|
|
|
113
111
|
*/
|
|
114
112
|
declare function _inferModelProvider(modelName: string): string | undefined;
|
|
115
113
|
interface ConfigurableModelFields extends BaseChatModelParams {
|
|
116
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
114
|
defaultConfig?: Record<string, any>;
|
|
118
115
|
/**
|
|
119
116
|
* @default "any"
|
|
@@ -127,7 +124,6 @@ interface ConfigurableModelFields extends BaseChatModelParams {
|
|
|
127
124
|
* Methods which should be called after the model is initialized.
|
|
128
125
|
* The key will be the method name, and the value will be the arguments.
|
|
129
126
|
*/
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
127
|
queuedMethodOperations?: Record<string, any>;
|
|
132
128
|
/**
|
|
133
129
|
* Overrides the profiling information for the model. If not provided,
|
|
@@ -143,7 +139,6 @@ interface ConfigurableModelFields extends BaseChatModelParams {
|
|
|
143
139
|
declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
|
|
144
140
|
_llmType(): string;
|
|
145
141
|
lc_namespace: string[];
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
142
|
_defaultConfig?: Record<string, any>;
|
|
148
143
|
/**
|
|
149
144
|
* @default "any"
|
|
@@ -157,7 +152,6 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
157
152
|
* Methods which should be called after the model is initialized.
|
|
158
153
|
* The key will be the method name, and the value will be the arguments.
|
|
159
154
|
*/
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
155
|
_queuedMethodOperations: Record<string, any>;
|
|
162
156
|
/** @internal */
|
|
163
157
|
private _modelInstanceCache;
|
|
@@ -166,12 +160,8 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
166
160
|
constructor(fields: ConfigurableModelFields);
|
|
167
161
|
_getModelInstance(config?: RunnableConfig): Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure>>>;
|
|
168
162
|
_generate(messages: BaseMessage[], options?: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
169
|
-
bindTools(tools: BindToolsInput[],
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
-
params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;
|
|
172
|
-
// Extract the input types from the `BaseModel` class.
|
|
163
|
+
bindTools(tools: BindToolsInput[], params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;
|
|
173
164
|
withStructuredOutput: BaseChatModel["withStructuredOutput"];
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
165
|
_modelParams(config?: RunnableConfig): Record<string, any>;
|
|
176
166
|
_removePrefix(str: string, prefix: string): string;
|
|
177
167
|
/**
|
|
@@ -205,31 +195,24 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
205
195
|
*/
|
|
206
196
|
get profile(): ModelProfile;
|
|
207
197
|
}
|
|
208
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
198
|
interface InitChatModelFields extends Partial<Record<string, any>> {
|
|
210
199
|
modelProvider?: string;
|
|
211
200
|
configurableFields?: string[] | "any";
|
|
212
201
|
configPrefix?: string;
|
|
213
202
|
}
|
|
214
203
|
type ConfigurableFields = "any" | string[];
|
|
215
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string,
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
-
fields?: Partial<Record<string, any>> & {
|
|
204
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string, fields?: Partial<Record<string, any>> & {
|
|
218
205
|
modelProvider?: string;
|
|
219
206
|
configurableFields?: never;
|
|
220
207
|
configPrefix?: string;
|
|
221
208
|
}): Promise<ConfigurableModel<RunInput, CallOptions>>;
|
|
222
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never,
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
|
-
options?: Partial<Record<string, any>> & {
|
|
209
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never, options?: Partial<Record<string, any>> & {
|
|
225
210
|
modelProvider?: string;
|
|
226
211
|
configurableFields?: never;
|
|
227
212
|
configPrefix?: string;
|
|
228
213
|
profile?: ModelProfile;
|
|
229
214
|
}): Promise<ConfigurableModel<RunInput, CallOptions>>;
|
|
230
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string,
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
-
options?: Partial<Record<string, any>> & {
|
|
215
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string, options?: Partial<Record<string, any>> & {
|
|
233
216
|
modelProvider?: string;
|
|
234
217
|
configurableFields?: ConfigurableFields;
|
|
235
218
|
configPrefix?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.d.cts","names":["BaseLanguageModelInput","ToolDefinition","BaseChatModel","BaseChatModelParams","BindToolsInput","BaseChatModelCallOptions","BaseMessage","AIMessageChunk","MessageStructure","RunnableBatchOptions","RunnableBinding","RunnableConfig","RunnableToolLike","IterableReadableStream","LogStreamCallbackHandlerInput","RunLogPatch","StreamEvent","StructuredToolInterface","CallbackManagerForLLMRun","ChatResult","ModelProfile","EventStreamCallbackHandlerInput","Omit","ConfigurableChatModelCallOptions","Record","MODEL_PROVIDER_CONFIG","ChatModelProvider","getChatModelByClassName","Promise","_inferModelProvider","ConfigurableModelFields","ConfigurableModel","RunInput","CallOptions","Partial","Error","AsyncGenerator","Uint8Array","InitChatModelFields","ConfigurableFields","initChatModel"],"sources":["../../src/chat_models/universal.d.ts"],"sourcesContent":["import { BaseLanguageModelInput, ToolDefinition } from \"@langchain/core/language_models/base\";\nimport { BaseChatModel, BaseChatModelParams, BindToolsInput, type BaseChatModelCallOptions } from \"@langchain/core/language_models/chat_models\";\nimport { BaseMessage, type AIMessageChunk, MessageStructure } from \"@langchain/core/messages\";\nimport { type RunnableBatchOptions, RunnableBinding, type RunnableConfig, type RunnableToolLike } from \"@langchain/core/runnables\";\nimport { IterableReadableStream } from \"@langchain/core/utils/stream\";\nimport { type LogStreamCallbackHandlerInput, type RunLogPatch, type StreamEvent } from \"@langchain/core/tracers/log_stream\";\nimport { type StructuredToolInterface } from \"@langchain/core/tools\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { ChatResult } from \"@langchain/core/outputs\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\ninterface EventStreamCallbackHandlerInput extends Omit<LogStreamCallbackHandlerInput, \"_schemaFormat\"> {\n}\nexport interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions {\n tools?: (StructuredToolInterface | Record<string, unknown> | ToolDefinition | RunnableToolLike)[];\n}\nexport declare const MODEL_PROVIDER_CONFIG: {\n readonly openai: {\n readonly package: \"@langchain/openai\";\n readonly className: \"ChatOpenAI\";\n };\n readonly anthropic: {\n readonly package: \"@langchain/anthropic\";\n readonly className: \"ChatAnthropic\";\n };\n readonly azure_openai: {\n readonly package: \"@langchain/openai\";\n readonly className: \"AzureChatOpenAI\";\n };\n readonly cohere: {\n readonly package: \"@langchain/cohere\";\n readonly className: \"ChatCohere\";\n };\n readonly \"google-vertexai\": {\n readonly package: \"@langchain/google-vertexai\";\n readonly className: \"ChatVertexAI\";\n };\n readonly \"google-vertexai-web\": {\n readonly package: \"@langchain/google-vertexai-web\";\n readonly className: \"ChatVertexAI\";\n };\n readonly \"google-genai\": {\n readonly package: \"@langchain/google-genai\";\n readonly className: \"ChatGoogleGenerativeAI\";\n };\n readonly ollama: {\n readonly package: \"@langchain/ollama\";\n readonly className: \"ChatOllama\";\n };\n readonly mistralai: {\n readonly package: \"@langchain/mistralai\";\n readonly className: \"ChatMistralAI\";\n };\n readonly mistral: {\n readonly package: \"@langchain/mistralai\";\n readonly className: \"ChatMistralAI\";\n };\n readonly groq: {\n readonly package: \"@langchain/groq\";\n readonly className: \"ChatGroq\";\n };\n readonly cerebras: {\n readonly package: \"@langchain/cerebras\";\n readonly className: \"ChatCerebras\";\n };\n readonly bedrock: {\n readonly package: \"@langchain/aws\";\n readonly className: \"ChatBedrockConverse\";\n };\n readonly deepseek: {\n readonly package: \"@langchain/deepseek\";\n readonly className: \"ChatDeepSeek\";\n };\n readonly xai: {\n readonly package: \"@langchain/xai\";\n readonly className: \"ChatXAI\";\n };\n readonly fireworks: {\n readonly package: \"@langchain/community/chat_models/fireworks\";\n readonly className: \"ChatFireworks\";\n readonly hasCircularDependency: true;\n };\n readonly together: {\n readonly package: \"@langchain/community/chat_models/togetherai\";\n readonly className: \"ChatTogetherAI\";\n readonly hasCircularDependency: true;\n };\n readonly perplexity: {\n readonly package: \"@langchain/community/chat_models/perplexity\";\n readonly className: \"ChatPerplexity\";\n readonly hasCircularDependency: true;\n };\n};\nexport type ChatModelProvider = keyof typeof MODEL_PROVIDER_CONFIG;\n/**\n * Helper function to get a chat model class by its class name\n * @param className The class name (e.g., \"ChatOpenAI\", \"ChatAnthropic\")\n * @returns The imported model class or undefined if not found\n */\nexport declare function getChatModelByClassName(className: string): Promise<any>;\n/**\n * Attempts to infer the model provider based on the given model name.\n *\n * @param {string} modelName - The name of the model to infer the provider for.\n * @returns {string | undefined} The inferred model provider name, or undefined if unable to infer.\n *\n * @example\n * _inferModelProvider(\"gpt-4\"); // returns \"openai\"\n * _inferModelProvider(\"claude-2\"); // returns \"anthropic\"\n * _inferModelProvider(\"unknown-model\"); // returns undefined\n */\nexport declare function _inferModelProvider(modelName: string): string | undefined;\ninterface ConfigurableModelFields extends BaseChatModelParams {\n defaultConfig?: Record<string, any>;\n /**\n * @default \"any\"\n */\n configurableFields?: string[] | \"any\";\n /**\n * @default \"\"\n */\n configPrefix?: string;\n /**\n * Methods which should be called after the model is initialized.\n * The key will be the method name, and the value will be the arguments.\n */\n queuedMethodOperations?: Record<string, any>;\n /**\n * Overrides the profiling information for the model. If not provided,\n * the profile will be inferred from the inner model instance.\n */\n profile?: ModelProfile;\n}\n/**\n * Internal class used to create chat models.\n *\n * @internal\n */\nexport declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {\n _llmType(): string;\n lc_namespace: string[];\n _defaultConfig?: Record<string, any>;\n /**\n * @default \"any\"\n */\n _configurableFields: string[] | \"any\";\n /**\n * @default \"\"\n */\n _configPrefix: string;\n /**\n * Methods which should be called after the model is initialized.\n * The key will be the method name, and the value will be the arguments.\n */\n _queuedMethodOperations: Record<string, any>;\n /** @internal */\n private _modelInstanceCache;\n /** @internal */\n private _profile?;\n constructor(fields: ConfigurableModelFields);\n _getModelInstance(config?: RunnableConfig): Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure>>>;\n _generate(messages: BaseMessage[], options?: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n bindTools(tools: BindToolsInput[], params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;\n withStructuredOutput: BaseChatModel[\"withStructuredOutput\"];\n _modelParams(config?: RunnableConfig): Record<string, any>;\n _removePrefix(str: string, prefix: string): string;\n /**\n * Bind config to a Runnable, returning a new Runnable.\n * @param {RunnableConfig | undefined} [config] - The config to bind.\n * @returns {RunnableBinding<RunInput, RunOutput, CallOptions>} A new RunnableBinding with the bound config.\n */\n withConfig(config?: RunnableConfig): RunnableBinding<RunInput, AIMessageChunk, CallOptions>;\n invoke(input: RunInput, options?: CallOptions): Promise<AIMessageChunk>;\n stream(input: RunInput, options?: CallOptions): Promise<IterableReadableStream<AIMessageChunk>>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {\n returnExceptions?: false;\n }): Promise<AIMessageChunk[]>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {\n returnExceptions: true;\n }): Promise<(AIMessageChunk | Error)[]>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(AIMessageChunk | Error)[]>;\n transform(generator: AsyncGenerator<RunInput>, options: CallOptions): AsyncGenerator<AIMessageChunk>;\n streamLog(input: RunInput, options?: Partial<CallOptions>, streamOptions?: Omit<LogStreamCallbackHandlerInput, \"autoClose\">): AsyncGenerator<RunLogPatch>;\n streamEvents(input: RunInput, options: Partial<CallOptions> & {\n version: \"v1\" | \"v2\";\n }, streamOptions?: Omit<EventStreamCallbackHandlerInput, \"autoClose\">): IterableReadableStream<StreamEvent>;\n streamEvents(input: RunInput, options: Partial<CallOptions> & {\n version: \"v1\" | \"v2\";\n encoding: \"text/event-stream\";\n }, streamOptions?: Omit<EventStreamCallbackHandlerInput, \"autoClose\">): IterableReadableStream<Uint8Array>;\n /**\n * Return profiling information for the model.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile;\n}\nexport interface InitChatModelFields extends Partial<Record<string, any>> {\n modelProvider?: string;\n configurableFields?: string[] | \"any\";\n configPrefix?: string;\n}\nexport type ConfigurableFields = \"any\" | string[];\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string, fields?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: never;\n configPrefix?: string;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never, options?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: never;\n configPrefix?: string;\n profile?: ModelProfile;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string, options?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: ConfigurableFields;\n configPrefix?: string;\n profile?: ModelProfile;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport {};\n//# sourceMappingURL=universal.d.ts.map"],"mappings":";;;;;;;;;;;;UAUUqB,+BAAAA,SAAwCC,KAAKR;AAA7CO,UAEOE,gCAAAA,SAAyClB,wBAFRiB,CAAAA;EAEjCC,KAAAA,CAAAA,EAAAA,CACJN,uBADIM,GACsBC,MADU,CAAA,MAAA,EAAA,OAAA,CAAA,GACgBvB,cADhB,GACiCW,gBADjC,CAAA,EAAA;;AACVY,cAElBC,qBAFkBD,EAAAA;EAA0BvB,SAAAA,MAAAA,EAAAA;IAAiBW,SAAAA,OAAAA,EAAAA,mBAAAA;IADxBP,SAAAA,SAAAA,EAAAA,YAAAA;EAAwB,CAAA;EAG7DoB,SAAAA,SAAAA,EAAAA;IA6ETC,SAAAA,OAAiB,EAAA,sBAAgBD;IAMrBE,SAAAA,SAAAA,EAAAA,eAA4CC;EAY5CC,CAAAA;EACdC,SAAAA,YAAAA,EAAAA;IACUN,SAAAA,OAAAA,EAAAA,mBAAAA;IAaSA,SAAAA,SAAAA,EAAAA,iBAAAA;EAKfJ,CAAAA;EAnB4BjB,SAAAA,MAAAA,EAAAA;IAAmB,SAAA,OAAA,EAAA,mBAAA;IA0BxC4B,SAAAA,SAAiB,EAAA,YAAAE;EAAkBjC,CAAAA;EAAyBA,SAAAA,iBAAAA,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4CuB,mCAAmCA,4DAA4DW,QAAQV;;uBAE1Me;;YAEXnB;IACVQ,QAAQG,kBAAkBC,UAAUC"}
|
|
@@ -10,12 +10,10 @@ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
|
10
10
|
import { ModelProfile } from "@langchain/core/language_models/profile";
|
|
11
11
|
|
|
12
12
|
//#region src/chat_models/universal.d.ts
|
|
13
|
-
// TODO: remove once `EventStreamCallbackHandlerInput` is exposed in core
|
|
14
13
|
interface EventStreamCallbackHandlerInput extends Omit<LogStreamCallbackHandlerInput, "_schemaFormat"> {}
|
|
15
14
|
interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions {
|
|
16
15
|
tools?: (StructuredToolInterface | Record<string, unknown> | ToolDefinition | RunnableToolLike)[];
|
|
17
16
|
}
|
|
18
|
-
// Configuration map for model providers
|
|
19
17
|
declare const MODEL_PROVIDER_CONFIG: {
|
|
20
18
|
readonly openai: {
|
|
21
19
|
readonly package: "@langchain/openai";
|
|
@@ -113,7 +111,6 @@ declare function getChatModelByClassName(className: string): Promise<any>;
|
|
|
113
111
|
*/
|
|
114
112
|
declare function _inferModelProvider(modelName: string): string | undefined;
|
|
115
113
|
interface ConfigurableModelFields extends BaseChatModelParams {
|
|
116
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
114
|
defaultConfig?: Record<string, any>;
|
|
118
115
|
/**
|
|
119
116
|
* @default "any"
|
|
@@ -127,7 +124,6 @@ interface ConfigurableModelFields extends BaseChatModelParams {
|
|
|
127
124
|
* Methods which should be called after the model is initialized.
|
|
128
125
|
* The key will be the method name, and the value will be the arguments.
|
|
129
126
|
*/
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
127
|
queuedMethodOperations?: Record<string, any>;
|
|
132
128
|
/**
|
|
133
129
|
* Overrides the profiling information for the model. If not provided,
|
|
@@ -143,7 +139,6 @@ interface ConfigurableModelFields extends BaseChatModelParams {
|
|
|
143
139
|
declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
|
|
144
140
|
_llmType(): string;
|
|
145
141
|
lc_namespace: string[];
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
142
|
_defaultConfig?: Record<string, any>;
|
|
148
143
|
/**
|
|
149
144
|
* @default "any"
|
|
@@ -157,7 +152,6 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
157
152
|
* Methods which should be called after the model is initialized.
|
|
158
153
|
* The key will be the method name, and the value will be the arguments.
|
|
159
154
|
*/
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
155
|
_queuedMethodOperations: Record<string, any>;
|
|
162
156
|
/** @internal */
|
|
163
157
|
private _modelInstanceCache;
|
|
@@ -166,12 +160,8 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
166
160
|
constructor(fields: ConfigurableModelFields);
|
|
167
161
|
_getModelInstance(config?: RunnableConfig): Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure>>>;
|
|
168
162
|
_generate(messages: BaseMessage[], options?: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
169
|
-
bindTools(tools: BindToolsInput[],
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
-
params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;
|
|
172
|
-
// Extract the input types from the `BaseModel` class.
|
|
163
|
+
bindTools(tools: BindToolsInput[], params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;
|
|
173
164
|
withStructuredOutput: BaseChatModel["withStructuredOutput"];
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
165
|
_modelParams(config?: RunnableConfig): Record<string, any>;
|
|
176
166
|
_removePrefix(str: string, prefix: string): string;
|
|
177
167
|
/**
|
|
@@ -205,31 +195,24 @@ declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLa
|
|
|
205
195
|
*/
|
|
206
196
|
get profile(): ModelProfile;
|
|
207
197
|
}
|
|
208
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
198
|
interface InitChatModelFields extends Partial<Record<string, any>> {
|
|
210
199
|
modelProvider?: string;
|
|
211
200
|
configurableFields?: string[] | "any";
|
|
212
201
|
configPrefix?: string;
|
|
213
202
|
}
|
|
214
203
|
type ConfigurableFields = "any" | string[];
|
|
215
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string,
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
-
fields?: Partial<Record<string, any>> & {
|
|
204
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string, fields?: Partial<Record<string, any>> & {
|
|
218
205
|
modelProvider?: string;
|
|
219
206
|
configurableFields?: never;
|
|
220
207
|
configPrefix?: string;
|
|
221
208
|
}): Promise<ConfigurableModel<RunInput, CallOptions>>;
|
|
222
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never,
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
|
-
options?: Partial<Record<string, any>> & {
|
|
209
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never, options?: Partial<Record<string, any>> & {
|
|
225
210
|
modelProvider?: string;
|
|
226
211
|
configurableFields?: never;
|
|
227
212
|
configPrefix?: string;
|
|
228
213
|
profile?: ModelProfile;
|
|
229
214
|
}): Promise<ConfigurableModel<RunInput, CallOptions>>;
|
|
230
|
-
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string,
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
-
options?: Partial<Record<string, any>> & {
|
|
215
|
+
declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string, options?: Partial<Record<string, any>> & {
|
|
233
216
|
modelProvider?: string;
|
|
234
217
|
configurableFields?: ConfigurableFields;
|
|
235
218
|
configPrefix?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.d.ts","names":["BaseLanguageModelInput","ToolDefinition","BaseChatModel","BaseChatModelParams","BindToolsInput","BaseChatModelCallOptions","BaseMessage","AIMessageChunk","MessageStructure","RunnableBatchOptions","RunnableBinding","RunnableConfig","RunnableToolLike","IterableReadableStream","LogStreamCallbackHandlerInput","RunLogPatch","StreamEvent","StructuredToolInterface","CallbackManagerForLLMRun","ChatResult","ModelProfile","EventStreamCallbackHandlerInput","Omit","ConfigurableChatModelCallOptions","Record","MODEL_PROVIDER_CONFIG","ChatModelProvider","getChatModelByClassName","Promise","_inferModelProvider","ConfigurableModelFields","ConfigurableModel","RunInput","CallOptions","Partial","Error","AsyncGenerator","Uint8Array","InitChatModelFields","ConfigurableFields","initChatModel"],"sources":["../../src/chat_models/universal.d.ts"],"sourcesContent":["import { BaseLanguageModelInput, ToolDefinition } from \"@langchain/core/language_models/base\";\nimport { BaseChatModel, BaseChatModelParams, BindToolsInput, type BaseChatModelCallOptions } from \"@langchain/core/language_models/chat_models\";\nimport { BaseMessage, type AIMessageChunk, MessageStructure } from \"@langchain/core/messages\";\nimport { type RunnableBatchOptions, RunnableBinding, type RunnableConfig, type RunnableToolLike } from \"@langchain/core/runnables\";\nimport { IterableReadableStream } from \"@langchain/core/utils/stream\";\nimport { type LogStreamCallbackHandlerInput, type RunLogPatch, type StreamEvent } from \"@langchain/core/tracers/log_stream\";\nimport { type StructuredToolInterface } from \"@langchain/core/tools\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { ChatResult } from \"@langchain/core/outputs\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\ninterface EventStreamCallbackHandlerInput extends Omit<LogStreamCallbackHandlerInput, \"_schemaFormat\"> {\n}\nexport interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions {\n tools?: (StructuredToolInterface | Record<string, unknown> | ToolDefinition | RunnableToolLike)[];\n}\nexport declare const MODEL_PROVIDER_CONFIG: {\n readonly openai: {\n readonly package: \"@langchain/openai\";\n readonly className: \"ChatOpenAI\";\n };\n readonly anthropic: {\n readonly package: \"@langchain/anthropic\";\n readonly className: \"ChatAnthropic\";\n };\n readonly azure_openai: {\n readonly package: \"@langchain/openai\";\n readonly className: \"AzureChatOpenAI\";\n };\n readonly cohere: {\n readonly package: \"@langchain/cohere\";\n readonly className: \"ChatCohere\";\n };\n readonly \"google-vertexai\": {\n readonly package: \"@langchain/google-vertexai\";\n readonly className: \"ChatVertexAI\";\n };\n readonly \"google-vertexai-web\": {\n readonly package: \"@langchain/google-vertexai-web\";\n readonly className: \"ChatVertexAI\";\n };\n readonly \"google-genai\": {\n readonly package: \"@langchain/google-genai\";\n readonly className: \"ChatGoogleGenerativeAI\";\n };\n readonly ollama: {\n readonly package: \"@langchain/ollama\";\n readonly className: \"ChatOllama\";\n };\n readonly mistralai: {\n readonly package: \"@langchain/mistralai\";\n readonly className: \"ChatMistralAI\";\n };\n readonly mistral: {\n readonly package: \"@langchain/mistralai\";\n readonly className: \"ChatMistralAI\";\n };\n readonly groq: {\n readonly package: \"@langchain/groq\";\n readonly className: \"ChatGroq\";\n };\n readonly cerebras: {\n readonly package: \"@langchain/cerebras\";\n readonly className: \"ChatCerebras\";\n };\n readonly bedrock: {\n readonly package: \"@langchain/aws\";\n readonly className: \"ChatBedrockConverse\";\n };\n readonly deepseek: {\n readonly package: \"@langchain/deepseek\";\n readonly className: \"ChatDeepSeek\";\n };\n readonly xai: {\n readonly package: \"@langchain/xai\";\n readonly className: \"ChatXAI\";\n };\n readonly fireworks: {\n readonly package: \"@langchain/community/chat_models/fireworks\";\n readonly className: \"ChatFireworks\";\n readonly hasCircularDependency: true;\n };\n readonly together: {\n readonly package: \"@langchain/community/chat_models/togetherai\";\n readonly className: \"ChatTogetherAI\";\n readonly hasCircularDependency: true;\n };\n readonly perplexity: {\n readonly package: \"@langchain/community/chat_models/perplexity\";\n readonly className: \"ChatPerplexity\";\n readonly hasCircularDependency: true;\n };\n};\nexport type ChatModelProvider = keyof typeof MODEL_PROVIDER_CONFIG;\n/**\n * Helper function to get a chat model class by its class name\n * @param className The class name (e.g., \"ChatOpenAI\", \"ChatAnthropic\")\n * @returns The imported model class or undefined if not found\n */\nexport declare function getChatModelByClassName(className: string): Promise<any>;\n/**\n * Attempts to infer the model provider based on the given model name.\n *\n * @param {string} modelName - The name of the model to infer the provider for.\n * @returns {string | undefined} The inferred model provider name, or undefined if unable to infer.\n *\n * @example\n * _inferModelProvider(\"gpt-4\"); // returns \"openai\"\n * _inferModelProvider(\"claude-2\"); // returns \"anthropic\"\n * _inferModelProvider(\"unknown-model\"); // returns undefined\n */\nexport declare function _inferModelProvider(modelName: string): string | undefined;\ninterface ConfigurableModelFields extends BaseChatModelParams {\n defaultConfig?: Record<string, any>;\n /**\n * @default \"any\"\n */\n configurableFields?: string[] | \"any\";\n /**\n * @default \"\"\n */\n configPrefix?: string;\n /**\n * Methods which should be called after the model is initialized.\n * The key will be the method name, and the value will be the arguments.\n */\n queuedMethodOperations?: Record<string, any>;\n /**\n * Overrides the profiling information for the model. If not provided,\n * the profile will be inferred from the inner model instance.\n */\n profile?: ModelProfile;\n}\n/**\n * Internal class used to create chat models.\n *\n * @internal\n */\nexport declare class ConfigurableModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {\n _llmType(): string;\n lc_namespace: string[];\n _defaultConfig?: Record<string, any>;\n /**\n * @default \"any\"\n */\n _configurableFields: string[] | \"any\";\n /**\n * @default \"\"\n */\n _configPrefix: string;\n /**\n * Methods which should be called after the model is initialized.\n * The key will be the method name, and the value will be the arguments.\n */\n _queuedMethodOperations: Record<string, any>;\n /** @internal */\n private _modelInstanceCache;\n /** @internal */\n private _profile?;\n constructor(fields: ConfigurableModelFields);\n _getModelInstance(config?: RunnableConfig): Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure>>>;\n _generate(messages: BaseMessage[], options?: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n bindTools(tools: BindToolsInput[], params?: Record<string, any>): ConfigurableModel<RunInput, CallOptions>;\n withStructuredOutput: BaseChatModel[\"withStructuredOutput\"];\n _modelParams(config?: RunnableConfig): Record<string, any>;\n _removePrefix(str: string, prefix: string): string;\n /**\n * Bind config to a Runnable, returning a new Runnable.\n * @param {RunnableConfig | undefined} [config] - The config to bind.\n * @returns {RunnableBinding<RunInput, RunOutput, CallOptions>} A new RunnableBinding with the bound config.\n */\n withConfig(config?: RunnableConfig): RunnableBinding<RunInput, AIMessageChunk, CallOptions>;\n invoke(input: RunInput, options?: CallOptions): Promise<AIMessageChunk>;\n stream(input: RunInput, options?: CallOptions): Promise<IterableReadableStream<AIMessageChunk>>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {\n returnExceptions?: false;\n }): Promise<AIMessageChunk[]>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {\n returnExceptions: true;\n }): Promise<(AIMessageChunk | Error)[]>;\n batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(AIMessageChunk | Error)[]>;\n transform(generator: AsyncGenerator<RunInput>, options: CallOptions): AsyncGenerator<AIMessageChunk>;\n streamLog(input: RunInput, options?: Partial<CallOptions>, streamOptions?: Omit<LogStreamCallbackHandlerInput, \"autoClose\">): AsyncGenerator<RunLogPatch>;\n streamEvents(input: RunInput, options: Partial<CallOptions> & {\n version: \"v1\" | \"v2\";\n }, streamOptions?: Omit<EventStreamCallbackHandlerInput, \"autoClose\">): IterableReadableStream<StreamEvent>;\n streamEvents(input: RunInput, options: Partial<CallOptions> & {\n version: \"v1\" | \"v2\";\n encoding: \"text/event-stream\";\n }, streamOptions?: Omit<EventStreamCallbackHandlerInput, \"autoClose\">): IterableReadableStream<Uint8Array>;\n /**\n * Return profiling information for the model.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile;\n}\nexport interface InitChatModelFields extends Partial<Record<string, any>> {\n modelProvider?: string;\n configurableFields?: string[] | \"any\";\n configPrefix?: string;\n}\nexport type ConfigurableFields = \"any\" | string[];\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: string, fields?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: never;\n configPrefix?: string;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model: never, options?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: never;\n configPrefix?: string;\n profile?: ModelProfile;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport declare function initChatModel<RunInput extends BaseLanguageModelInput = BaseLanguageModelInput, CallOptions extends ConfigurableChatModelCallOptions = ConfigurableChatModelCallOptions>(model?: string, options?: Partial<Record<string, any>> & {\n modelProvider?: string;\n configurableFields?: ConfigurableFields;\n configPrefix?: string;\n profile?: ModelProfile;\n}): Promise<ConfigurableModel<RunInput, CallOptions>>;\nexport {};\n//# sourceMappingURL=universal.d.ts.map"],"mappings":";;;;;;;;;;;;UAUUqB,+BAAAA,SAAwCC,KAAKR;AAA7CO,UAEOE,gCAAAA,SAAyClB,wBAFRiB,CAAAA;EAEjCC,KAAAA,CAAAA,EAAAA,CACJN,uBADIM,GACsBC,MADU,CAAA,MAAA,EAAA,OAAA,CAAA,GACgBvB,cADhB,GACiCW,gBADjC,CAAA,EAAA;;AACVY,cAElBC,qBAFkBD,EAAAA;EAA0BvB,SAAAA,MAAAA,EAAAA;IAAiBW,SAAAA,OAAAA,EAAAA,mBAAAA;IADxBP,SAAAA,SAAAA,EAAAA,YAAAA;EAAwB,CAAA;EAG7DoB,SAAAA,SAAAA,EAAAA;IA6ETC,SAAAA,OAAiB,EAAA,sBAAgBD;IAMrBE,SAAAA,SAAAA,EAAAA,eAA4CC;EAY5CC,CAAAA;EACdC,SAAAA,YAAAA,EAAAA;IACUN,SAAAA,OAAAA,EAAAA,mBAAAA;IAaSA,SAAAA,SAAAA,EAAAA,iBAAAA;EAKfJ,CAAAA;EAnB4BjB,SAAAA,MAAAA,EAAAA;IAAmB,SAAA,OAAA,EAAA,mBAAA;IA0BxC4B,SAAAA,SAAiB,EAAA,YAAAE;EAAkBjC,CAAAA;EAAyBA,SAAAA,iBAAAA,EAAAA;IAA4CuB,SAAAA,OAAAA,EAAAA,4BAAAA;IAAmCA,SAAAA,SAAAA,EAAAA,cAAAA;EAAwDU,CAAAA;EAAa1B,SAAAA,qBAAAA,EAAAA;IAGhNiB,SAAAA,OAAAA,EAAAA,gCAAAA;IAaQA,SAAAA,SAAAA,EAAAA,cAAAA;EAKLM,CAAAA;EACOnB,SAAAA,cAAAA,EAAAA;IAAuCN,SAAAA,OAAAA,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A,MAAAA,CAAAA,EAAAA,MAAAA;EAA5BF;;AAAD;;;sBAhDapB,iBAAiBD,gBAAgBsB,UAAUzB,gBAAgB0B;gBACjED,oBAAoBC,cAAcL,QAAQrB;gBAC1CyB,oBAAoBC,cAAcL,QAAQf,uBAAuBN;gBACjEyB,sBAAsBE,QAAQD,eAAeC,QAAQD,+BAA+BxB;;MAE9FmB,QAAQrB;gBACEyB,sBAAsBE,QAAQD,eAAeC,QAAQD,+BAA+BxB;;MAE9FmB,SAASrB,iBAAiB4B;gBAChBH,sBAAsBE,QAAQD,eAAeC,QAAQD,+BAA+BxB,uBAAuBmB,SAASrB,iBAAiB4B;uBAC9HC,eAAeJ,oBAAoBC,cAAcG,eAAe7B;mBACpEyB,oBAAoBE,QAAQD,8BAA8BX,KAAKR,8CAA8CsB,eAAerB;sBACzHiB,mBAAmBE,QAAQD;;qBAE5BX,KAAKD,gDAAgDR,uBAAuBG;sBAC3EgB,mBAAmBE,QAAQD;;;qBAG5BX,KAAKD,gDAAgDR,uBAAuBwB;;;;;;iBAMhFjB;;UAEFkB,mBAAAA,SAA4BJ,QAAQV;;;;;KAKzCe,kBAAAA;iBACYC,+BAA+BxC,yBAAyBA,4CAA4CuB,mCAAmCA,0DAA0DW,QAAQV;;;;IAI7NI,QAAQG,kBAAkBC,UAAUC;iBAChBO,+BAA+BxC,yBAAyBA,4CAA4CuB,mCAAmCA,0DAA0DW,QAAQV;;;;YAInNJ;IACVQ,QAAQG,kBAAkBC,UAAUC;iBAChBO,+BAA+BxC,yBAAyBA,4CAA4CuB,mCAAmCA,4DAA4DW,QAAQV;;uBAE1Me;;YAEXnB;IACVQ,QAAQG,kBAAkBC,UAAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["BaseLanguageModel","Runnable","PromptCommit","basePush","Promise","basePull","generateModelImportMap","Record","generateOptionalImportMap","bindOutputSchema","T"],"sources":["../../src/hub/base.d.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport declare function basePush(repoFullName: string, runnable: Runnable, options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n}): Promise<string>;\nexport declare function basePull(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<PromptCommit>;\nexport declare function generateModelImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;\nexport declare function generateOptionalImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;\nexport declare function bindOutputSchema<T extends Runnable>(loadedSequence: T): T;\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;AAWA;;;;;;;iBAAwBG,QAAAA,iCAAyCF;;;;;;;;IAQ7DG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":["BaseLanguageModel","Runnable","PromptCommit","basePush","Promise","basePull","generateModelImportMap","Record","generateOptionalImportMap","bindOutputSchema","T"],"sources":["../../src/hub/base.d.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport declare function basePush(repoFullName: string, runnable: Runnable, options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n}): Promise<string>;\nexport declare function basePull(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<PromptCommit>;\nexport declare function generateModelImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;\nexport declare function generateOptionalImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;\nexport declare function bindOutputSchema<T extends Runnable>(loadedSequence: T): T;\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;AAWA;;;;;;;iBAAwBG,QAAAA,iCAAyCF;;;;;;;;IAQ7DG"}
|
package/dist/hub/index.d.cts
CHANGED
|
@@ -24,7 +24,6 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
|
|
|
24
24
|
apiKey?: string;
|
|
25
25
|
apiUrl?: string;
|
|
26
26
|
includeModel?: boolean;
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
27
|
modelClass?: new (...args: any[]) => BaseLanguageModel;
|
|
29
28
|
}): Promise<T>;
|
|
30
29
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\n/**\n * Pull a prompt from the hub.\n *\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. For non-OpenAI models, you must also set \"modelClass\" to the\n * correct class of the model.\n * @param options.modelClass If includeModel is true, the class of the model to instantiate. Required\n * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,\n * you may instead import this function from \"langchain/hub/node\" and pass \"includeModel: true\" instead\n * of specifying this parameter.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAoBA;;;;;AAKW;;;;;;;;;;iBALaI,eAAeJ;;;;uCAIEC;IACrCK,QAAQD"}
|
package/dist/hub/index.d.ts
CHANGED
|
@@ -24,7 +24,6 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
|
|
|
24
24
|
apiKey?: string;
|
|
25
25
|
apiUrl?: string;
|
|
26
26
|
includeModel?: boolean;
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
27
|
modelClass?: new (...args: any[]) => BaseLanguageModel;
|
|
29
28
|
}): Promise<T>;
|
|
30
29
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\n/**\n * Pull a prompt from the hub.\n *\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. For non-OpenAI models, you must also set \"modelClass\" to the\n * correct class of the model.\n * @param options.modelClass If includeModel is true, the class of the model to instantiate. Required\n * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,\n * you may instead import this function from \"langchain/hub/node\" and pass \"includeModel: true\" instead\n * of specifying this parameter.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAoBA;;;;;AAKW;;;;;;;;;;iBALaI,eAAeJ;;;;uCAIEC;IACrCK,QAAQD"}
|
package/dist/hub/node.cjs
CHANGED
|
@@ -3,6 +3,25 @@ const require_load_index = require('../load/index.cjs');
|
|
|
3
3
|
const require_base = require('./base.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/hub/node.ts
|
|
6
|
+
function _idEquals(a, b) {
|
|
7
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
8
|
+
if (a.length !== b.length) return false;
|
|
9
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
function isRunnableBinding(a) {
|
|
13
|
+
const wellKnownIds = [[
|
|
14
|
+
"langchain_core",
|
|
15
|
+
"runnables",
|
|
16
|
+
"RunnableBinding"
|
|
17
|
+
], [
|
|
18
|
+
"langchain",
|
|
19
|
+
"schema",
|
|
20
|
+
"runnable",
|
|
21
|
+
"RunnableBinding"
|
|
22
|
+
]];
|
|
23
|
+
return wellKnownIds.some((id) => _idEquals(a, id));
|
|
24
|
+
}
|
|
6
25
|
/**
|
|
7
26
|
* Pull a prompt from the hub.
|
|
8
27
|
* @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
|
|
@@ -17,8 +36,9 @@ async function pull(ownerRepoCommit, options) {
|
|
|
17
36
|
const promptObject = await require_base.basePull(ownerRepoCommit, options);
|
|
18
37
|
let modelClass;
|
|
19
38
|
if (options?.includeModel) {
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id) ? promptObject.manifest.kwargs?.last?.kwargs?.bound : promptObject.manifest.kwargs?.last;
|
|
40
|
+
if (Array.isArray(chatModelObject?.id)) {
|
|
41
|
+
const modelName = chatModelObject?.id.at(-1);
|
|
22
42
|
if (modelName) {
|
|
23
43
|
modelClass = await require_chat_models_universal.getChatModelByClassName(modelName);
|
|
24
44
|
if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
|
package/dist/hub/node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.cjs","names":["ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n }","basePull","getChatModelByClassName","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\n
|
|
1
|
+
{"version":3,"file":"node.cjs","names":["a: string[]","b: string[]","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n }","basePull","getChatModelByClassName","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\nexport { basePush as push } from \"./base.js\";\n\nfunction _idEquals(a: string[], b: string[]): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction isRunnableBinding(a: string[]): boolean {\n const wellKnownIds = [\n [\"langchain_core\", \"runnables\", \"RunnableBinding\"],\n [\"langchain\", \"schema\", \"runnable\", \"RunnableBinding\"],\n ];\n return wellKnownIds.some((id) => _idEquals(a, id));\n}\n\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n const chatModelObject = isRunnableBinding(\n promptObject.manifest.kwargs?.last?.id\n )\n ? promptObject.manifest.kwargs?.last?.kwargs?.bound\n : promptObject.manifest.kwargs?.last;\n\n if (Array.isArray(chatModelObject?.id)) {\n const modelName = chatModelObject?.id.at(-1);\n\n if (modelName) {\n modelClass = await getChatModelByClassName(modelName);\n if (!modelClass) {\n console.warn(\n `Received unknown model name from prompt hub: \"${modelName}\"`\n );\n }\n }\n }\n }\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n undefined,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass)\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;AAYA,SAAS,UAAUA,GAAaC,GAAsB;AACpD,KAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,QAAQ,EAAE,CACxC,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;AACR;AAED,SAAS,kBAAkBD,GAAsB;CAC/C,MAAM,eAAe,CACnB;EAAC;EAAkB;EAAa;CAAkB,GAClD;EAAC;EAAa;EAAU;EAAY;CAAkB,CACvD;AACD,QAAO,aAAa,KAAK,CAAC,OAAO,UAAU,GAAG,GAAG,CAAC;AACnD;;;;;;;;;;;AAYD,eAAsB,KACpBE,iBACAC,SAKA;CACA,MAAM,eAAe,MAAMC,sBAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cAAc;EACzB,MAAM,kBAAkB,kBACtB,aAAa,SAAS,QAAQ,MAAM,GACrC,GACG,aAAa,SAAS,QAAQ,MAAM,QAAQ,QAC5C,aAAa,SAAS,QAAQ;AAElC,MAAI,MAAM,QAAQ,iBAAiB,GAAG,EAAE;GACtC,MAAM,YAAY,iBAAiB,GAAG,GAAG,GAAG;AAE5C,OAAI,WAAW;IACb,aAAa,MAAMC,sDAAwB,UAAU;AACrD,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;CACF;CACD,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,QACAC,uCAA0B,WAAW,EACrCC,oCAAuB,WAAW,CACnC;AACD,QAAOC,8BAAiB,aAAa;AACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.cts","names":["Runnable","basePush","push","pull","T","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAYA;;;;AAIW;;;;iBAJaG,eAAeH;;;;IAInCK,QAAQD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","names":["Runnable","basePush","push","pull","T","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAYA;;;;AAIW;;;;iBAJaG,eAAeH;;;;IAInCK,QAAQD"}
|
package/dist/hub/node.js
CHANGED
|
@@ -3,6 +3,25 @@ import { load } from "../load/index.js";
|
|
|
3
3
|
import { basePull, basePush, bindOutputSchema, generateModelImportMap, generateOptionalImportMap } from "./base.js";
|
|
4
4
|
|
|
5
5
|
//#region src/hub/node.ts
|
|
6
|
+
function _idEquals(a, b) {
|
|
7
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
8
|
+
if (a.length !== b.length) return false;
|
|
9
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
function isRunnableBinding(a) {
|
|
13
|
+
const wellKnownIds = [[
|
|
14
|
+
"langchain_core",
|
|
15
|
+
"runnables",
|
|
16
|
+
"RunnableBinding"
|
|
17
|
+
], [
|
|
18
|
+
"langchain",
|
|
19
|
+
"schema",
|
|
20
|
+
"runnable",
|
|
21
|
+
"RunnableBinding"
|
|
22
|
+
]];
|
|
23
|
+
return wellKnownIds.some((id) => _idEquals(a, id));
|
|
24
|
+
}
|
|
6
25
|
/**
|
|
7
26
|
* Pull a prompt from the hub.
|
|
8
27
|
* @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
|
|
@@ -17,8 +36,9 @@ async function pull(ownerRepoCommit, options) {
|
|
|
17
36
|
const promptObject = await basePull(ownerRepoCommit, options);
|
|
18
37
|
let modelClass;
|
|
19
38
|
if (options?.includeModel) {
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id) ? promptObject.manifest.kwargs?.last?.kwargs?.bound : promptObject.manifest.kwargs?.last;
|
|
40
|
+
if (Array.isArray(chatModelObject?.id)) {
|
|
41
|
+
const modelName = chatModelObject?.id.at(-1);
|
|
22
42
|
if (modelName) {
|
|
23
43
|
modelClass = await getChatModelByClassName(modelName);
|
|
24
44
|
if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
|