@langchain/core 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/agents.d.cts +2 -0
- package/dist/agents.d.ts +2 -0
- package/dist/callbacks/base.d.cts +60 -22
- package/dist/callbacks/base.d.ts +60 -22
- package/dist/callbacks/dispatch/index.d.cts +3 -1
- package/dist/callbacks/dispatch/index.d.ts +3 -1
- package/dist/callbacks/dispatch/web.d.cts +3 -1
- package/dist/callbacks/dispatch/web.d.ts +3 -1
- package/dist/callbacks/manager.d.cts +12 -2
- package/dist/callbacks/manager.d.ts +12 -2
- package/dist/chat_history.d.cts +1 -0
- package/dist/chat_history.d.ts +1 -0
- package/dist/document_loaders/langsmith.d.cts +3 -0
- package/dist/document_loaders/langsmith.d.ts +3 -0
- package/dist/documents/document.d.cts +12 -3
- package/dist/documents/document.d.ts +12 -3
- package/dist/example_selectors/length_based.d.cts +1 -1
- package/dist/example_selectors/length_based.d.ts +1 -1
- package/dist/indexing/base.d.cts +1 -0
- package/dist/indexing/base.d.ts +1 -0
- package/dist/indexing/record_manager.d.cts +1 -0
- package/dist/indexing/record_manager.d.ts +1 -0
- package/dist/language_models/base.d.cts +38 -8
- package/dist/language_models/base.d.ts +38 -8
- package/dist/language_models/chat_models.d.cts +33 -6
- package/dist/language_models/chat_models.d.ts +33 -6
- package/dist/language_models/llms.d.cts +6 -0
- package/dist/language_models/llms.d.ts +6 -0
- package/dist/load/import_type.d.cts +1 -0
- package/dist/load/import_type.d.ts +1 -0
- package/dist/load/map_keys.cjs +5 -4
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.d.cts +1 -0
- package/dist/load/map_keys.d.ts +1 -0
- package/dist/load/map_keys.js +3 -3
- package/dist/load/map_keys.js.map +1 -1
- package/dist/load/serializable.d.cts +1 -0
- package/dist/load/serializable.d.ts +1 -0
- package/dist/memory.d.cts +3 -0
- package/dist/memory.d.ts +3 -0
- package/dist/messages/base.d.cts +13 -1
- package/dist/messages/base.d.ts +13 -1
- package/dist/messages/content/data.d.cts +7 -2
- package/dist/messages/content/data.d.ts +7 -2
- package/dist/messages/content/index.d.cts +4 -1
- package/dist/messages/content/index.d.ts +4 -1
- package/dist/messages/content/multimodal.d.cts +1 -0
- package/dist/messages/content/multimodal.d.ts +1 -0
- package/dist/messages/content/tools.d.cts +1 -0
- package/dist/messages/content/tools.d.ts +1 -0
- package/dist/messages/tool.d.cts +9 -2
- package/dist/messages/tool.d.ts +9 -2
- package/dist/messages/transformers.d.cts +3 -0
- package/dist/messages/transformers.d.ts +3 -0
- package/dist/messages/utils.d.cts +5 -2
- package/dist/messages/utils.d.ts +5 -2
- package/dist/output_parsers/json.d.cts +5 -1
- package/dist/output_parsers/json.d.ts +5 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +6 -2
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +6 -2
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +34 -10
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +34 -10
- package/dist/output_parsers/transform.d.cts +1 -0
- package/dist/output_parsers/transform.d.ts +1 -0
- package/dist/outputs.d.cts +6 -0
- package/dist/outputs.d.ts +6 -0
- package/dist/prompts/base.d.cts +10 -2
- package/dist/prompts/base.d.ts +10 -2
- package/dist/prompts/chat.d.cts +51 -13
- package/dist/prompts/chat.d.ts +51 -13
- package/dist/prompts/few_shot.d.cts +5 -1
- package/dist/prompts/few_shot.d.ts +5 -1
- package/dist/prompts/image.d.cts +10 -2
- package/dist/prompts/image.d.ts +10 -2
- package/dist/prompts/prompt.d.cts +15 -4
- package/dist/prompts/prompt.d.ts +16 -4
- package/dist/prompts/serde.d.cts +1 -0
- package/dist/prompts/serde.d.ts +1 -0
- package/dist/prompts/string.d.cts +5 -1
- package/dist/prompts/string.d.ts +5 -1
- package/dist/prompts/structured.d.cts +16 -3
- package/dist/prompts/structured.d.ts +16 -3
- package/dist/retrievers/document_compressors/index.d.cts +1 -0
- package/dist/retrievers/document_compressors/index.d.ts +1 -0
- package/dist/retrievers/index.d.cts +6 -2
- package/dist/retrievers/index.d.ts +6 -2
- package/dist/runnables/base.cjs +7 -7
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +64 -12
- package/dist/runnables/base.d.ts +64 -12
- package/dist/runnables/base.js +1 -1
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.d.cts +2 -0
- package/dist/runnables/branch.d.ts +2 -0
- package/dist/runnables/config.d.cts +1 -0
- package/dist/runnables/config.d.ts +1 -0
- package/dist/runnables/graph.d.cts +5 -1
- package/dist/runnables/graph.d.ts +5 -1
- package/dist/runnables/history.d.cts +12 -4
- package/dist/runnables/history.d.ts +12 -4
- package/dist/runnables/passthrough.d.cts +2 -0
- package/dist/runnables/passthrough.d.ts +2 -0
- package/dist/runnables/router.d.cts +1 -0
- package/dist/runnables/router.d.ts +1 -0
- package/dist/runnables/types.d.cts +9 -2
- package/dist/runnables/types.d.ts +9 -2
- package/dist/singletons/async_local_storage/context.d.cts +2 -0
- package/dist/singletons/async_local_storage/context.d.ts +2 -0
- package/dist/singletons/async_local_storage/globals.d.cts +1 -0
- package/dist/singletons/async_local_storage/globals.d.ts +1 -0
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/stores.d.cts +1 -0
- package/dist/stores.d.ts +1 -0
- package/dist/structured_query/utils.d.cts +4 -1
- package/dist/structured_query/utils.d.ts +4 -1
- package/dist/tools/index.d.cts +6 -1
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/types.d.cts +13 -3
- package/dist/tools/types.d.ts +13 -3
- package/dist/tracers/base.d.cts +20 -1
- package/dist/tracers/base.d.ts +20 -1
- package/dist/tracers/console.cjs +3 -3
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.d.cts +2 -0
- package/dist/tracers/console.d.ts +2 -0
- package/dist/tracers/console.js +3 -3
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.d.cts +4 -0
- package/dist/tracers/event_stream.d.ts +4 -0
- package/dist/tracers/log_stream.d.cts +6 -0
- package/dist/tracers/log_stream.d.ts +6 -0
- package/dist/types/_internal.d.cts +3 -0
- package/dist/types/_internal.d.ts +3 -0
- package/dist/types/type-utils.d.cts +2 -0
- package/dist/types/type-utils.d.ts +2 -0
- package/dist/utils/async_caller.cjs +1 -1
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts +3 -0
- package/dist/utils/async_caller.d.ts +3 -0
- package/dist/utils/async_caller.js +1 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/env.d.cts +4 -0
- package/dist/utils/env.d.ts +4 -0
- package/dist/utils/event_source_parse.d.cts +4 -1
- package/dist/utils/event_source_parse.d.ts +4 -1
- package/dist/utils/function_calling.d.cts +3 -1
- package/dist/utils/function_calling.d.ts +3 -1
- package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.cjs +1 -1
- package/dist/utils/is-network-error/index.cjs.map +1 -0
- package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.js +1 -1
- package/dist/utils/is-network-error/index.js.map +1 -0
- package/dist/utils/json.d.cts +1 -0
- package/dist/utils/json.d.ts +1 -0
- package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.cjs +2 -2
- package/dist/utils/p-retry/index.cjs.map +1 -0
- package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.js +2 -2
- package/dist/utils/p-retry/index.js.map +1 -0
- package/dist/utils/stream.d.cts +13 -1
- package/dist/utils/stream.d.ts +13 -1
- package/dist/utils/testing/chat_models.d.cts +11 -3
- package/dist/utils/testing/chat_models.d.ts +11 -3
- package/dist/utils/testing/retrievers.d.cts +3 -1
- package/dist/utils/testing/retrievers.d.ts +3 -1
- package/dist/utils/testing/vectorstores.d.cts +1 -0
- package/dist/utils/testing/vectorstores.d.ts +1 -0
- package/dist/utils/types/index.d.cts +2 -0
- package/dist/utils/types/index.d.ts +2 -0
- package/dist/utils/types/zod.d.cts +3 -0
- package/dist/utils/types/zod.d.ts +3 -0
- package/dist/vectorstores.d.cts +17 -5
- package/dist/vectorstores.d.ts +17 -5
- package/package.json +5 -6
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +0 -169
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +0 -168
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +0 -1
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +0 -122
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +0 -121
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +0 -1
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +0 -18
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +0 -17
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +0 -1
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +0 -1
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +0 -1
|
@@ -47,6 +47,7 @@ type BranchLike<RunInput, RunOutput> = [RunnableLike<RunInput, boolean>, Runnabl
|
|
|
47
47
|
* });
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
51
|
declare class RunnableBranch<RunInput = any, RunOutput = any> extends Runnable<RunInput, RunOutput> {
|
|
51
52
|
static lc_name(): string;
|
|
52
53
|
lc_namespace: string[];
|
|
@@ -82,6 +83,7 @@ declare class RunnableBranch<RunInput = any, RunOutput = any> extends Runnable<R
|
|
|
82
83
|
* pairs. The last item is a default runnable which is invoked if no other condition matches.
|
|
83
84
|
* @returns A new RunnableBranch.
|
|
84
85
|
*/
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
87
|
static from<RunInput = any, RunOutput = any>(branches: [...BranchLike<RunInput, RunOutput>[], RunnableLike<RunInput, RunOutput>]): RunnableBranch<RunInput, RunOutput>;
|
|
86
88
|
_invoke(input: RunInput, config?: Partial<RunnableConfig>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
|
|
87
89
|
invoke(input: RunInput, config?: RunnableConfig): Promise<RunOutput>;
|
|
@@ -48,6 +48,7 @@ type BranchLike<RunInput, RunOutput> = [RunnableLike<RunInput, boolean>, Runnabl
|
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
52
|
declare class RunnableBranch<RunInput = any, RunOutput = any> extends Runnable<RunInput, RunOutput> {
|
|
52
53
|
static lc_name(): string;
|
|
53
54
|
lc_namespace: string[];
|
|
@@ -83,6 +84,7 @@ declare class RunnableBranch<RunInput = any, RunOutput = any> extends Runnable<R
|
|
|
83
84
|
* pairs. The last item is a default runnable which is invoked if no other condition matches.
|
|
84
85
|
* @returns A new RunnableBranch.
|
|
85
86
|
*/
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
88
|
static from<RunInput = any, RunOutput = any>(branches: [...BranchLike<RunInput, RunOutput>[], RunnableLike<RunInput, RunOutput>]): RunnableBranch<RunInput, RunOutput>;
|
|
87
89
|
_invoke(input: RunInput, config?: Partial<RunnableConfig>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
|
|
88
90
|
invoke(input: RunInput, config?: RunnableConfig): Promise<RunOutput>;
|
|
@@ -19,6 +19,7 @@ declare function patchConfig<CallOptions extends RunnableConfig>(config?: Partia
|
|
|
19
19
|
configurable,
|
|
20
20
|
runId
|
|
21
21
|
}?: RunnableConfig): Partial<CallOptions>;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
23
|
declare function pickRunnableConfigKeys<CallOptions extends Record<string, any>>(config?: CallOptions): Partial<RunnableConfig> | undefined;
|
|
23
24
|
//#endregion
|
|
24
25
|
export { ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig, pickRunnableConfigKeys };
|
|
@@ -19,6 +19,7 @@ declare function patchConfig<CallOptions extends RunnableConfig>(config?: Partia
|
|
|
19
19
|
configurable,
|
|
20
20
|
runId
|
|
21
21
|
}?: RunnableConfig): Partial<CallOptions>;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
23
|
declare function pickRunnableConfigKeys<CallOptions extends Record<string, any>>(config?: CallOptions): Partial<RunnableConfig> | undefined;
|
|
23
24
|
//#endregion
|
|
24
25
|
export { ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig, pickRunnableConfigKeys };
|
|
@@ -8,8 +8,12 @@ declare class Graph {
|
|
|
8
8
|
nodes: Record<string, Node>;
|
|
9
9
|
edges: Edge[];
|
|
10
10
|
});
|
|
11
|
+
// Convert the graph to a JSON-serializable format.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
13
|
toJSON(): Record<string, any>;
|
|
12
|
-
addNode(data: RunnableInterface | RunnableIOSchema, id?: string,
|
|
14
|
+
addNode(data: RunnableInterface | RunnableIOSchema, id?: string,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
metadata?: Record<string, any>): Node;
|
|
13
17
|
removeNode(node: Node): void;
|
|
14
18
|
addEdge(source: Node, target: Node, data?: string, conditional?: boolean): Edge;
|
|
15
19
|
firstNode(): Node | undefined;
|
|
@@ -8,8 +8,12 @@ declare class Graph {
|
|
|
8
8
|
nodes: Record<string, Node>;
|
|
9
9
|
edges: Edge[];
|
|
10
10
|
});
|
|
11
|
+
// Convert the graph to a JSON-serializable format.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
13
|
toJSON(): Record<string, any>;
|
|
12
|
-
addNode(data: RunnableInterface | RunnableIOSchema, id?: string,
|
|
14
|
+
addNode(data: RunnableInterface | RunnableIOSchema, id?: string,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
metadata?: Record<string, any>): Node;
|
|
13
17
|
removeNode(node: Node): void;
|
|
14
18
|
addEdge(source: Node, target: Node, data?: string, conditional?: boolean): Edge;
|
|
15
19
|
firstNode(): Node | undefined;
|
|
@@ -5,7 +5,9 @@ import { Runnable, RunnableBinding, RunnableBindingArgs } from "./base.cjs";
|
|
|
5
5
|
import { BaseChatMessageHistory, BaseListChatMessageHistory } from "../chat_history.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/runnables/history.d.ts
|
|
8
|
-
type GetSessionHistoryCallable = (
|
|
8
|
+
type GetSessionHistoryCallable = (
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
...args: Array<any>) => Promise<BaseChatMessageHistory | BaseListChatMessageHistory> | BaseChatMessageHistory | BaseListChatMessageHistory;
|
|
9
11
|
interface RunnableWithMessageHistoryInputs<RunInput, RunOutput> extends Omit<RunnableBindingArgs<RunInput, RunOutput>, "bound" | "config"> {
|
|
10
12
|
runnable: Runnable<RunInput, RunOutput>;
|
|
11
13
|
getMessageHistory: GetSessionHistoryCallable;
|
|
@@ -85,9 +87,15 @@ declare class RunnableWithMessageHistory<RunInput, RunOutput> extends RunnableBi
|
|
|
85
87
|
historyMessagesKey?: string;
|
|
86
88
|
getMessageHistory: GetSessionHistoryCallable;
|
|
87
89
|
constructor(fields: RunnableWithMessageHistoryInputs<RunInput, RunOutput>);
|
|
88
|
-
_getInputMessages(
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
_getInputMessages(
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
inputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
93
|
+
_getOutputMessages(
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
96
|
+
_enterHistory(
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
input: any, kwargs?: RunnableConfig): Promise<BaseMessage[]>;
|
|
91
99
|
_exitHistory(run: Run, config: RunnableConfig): Promise<void>;
|
|
92
100
|
_mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig<Record<string, any>>>>;
|
|
93
101
|
}
|
|
@@ -7,7 +7,9 @@ import "../messages/index.js";
|
|
|
7
7
|
import { BaseChatMessageHistory, BaseListChatMessageHistory } from "../chat_history.js";
|
|
8
8
|
|
|
9
9
|
//#region src/runnables/history.d.ts
|
|
10
|
-
type GetSessionHistoryCallable = (
|
|
10
|
+
type GetSessionHistoryCallable = (
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
...args: Array<any>) => Promise<BaseChatMessageHistory | BaseListChatMessageHistory> | BaseChatMessageHistory | BaseListChatMessageHistory;
|
|
11
13
|
interface RunnableWithMessageHistoryInputs<RunInput, RunOutput> extends Omit<RunnableBindingArgs<RunInput, RunOutput>, "bound" | "config"> {
|
|
12
14
|
runnable: Runnable<RunInput, RunOutput>;
|
|
13
15
|
getMessageHistory: GetSessionHistoryCallable;
|
|
@@ -87,9 +89,15 @@ declare class RunnableWithMessageHistory<RunInput, RunOutput> extends RunnableBi
|
|
|
87
89
|
historyMessagesKey?: string;
|
|
88
90
|
getMessageHistory: GetSessionHistoryCallable;
|
|
89
91
|
constructor(fields: RunnableWithMessageHistoryInputs<RunInput, RunOutput>);
|
|
90
|
-
_getInputMessages(
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
_getInputMessages(
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
inputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
95
|
+
_getOutputMessages(
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
98
|
+
_enterHistory(
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
input: any, kwargs?: RunnableConfig): Promise<BaseMessage[]>;
|
|
93
101
|
_exitHistory(run: Run, config: RunnableConfig): Promise<void>;
|
|
94
102
|
_mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig<Record<string, any>>>>;
|
|
95
103
|
}
|
|
@@ -2,6 +2,7 @@ import { RunnableConfig } from "./types.cjs";
|
|
|
2
2
|
import { Runnable, RunnableAssign, RunnableMapLike } from "./base.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/runnables/passthrough.d.ts
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((input: RunInput, config?: RunnableConfig) => void) | ((input: RunInput) => Promise<void>) | ((input: RunInput, config?: RunnableConfig) => Promise<void>);
|
|
6
7
|
/**
|
|
7
8
|
* A runnable to passthrough inputs unchanged or with additional keys.
|
|
@@ -29,6 +30,7 @@ type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((i
|
|
|
29
30
|
* );
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
34
|
declare class RunnablePassthrough<RunInput = any> extends Runnable<RunInput, RunInput> {
|
|
33
35
|
static lc_name(): string;
|
|
34
36
|
lc_namespace: string[];
|
|
@@ -3,6 +3,7 @@ import "./config.js";
|
|
|
3
3
|
import { Runnable, RunnableAssign, RunnableMapLike } from "./base.js";
|
|
4
4
|
|
|
5
5
|
//#region src/runnables/passthrough.d.ts
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((input: RunInput, config?: RunnableConfig) => void) | ((input: RunInput) => Promise<void>) | ((input: RunInput, config?: RunnableConfig) => Promise<void>);
|
|
7
8
|
/**
|
|
8
9
|
* A runnable to passthrough inputs unchanged or with additional keys.
|
|
@@ -30,6 +31,7 @@ type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((i
|
|
|
30
31
|
* );
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
35
|
declare class RunnablePassthrough<RunInput = any> extends Runnable<RunInput, RunInput> {
|
|
34
36
|
static lc_name(): string;
|
|
35
37
|
lc_namespace: string[];
|
|
@@ -19,7 +19,11 @@ type RunnableIOSchema = {
|
|
|
19
19
|
*
|
|
20
20
|
* Should not change on patch releases.
|
|
21
21
|
*/
|
|
22
|
-
interface RunnableInterface<
|
|
22
|
+
interface RunnableInterface<
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
RunInput = any,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends SerializableInterface {
|
|
23
27
|
lc_serializable: boolean;
|
|
24
28
|
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
25
29
|
batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
|
|
@@ -43,9 +47,12 @@ interface Node {
|
|
|
43
47
|
id: string;
|
|
44
48
|
name: string;
|
|
45
49
|
data: RunnableIOSchema | RunnableInterface;
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
51
|
metadata?: Record<string, any>;
|
|
47
52
|
}
|
|
48
|
-
interface RunnableConfig<
|
|
53
|
+
interface RunnableConfig<
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
49
56
|
/**
|
|
50
57
|
* Runtime values for attributes previously made configurable on this Runnable,
|
|
51
58
|
* or sub-Runnables.
|
|
@@ -19,7 +19,11 @@ type RunnableIOSchema = {
|
|
|
19
19
|
*
|
|
20
20
|
* Should not change on patch releases.
|
|
21
21
|
*/
|
|
22
|
-
interface RunnableInterface<
|
|
22
|
+
interface RunnableInterface<
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
RunInput = any,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends SerializableInterface {
|
|
23
27
|
lc_serializable: boolean;
|
|
24
28
|
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
25
29
|
batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
|
|
@@ -43,9 +47,12 @@ interface Node {
|
|
|
43
47
|
id: string;
|
|
44
48
|
name: string;
|
|
45
49
|
data: RunnableIOSchema | RunnableInterface;
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
51
|
metadata?: Record<string, any>;
|
|
47
52
|
}
|
|
48
|
-
interface RunnableConfig<
|
|
53
|
+
interface RunnableConfig<
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
49
56
|
/**
|
|
50
57
|
* Runtime values for attributes previously made configurable on this Runnable,
|
|
51
58
|
* or sub-Runnables.
|
|
@@ -102,6 +102,7 @@ declare function setContextVariable<T>(name: PropertyKey, value: T): void;
|
|
|
102
102
|
*
|
|
103
103
|
* @param name The name of the context variable.
|
|
104
104
|
*/
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
declare function getContextVariable<T = any>(name: PropertyKey): T | undefined;
|
|
106
107
|
/**
|
|
107
108
|
* Register a callback configure hook to automatically add callback handlers to all runs.
|
|
@@ -152,6 +153,7 @@ declare const registerConfigureHook: (config: ConfigureHook) => void;
|
|
|
152
153
|
type ConfigureHook = {
|
|
153
154
|
contextVar?: string;
|
|
154
155
|
inheritable?: boolean;
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
157
|
handlerClass?: new (...args: any[]) => BaseCallbackHandler;
|
|
156
158
|
envVar?: string;
|
|
157
159
|
};
|
|
@@ -102,6 +102,7 @@ declare function setContextVariable<T>(name: PropertyKey, value: T): void;
|
|
|
102
102
|
*
|
|
103
103
|
* @param name The name of the context variable.
|
|
104
104
|
*/
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
declare function getContextVariable<T = any>(name: PropertyKey): T | undefined;
|
|
106
107
|
/**
|
|
107
108
|
* Register a callback configure hook to automatically add callback handlers to all runs.
|
|
@@ -152,6 +153,7 @@ declare const registerConfigureHook: (config: ConfigureHook) => void;
|
|
|
152
153
|
type ConfigureHook = {
|
|
153
154
|
contextVar?: string;
|
|
154
155
|
inheritable?: boolean;
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
157
|
handlerClass?: new (...args: any[]) => BaseCallbackHandler;
|
|
156
158
|
envVar?: string;
|
|
157
159
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.cjs","names":["queue:
|
|
1
|
+
{"version":3,"file":"callbacks.cjs","names":["queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"]","PQueue: any","PQueueMod","promiseFn: () => Promise<T> | T | void","wait: boolean","getGlobalAsyncLocalStorageInstance","getDefaultLangChainClientSingleton"],"sources":["../../src/singletons/callbacks.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport PQueueMod from \"p-queue\";\nimport { getGlobalAsyncLocalStorageInstance } from \"./async_local_storage/globals.js\";\nimport { getDefaultLangChainClientSingleton } from \"./tracer.js\";\n\nlet queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n/**\n * Creates a queue using the p-queue library. The queue is configured to\n * auto-start and has a concurrency of 1, meaning it will process tasks\n * one at a time.\n */\nfunction createQueue() {\n const PQueue: any = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n return new PQueue({\n autoStart: true,\n concurrency: 1,\n });\n}\n\nexport function getQueue() {\n if (typeof queue === \"undefined\") {\n queue = createQueue();\n }\n return queue;\n}\n\n/**\n * Consume a promise, either adding it to the queue or waiting for it to resolve\n * @param promiseFn Promise to consume\n * @param wait Whether to wait for the promise to resolve or resolve immediately\n */\nexport async function consumeCallback<T>(\n promiseFn: () => Promise<T> | T | void,\n wait: boolean\n): Promise<void> {\n if (wait === true) {\n // Clear config since callbacks are not part of the root run\n // Avoid using global singleton due to circuluar dependency issues\n const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n if (asyncLocalStorageInstance !== undefined) {\n await asyncLocalStorageInstance.run(undefined, async () => promiseFn());\n } else {\n await promiseFn();\n }\n } else {\n queue = getQueue();\n // eslint-disable-next-line no-void\n void queue.add(async () => {\n const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n if (asyncLocalStorageInstance !== undefined) {\n await asyncLocalStorageInstance.run(undefined, async () => promiseFn());\n } else {\n await promiseFn();\n }\n });\n }\n}\n\n/**\n * Waits for all promises in the queue to resolve. If the queue is\n * undefined, it immediately resolves a promise.\n */\nexport async function awaitAllCallbacks(): Promise<void> {\n const defaultClient = getDefaultLangChainClientSingleton();\n await Promise.allSettled([\n typeof queue !== \"undefined\" ? queue.onIdle() : Promise.resolve(),\n defaultClient.awaitPendingTraceBatches(),\n ]);\n}\n"],"mappings":";;;;;;AAMA,IAAIA;;;;;;AAOJ,SAAS,cAAc;CACrB,MAAMC,SAAc,aAAaC,kBAAYA,gBAAU,UAAUA;AACjE,QAAO,IAAI,OAAO;EAChB,WAAW;EACX,aAAa;CACd;AACF;AAED,SAAgB,WAAW;AACzB,KAAI,OAAO,UAAU,aACnB,QAAQ,aAAa;AAEvB,QAAO;AACR;;;;;;AAOD,eAAsB,gBACpBC,WACAC,MACe;AACf,KAAI,SAAS,MAAM;EAGjB,MAAM,4BAA4BC,oDAAoC;AACtE,MAAI,8BAA8B,QAChC,MAAM,0BAA0B,IAAI,QAAW,YAAY,WAAW,CAAC;OAEvE,MAAM,WAAW;CAEpB,OAAM;EACL,QAAQ,UAAU;EAEb,MAAM,IAAI,YAAY;GACzB,MAAM,4BAA4BA,oDAAoC;AACtE,OAAI,8BAA8B,QAChC,MAAM,0BAA0B,IAAI,QAAW,YAAY,WAAW,CAAC;QAEvE,MAAM,WAAW;EAEpB,EAAC;CACH;AACF;;;;;AAMD,eAAsB,oBAAmC;CACvD,MAAM,gBAAgBC,mDAAoC;CAC1D,MAAM,QAAQ,WAAW,CACvB,OAAO,UAAU,cAAc,MAAM,QAAQ,GAAG,QAAQ,SAAS,EACjE,cAAc,0BAA0B,AACzC,EAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.js","names":["queue:
|
|
1
|
+
{"version":3,"file":"callbacks.js","names":["queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"]","PQueue: any","promiseFn: () => Promise<T> | T | void","wait: boolean"],"sources":["../../src/singletons/callbacks.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport PQueueMod from \"p-queue\";\nimport { getGlobalAsyncLocalStorageInstance } from \"./async_local_storage/globals.js\";\nimport { getDefaultLangChainClientSingleton } from \"./tracer.js\";\n\nlet queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n/**\n * Creates a queue using the p-queue library. The queue is configured to\n * auto-start and has a concurrency of 1, meaning it will process tasks\n * one at a time.\n */\nfunction createQueue() {\n const PQueue: any = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n return new PQueue({\n autoStart: true,\n concurrency: 1,\n });\n}\n\nexport function getQueue() {\n if (typeof queue === \"undefined\") {\n queue = createQueue();\n }\n return queue;\n}\n\n/**\n * Consume a promise, either adding it to the queue or waiting for it to resolve\n * @param promiseFn Promise to consume\n * @param wait Whether to wait for the promise to resolve or resolve immediately\n */\nexport async function consumeCallback<T>(\n promiseFn: () => Promise<T> | T | void,\n wait: boolean\n): Promise<void> {\n if (wait === true) {\n // Clear config since callbacks are not part of the root run\n // Avoid using global singleton due to circuluar dependency issues\n const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n if (asyncLocalStorageInstance !== undefined) {\n await asyncLocalStorageInstance.run(undefined, async () => promiseFn());\n } else {\n await promiseFn();\n }\n } else {\n queue = getQueue();\n // eslint-disable-next-line no-void\n void queue.add(async () => {\n const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n if (asyncLocalStorageInstance !== undefined) {\n await asyncLocalStorageInstance.run(undefined, async () => promiseFn());\n } else {\n await promiseFn();\n }\n });\n }\n}\n\n/**\n * Waits for all promises in the queue to resolve. If the queue is\n * undefined, it immediately resolves a promise.\n */\nexport async function awaitAllCallbacks(): Promise<void> {\n const defaultClient = getDefaultLangChainClientSingleton();\n await Promise.allSettled([\n typeof queue !== \"undefined\" ? queue.onIdle() : Promise.resolve(),\n defaultClient.awaitPendingTraceBatches(),\n ]);\n}\n"],"mappings":";;;;;AAMA,IAAIA;;;;;;AAOJ,SAAS,cAAc;CACrB,MAAMC,SAAc,aAAa,YAAY,UAAU,UAAU;AACjE,QAAO,IAAI,OAAO;EAChB,WAAW;EACX,aAAa;CACd;AACF;AAED,SAAgB,WAAW;AACzB,KAAI,OAAO,UAAU,aACnB,QAAQ,aAAa;AAEvB,QAAO;AACR;;;;;;AAOD,eAAsB,gBACpBC,WACAC,MACe;AACf,KAAI,SAAS,MAAM;EAGjB,MAAM,4BAA4B,oCAAoC;AACtE,MAAI,8BAA8B,QAChC,MAAM,0BAA0B,IAAI,QAAW,YAAY,WAAW,CAAC;OAEvE,MAAM,WAAW;CAEpB,OAAM;EACL,QAAQ,UAAU;EAEb,MAAM,IAAI,YAAY;GACzB,MAAM,4BAA4B,oCAAoC;AACtE,OAAI,8BAA8B,QAChC,MAAM,0BAA0B,IAAI,QAAW,YAAY,WAAW,CAAC;QAEvE,MAAM,WAAW;EAEpB,EAAC;CACH;AACF;;;;;AAMD,eAAsB,oBAAmC;CACvD,MAAM,gBAAgB,oCAAoC;CAC1D,MAAM,QAAQ,WAAW,CACvB,OAAO,UAAU,cAAc,MAAM,QAAQ,GAAG,QAAQ,SAAS,EACjE,cAAc,0BAA0B,AACzC,EAAC;AACH"}
|
package/dist/stores.d.cts
CHANGED
|
@@ -50,6 +50,7 @@ declare abstract class BaseStore<K, V> extends Serializable {
|
|
|
50
50
|
* await store.mdelete(await store.yieldKeys("message:id:").toArray());
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
54
|
declare class InMemoryStore<T = any> extends BaseStore<string, T> {
|
|
54
55
|
lc_namespace: string[];
|
|
55
56
|
protected store: Record<string, T>;
|
package/dist/stores.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare abstract class BaseStore<K, V> extends Serializable {
|
|
|
50
50
|
* await store.mdelete(await store.yieldKeys("message:id:").toArray());
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
54
|
declare class InMemoryStore<T = any> extends BaseStore<string, T> {
|
|
54
55
|
lc_namespace: string[];
|
|
55
56
|
protected store: Record<string, T>;
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the provided argument is an object and not an array.
|
|
4
4
|
*/
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
declare function isObject(obj: any): obj is object;
|
|
6
7
|
/**
|
|
7
8
|
* Checks if a provided filter is empty. The filter can be a function, an
|
|
8
9
|
* object, a string, or undefined.
|
|
9
10
|
*/
|
|
10
|
-
declare function isFilterEmpty(
|
|
11
|
+
declare function isFilterEmpty(
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
filter: ((q: any) => any) | object | string | undefined): filter is undefined;
|
|
11
14
|
/**
|
|
12
15
|
* Checks if the provided value is an integer.
|
|
13
16
|
*/
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the provided argument is an object and not an array.
|
|
4
4
|
*/
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
declare function isObject(obj: any): obj is object;
|
|
6
7
|
/**
|
|
7
8
|
* Checks if a provided filter is empty. The filter can be a function, an
|
|
8
9
|
* object, a string, or undefined.
|
|
9
10
|
*/
|
|
10
|
-
declare function isFilterEmpty(
|
|
11
|
+
declare function isFilterEmpty(
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
filter: ((q: any) => any) | object | string | undefined): filter is undefined;
|
|
11
14
|
/**
|
|
12
15
|
* Checks if the provided value is an integer.
|
|
13
16
|
*/
|
package/dist/tools/index.d.cts
CHANGED
|
@@ -94,6 +94,7 @@ declare abstract class Tool<ToolOutputT = ToolOutputType> extends StructuredTool
|
|
|
94
94
|
* @param callbacks Optional callbacks for the tool.
|
|
95
95
|
* @returns A Promise that resolves with a string.
|
|
96
96
|
*/
|
|
97
|
+
// Match the base class signature including the generics and conditional return type
|
|
97
98
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
@@ -110,7 +111,9 @@ declare class DynamicTool<ToolOutputT = ToolOutputType> extends Tool<ToolOutputT
|
|
|
110
111
|
*/
|
|
111
112
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
112
113
|
/** @ignore */
|
|
113
|
-
_call(input: string,
|
|
114
|
+
_call(input: string,
|
|
115
|
+
// DynamicTool's _call specifically expects a string after schema transformation
|
|
116
|
+
runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
116
119
|
* A tool that can be created dynamically from a function, name, and
|
|
@@ -131,6 +134,7 @@ declare class DynamicStructuredTool<SchemaT = ToolInputSchemaBase, SchemaOutputT
|
|
|
131
134
|
/**
|
|
132
135
|
* @deprecated Use .invoke() instead. Will be removed in 0.3.0.
|
|
133
136
|
*/
|
|
137
|
+
// Match the base class signature
|
|
134
138
|
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig, /** @deprecated */
|
|
135
139
|
tags?: string[]): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
136
140
|
protected _call(arg: Parameters<DynamicStructuredToolInput<SchemaT, SchemaOutputT>["func"]>[0], runManager?: CallbackManagerForToolRun, parentConfig?: RunnableConfig): Promise<ToolOutputT>;
|
|
@@ -208,6 +212,7 @@ declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZ
|
|
|
208
212
|
declare function tool<SchemaT extends ZodObjectV4, SchemaOutputT = InferInteropZodOutput<SchemaT>, SchemaInputT = InferInteropZodInput<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<SchemaOutputT, ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
|
209
213
|
declare function tool<SchemaT extends JsonSchema7Type, SchemaOutputT = ToolInputSchemaOutputType<SchemaT>, SchemaInputT = ToolInputSchemaInputType<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<Parameters<DynamicStructuredToolInput<SchemaT>["func"]>[0], ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
|
210
214
|
declare function tool<SchemaT extends InteropZodObject | InteropZodType<string> | JsonSchema7Type = InteropZodObject, SchemaOutputT = ToolInputSchemaOutputType<SchemaT>, SchemaInputT = ToolInputSchemaInputType<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<SchemaOutputT, ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT> | DynamicTool<ToolOutputT>;
|
|
215
|
+
// Overloads with ToolRuntime as CallOptions
|
|
211
216
|
declare function tool<SchemaT extends ZodStringV3, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: InferInteropZodOutput<SchemaT>, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicTool<ToolOutputT>;
|
|
212
217
|
declare function tool<SchemaT extends ZodStringV4, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: InferInteropZodOutput<SchemaT>, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicTool<ToolOutputT>;
|
|
213
218
|
declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZodOutput<SchemaT>, SchemaInputT = InferInteropZodInput<SchemaT>, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: SchemaOutputT, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ declare abstract class Tool<ToolOutputT = ToolOutputType> extends StructuredTool
|
|
|
96
96
|
* @param callbacks Optional callbacks for the tool.
|
|
97
97
|
* @returns A Promise that resolves with a string.
|
|
98
98
|
*/
|
|
99
|
+
// Match the base class signature including the generics and conditional return type
|
|
99
100
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
@@ -112,7 +113,9 @@ declare class DynamicTool<ToolOutputT = ToolOutputType> extends Tool<ToolOutputT
|
|
|
112
113
|
*/
|
|
113
114
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
114
115
|
/** @ignore */
|
|
115
|
-
_call(input: string,
|
|
116
|
+
_call(input: string,
|
|
117
|
+
// DynamicTool's _call specifically expects a string after schema transformation
|
|
118
|
+
runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
116
119
|
}
|
|
117
120
|
/**
|
|
118
121
|
* A tool that can be created dynamically from a function, name, and
|
|
@@ -133,6 +136,7 @@ declare class DynamicStructuredTool<SchemaT = ToolInputSchemaBase, SchemaOutputT
|
|
|
133
136
|
/**
|
|
134
137
|
* @deprecated Use .invoke() instead. Will be removed in 0.3.0.
|
|
135
138
|
*/
|
|
139
|
+
// Match the base class signature
|
|
136
140
|
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig, /** @deprecated */
|
|
137
141
|
tags?: string[]): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
138
142
|
protected _call(arg: Parameters<DynamicStructuredToolInput<SchemaT, SchemaOutputT>["func"]>[0], runManager?: CallbackManagerForToolRun, parentConfig?: RunnableConfig): Promise<ToolOutputT>;
|
|
@@ -210,6 +214,7 @@ declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZ
|
|
|
210
214
|
declare function tool<SchemaT extends ZodObjectV4, SchemaOutputT = InferInteropZodOutput<SchemaT>, SchemaInputT = InferInteropZodInput<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<SchemaOutputT, ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
|
211
215
|
declare function tool<SchemaT extends JsonSchema7Type, SchemaOutputT = ToolInputSchemaOutputType<SchemaT>, SchemaInputT = ToolInputSchemaInputType<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<Parameters<DynamicStructuredToolInput<SchemaT>["func"]>[0], ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
|
212
216
|
declare function tool<SchemaT extends InteropZodObject | InteropZodType<string> | JsonSchema7Type = InteropZodObject, SchemaOutputT = ToolInputSchemaOutputType<SchemaT>, SchemaInputT = ToolInputSchemaInputType<SchemaT>, ToolOutputT = ToolOutputType>(func: RunnableFunc<SchemaOutputT, ToolOutputT, ToolRunnableConfig>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT> | DynamicTool<ToolOutputT>;
|
|
217
|
+
// Overloads with ToolRuntime as CallOptions
|
|
213
218
|
declare function tool<SchemaT extends ZodStringV3, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: InferInteropZodOutput<SchemaT>, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicTool<ToolOutputT>;
|
|
214
219
|
declare function tool<SchemaT extends ZodStringV4, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: InferInteropZodOutput<SchemaT>, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicTool<ToolOutputT>;
|
|
215
220
|
declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZodOutput<SchemaT>, SchemaInputT = InferInteropZodInput<SchemaT>, ToolOutputT = ToolOutputType, TState = unknown, TContext = unknown>(func: (input: SchemaOutputT, runtime: ToolRuntime<TState, TContext>) => ToolOutputT | Promise<ToolOutputT>, fields: ToolWrapperParams<SchemaT>): DynamicStructuredTool<SchemaT, SchemaOutputT, SchemaInputT, ToolOutputT>;
|
package/dist/tools/types.d.cts
CHANGED
|
@@ -11,7 +11,9 @@ import { z } from "zod/v3";
|
|
|
11
11
|
|
|
12
12
|
//#region src/tools/types.d.ts
|
|
13
13
|
type ResponseFormat = "content" | "content_and_artifact" | string;
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
type ToolOutputType = any;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
17
|
type ContentAndArtifact = [MessageContent, any];
|
|
16
18
|
/**
|
|
17
19
|
* Conditional type that determines the return type of the {@link StructuredTool.invoke} method.
|
|
@@ -73,7 +75,11 @@ interface ToolParams extends BaseLangChainParams {
|
|
|
73
75
|
*/
|
|
74
76
|
extras?: Record<string, unknown>;
|
|
75
77
|
}
|
|
76
|
-
type ToolRunnableConfig<
|
|
78
|
+
type ToolRunnableConfig<
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
ConfigurableFieldType extends Record<string, any> = Record<string, any>,
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
ContextSchema = any> = RunnableConfig<ConfigurableFieldType> & {
|
|
77
83
|
toolCall?: ToolCall;
|
|
78
84
|
context?: ContextSchema;
|
|
79
85
|
};
|
|
@@ -128,7 +134,9 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
|
|
|
128
134
|
* This is primarily used for creating simple string-based tools where the LLM
|
|
129
135
|
* only needs to provide a single text value as input to the tool.
|
|
130
136
|
*/
|
|
131
|
-
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
137
|
+
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
any>;
|
|
132
140
|
/**
|
|
133
141
|
* Interface that defines the shape of a LangChain structured tool.
|
|
134
142
|
*
|
|
@@ -203,7 +211,9 @@ interface ToolInterface<SchemaT = StringInputToolSchema, SchemaInputT = ToolInpu
|
|
|
203
211
|
* @param callbacks Optional callbacks for the tool.
|
|
204
212
|
* @returns A Promise that resolves with a string.
|
|
205
213
|
*/
|
|
206
|
-
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(
|
|
214
|
+
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(
|
|
215
|
+
// TODO: shouldn't this be narrowed based on SchemaT?
|
|
216
|
+
arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
207
217
|
}
|
|
208
218
|
/**
|
|
209
219
|
* Base interface for the input parameters of the {@link DynamicTool} and
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ import { z } from "zod/v3";
|
|
|
13
13
|
|
|
14
14
|
//#region src/tools/types.d.ts
|
|
15
15
|
type ResponseFormat = "content" | "content_and_artifact" | string;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
type ToolOutputType = any;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
19
|
type ContentAndArtifact = [MessageContent, any];
|
|
18
20
|
/**
|
|
19
21
|
* Conditional type that determines the return type of the {@link StructuredTool.invoke} method.
|
|
@@ -75,7 +77,11 @@ interface ToolParams extends BaseLangChainParams {
|
|
|
75
77
|
*/
|
|
76
78
|
extras?: Record<string, unknown>;
|
|
77
79
|
}
|
|
78
|
-
type ToolRunnableConfig<
|
|
80
|
+
type ToolRunnableConfig<
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
ConfigurableFieldType extends Record<string, any> = Record<string, any>,
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
ContextSchema = any> = RunnableConfig<ConfigurableFieldType> & {
|
|
79
85
|
toolCall?: ToolCall;
|
|
80
86
|
context?: ContextSchema;
|
|
81
87
|
};
|
|
@@ -130,7 +136,9 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
|
|
|
130
136
|
* This is primarily used for creating simple string-based tools where the LLM
|
|
131
137
|
* only needs to provide a single text value as input to the tool.
|
|
132
138
|
*/
|
|
133
|
-
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
139
|
+
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
+
any>;
|
|
134
142
|
/**
|
|
135
143
|
* Interface that defines the shape of a LangChain structured tool.
|
|
136
144
|
*
|
|
@@ -205,7 +213,9 @@ interface ToolInterface<SchemaT = StringInputToolSchema, SchemaInputT = ToolInpu
|
|
|
205
213
|
* @param callbacks Optional callbacks for the tool.
|
|
206
214
|
* @returns A Promise that resolves with a string.
|
|
207
215
|
*/
|
|
208
|
-
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(
|
|
216
|
+
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(
|
|
217
|
+
// TODO: shouldn't this be narrowed based on SchemaT?
|
|
218
|
+
arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
209
219
|
}
|
|
210
220
|
/**
|
|
211
221
|
* Base interface for the input parameters of the {@link DynamicTool} and
|