@langchain/core 1.1.1 → 1.1.3
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 +16 -0
- package/dist/agents.d.cts +0 -2
- package/dist/agents.d.ts +0 -2
- package/dist/callbacks/base.d.cts +22 -60
- package/dist/callbacks/base.d.ts +22 -60
- package/dist/callbacks/dispatch/index.d.cts +1 -3
- package/dist/callbacks/dispatch/index.d.ts +1 -3
- package/dist/callbacks/dispatch/web.d.cts +1 -3
- package/dist/callbacks/dispatch/web.d.ts +1 -3
- package/dist/callbacks/manager.d.cts +2 -12
- package/dist/callbacks/manager.d.ts +2 -12
- package/dist/chat_history.cjs +1 -1
- package/dist/chat_history.d.cts +0 -1
- package/dist/chat_history.d.ts +0 -1
- package/dist/chat_history.js +1 -1
- package/dist/document_loaders/langsmith.d.cts +0 -3
- package/dist/document_loaders/langsmith.d.ts +0 -3
- package/dist/documents/document.d.cts +3 -12
- package/dist/documents/document.d.ts +3 -12
- 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 +0 -1
- package/dist/indexing/base.d.ts +0 -1
- package/dist/indexing/record_manager.d.cts +0 -1
- package/dist/indexing/record_manager.d.ts +0 -1
- package/dist/language_models/base.d.cts +8 -38
- package/dist/language_models/base.d.ts +8 -38
- package/dist/language_models/chat_models.cjs +1 -1
- package/dist/language_models/chat_models.d.cts +6 -33
- package/dist/language_models/chat_models.d.ts +6 -33
- package/dist/language_models/chat_models.js +1 -1
- package/dist/language_models/llms.d.cts +0 -6
- package/dist/language_models/llms.d.ts +0 -6
- package/dist/load/import_type.d.cts +0 -1
- package/dist/load/import_type.d.ts +0 -1
- package/dist/load/map_keys.cjs +4 -5
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.d.cts +0 -1
- package/dist/load/map_keys.d.ts +0 -1
- package/dist/load/map_keys.js +3 -3
- package/dist/load/map_keys.js.map +1 -1
- package/dist/load/serializable.d.cts +0 -1
- package/dist/load/serializable.d.ts +0 -1
- package/dist/memory.d.cts +0 -3
- package/dist/memory.d.ts +0 -3
- package/dist/messages/ai.cjs +6 -48
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.js +6 -48
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +3 -2
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +1 -13
- package/dist/messages/base.d.ts +1 -13
- package/dist/messages/base.js +3 -2
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/content/data.d.cts +2 -7
- package/dist/messages/content/data.d.ts +2 -7
- package/dist/messages/content/index.d.cts +1 -4
- package/dist/messages/content/index.d.ts +1 -4
- package/dist/messages/content/multimodal.d.cts +0 -1
- package/dist/messages/content/multimodal.d.ts +0 -1
- package/dist/messages/content/tools.d.cts +0 -1
- package/dist/messages/content/tools.d.ts +0 -1
- package/dist/messages/index.cjs +4 -2
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.js +5 -4
- package/dist/messages/tool.d.cts +2 -9
- package/dist/messages/tool.d.ts +2 -9
- package/dist/messages/transformers.cjs +2 -2
- package/dist/messages/transformers.d.cts +0 -3
- package/dist/messages/transformers.d.ts +0 -3
- package/dist/messages/transformers.js +2 -2
- package/dist/messages/utils.cjs +77 -4
- package/dist/messages/utils.cjs.map +1 -1
- package/dist/messages/utils.d.cts +35 -7
- package/dist/messages/utils.d.ts +35 -7
- package/dist/messages/utils.js +77 -5
- package/dist/messages/utils.js.map +1 -1
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +169 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +168 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +1 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +122 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +121 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +1 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +18 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +17 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs +27 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js +26 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +1 -0
- package/dist/output_parsers/json.cjs.map +1 -1
- package/dist/output_parsers/json.d.cts +1 -5
- package/dist/output_parsers/json.d.ts +1 -5
- package/dist/output_parsers/json.js.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +2 -6
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +2 -6
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -34
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -34
- package/dist/output_parsers/transform.d.cts +0 -1
- package/dist/output_parsers/transform.d.ts +0 -1
- package/dist/outputs.d.cts +0 -6
- package/dist/outputs.d.ts +0 -6
- package/dist/prompts/base.d.cts +2 -10
- package/dist/prompts/base.d.ts +2 -10
- package/dist/prompts/chat.cjs +2 -2
- package/dist/prompts/chat.d.cts +13 -51
- package/dist/prompts/chat.d.ts +13 -51
- package/dist/prompts/chat.js +2 -2
- package/dist/prompts/few_shot.d.cts +1 -5
- package/dist/prompts/few_shot.d.ts +1 -5
- package/dist/prompts/image.d.cts +2 -10
- package/dist/prompts/image.d.ts +2 -10
- package/dist/prompts/prompt.d.cts +4 -15
- package/dist/prompts/prompt.d.ts +4 -16
- package/dist/prompts/serde.d.cts +0 -1
- package/dist/prompts/serde.d.ts +0 -1
- package/dist/prompts/string.d.cts +1 -5
- package/dist/prompts/string.d.ts +1 -5
- package/dist/prompts/structured.d.cts +3 -16
- package/dist/prompts/structured.d.ts +3 -16
- package/dist/retrievers/document_compressors/index.d.cts +0 -1
- package/dist/retrievers/document_compressors/index.d.ts +0 -1
- package/dist/retrievers/index.d.cts +2 -6
- package/dist/retrievers/index.d.ts +2 -6
- package/dist/runnables/base.cjs +7 -7
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +12 -64
- package/dist/runnables/base.d.ts +12 -64
- package/dist/runnables/base.js +1 -1
- package/dist/runnables/branch.d.cts +0 -2
- package/dist/runnables/branch.d.ts +0 -2
- package/dist/runnables/config.d.cts +0 -1
- package/dist/runnables/config.d.ts +0 -1
- package/dist/runnables/graph.d.cts +1 -5
- package/dist/runnables/graph.d.ts +1 -5
- package/dist/runnables/graph_mermaid.cjs +2 -1
- package/dist/runnables/graph_mermaid.cjs.map +1 -1
- package/dist/runnables/graph_mermaid.js +3 -1
- package/dist/runnables/graph_mermaid.js.map +1 -1
- package/dist/runnables/history.cjs +1 -1
- package/dist/runnables/history.d.cts +4 -12
- package/dist/runnables/history.d.ts +4 -12
- package/dist/runnables/history.js +1 -1
- package/dist/runnables/passthrough.d.cts +0 -2
- package/dist/runnables/passthrough.d.ts +0 -2
- package/dist/runnables/router.d.cts +0 -1
- package/dist/runnables/router.d.ts +0 -1
- package/dist/runnables/types.d.cts +2 -9
- package/dist/runnables/types.d.ts +2 -9
- package/dist/runnables/utils.cjs +5 -0
- package/dist/runnables/utils.cjs.map +1 -1
- package/dist/runnables/utils.js +5 -1
- package/dist/runnables/utils.js.map +1 -1
- package/dist/singletons/async_local_storage/context.d.cts +0 -2
- package/dist/singletons/async_local_storage/context.d.ts +0 -2
- package/dist/singletons/async_local_storage/globals.d.cts +0 -1
- package/dist/singletons/async_local_storage/globals.d.ts +0 -1
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/stores.d.cts +0 -1
- package/dist/stores.d.ts +0 -1
- package/dist/structured_query/utils.d.cts +1 -4
- package/dist/structured_query/utils.d.ts +1 -4
- package/dist/tools/index.d.cts +1 -6
- package/dist/tools/index.d.ts +1 -6
- package/dist/tools/types.d.cts +3 -13
- package/dist/tools/types.d.ts +3 -13
- package/dist/tracers/base.d.cts +1 -20
- package/dist/tracers/base.d.ts +1 -20
- package/dist/tracers/console.cjs +3 -3
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.d.cts +0 -2
- package/dist/tracers/console.d.ts +0 -2
- package/dist/tracers/console.js +3 -3
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.d.cts +0 -4
- package/dist/tracers/event_stream.d.ts +0 -4
- package/dist/tracers/log_stream.d.cts +0 -6
- package/dist/tracers/log_stream.d.ts +0 -6
- package/dist/types/_internal.d.cts +0 -3
- package/dist/types/_internal.d.ts +0 -3
- package/dist/types/type-utils.d.cts +0 -2
- package/dist/types/type-utils.d.ts +0 -2
- package/dist/utils/async_caller.cjs +2 -7
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts +0 -3
- package/dist/utils/async_caller.d.ts +0 -3
- package/dist/utils/async_caller.js +1 -6
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/env.d.cts +0 -4
- package/dist/utils/env.d.ts +0 -4
- package/dist/utils/event_source_parse.d.cts +1 -4
- package/dist/utils/event_source_parse.d.ts +1 -4
- package/dist/utils/function_calling.d.cts +1 -3
- package/dist/utils/function_calling.d.ts +1 -3
- package/dist/utils/json.cjs +182 -22
- package/dist/utils/json.cjs.map +1 -1
- package/dist/utils/json.d.cts +1 -3
- package/dist/utils/json.d.ts +1 -3
- package/dist/utils/json.js +182 -22
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/stream.d.cts +1 -13
- package/dist/utils/stream.d.ts +1 -13
- package/dist/utils/testing/chat_models.d.cts +3 -11
- package/dist/utils/testing/chat_models.d.ts +3 -11
- package/dist/utils/testing/message_history.cjs +1 -1
- package/dist/utils/testing/message_history.js +1 -1
- package/dist/utils/testing/retrievers.d.cts +1 -3
- package/dist/utils/testing/retrievers.d.ts +1 -3
- package/dist/utils/testing/vectorstores.d.cts +0 -1
- package/dist/utils/testing/vectorstores.d.ts +0 -1
- package/dist/utils/types/index.cjs +4 -0
- package/dist/utils/types/index.d.cts +2 -4
- package/dist/utils/types/index.d.ts +2 -4
- package/dist/utils/types/index.js +4 -2
- package/dist/utils/types/zod.cjs +24 -0
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.d.cts +4 -4
- package/dist/utils/types/zod.d.ts +4 -4
- package/dist/utils/types/zod.js +23 -1
- package/dist/utils/types/zod.js.map +1 -1
- package/dist/vectorstores.d.cts +5 -17
- package/dist/vectorstores.d.ts +5 -17
- package/package.json +6 -6
|
@@ -7,9 +7,7 @@ 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 = (
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
...args: Array<any>) => Promise<BaseChatMessageHistory | BaseListChatMessageHistory> | BaseChatMessageHistory | BaseListChatMessageHistory;
|
|
10
|
+
type GetSessionHistoryCallable = (...args: Array<any>) => Promise<BaseChatMessageHistory | BaseListChatMessageHistory> | BaseChatMessageHistory | BaseListChatMessageHistory;
|
|
13
11
|
interface RunnableWithMessageHistoryInputs<RunInput, RunOutput> extends Omit<RunnableBindingArgs<RunInput, RunOutput>, "bound" | "config"> {
|
|
14
12
|
runnable: Runnable<RunInput, RunOutput>;
|
|
15
13
|
getMessageHistory: GetSessionHistoryCallable;
|
|
@@ -89,15 +87,9 @@ declare class RunnableWithMessageHistory<RunInput, RunOutput> extends RunnableBi
|
|
|
89
87
|
historyMessagesKey?: string;
|
|
90
88
|
getMessageHistory: GetSessionHistoryCallable;
|
|
91
89
|
constructor(fields: RunnableWithMessageHistoryInputs<RunInput, RunOutput>);
|
|
92
|
-
_getInputMessages(
|
|
93
|
-
|
|
94
|
-
|
|
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[]>;
|
|
90
|
+
_getInputMessages(inputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
91
|
+
_getOutputMessages(outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
|
|
92
|
+
_enterHistory(input: any, kwargs?: RunnableConfig): Promise<BaseMessage[]>;
|
|
101
93
|
_exitHistory(run: Run, config: RunnableConfig): Promise<void>;
|
|
102
94
|
_mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig<Record<string, any>>>>;
|
|
103
95
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isBaseMessage } from "../messages/base.js";
|
|
2
|
-
import { AIMessage } from "../messages/ai.js";
|
|
3
2
|
import { HumanMessage } from "../messages/human.js";
|
|
3
|
+
import { AIMessage } from "../messages/ai.js";
|
|
4
4
|
import { RunnableBinding, RunnableLambda } from "./base.js";
|
|
5
5
|
import "../messages/index.js";
|
|
6
6
|
import { RunnablePassthrough } from "./passthrough.js";
|
|
@@ -2,7 +2,6 @@ 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
|
|
6
5
|
type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((input: RunInput, config?: RunnableConfig) => void) | ((input: RunInput) => Promise<void>) | ((input: RunInput, config?: RunnableConfig) => Promise<void>);
|
|
7
6
|
/**
|
|
8
7
|
* A runnable to passthrough inputs unchanged or with additional keys.
|
|
@@ -30,7 +29,6 @@ type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((i
|
|
|
30
29
|
* );
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
32
|
declare class RunnablePassthrough<RunInput = any> extends Runnable<RunInput, RunInput> {
|
|
35
33
|
static lc_name(): string;
|
|
36
34
|
lc_namespace: string[];
|
|
@@ -3,7 +3,6 @@ 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
|
|
7
6
|
type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((input: RunInput, config?: RunnableConfig) => void) | ((input: RunInput) => Promise<void>) | ((input: RunInput, config?: RunnableConfig) => Promise<void>);
|
|
8
7
|
/**
|
|
9
8
|
* A runnable to passthrough inputs unchanged or with additional keys.
|
|
@@ -31,7 +30,6 @@ type RunnablePassthroughFunc<RunInput = any> = ((input: RunInput) => void) | ((i
|
|
|
31
30
|
* );
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
33
|
declare class RunnablePassthrough<RunInput = any> extends Runnable<RunInput, RunInput> {
|
|
36
34
|
static lc_name(): string;
|
|
37
35
|
lc_namespace: string[];
|
|
@@ -19,11 +19,7 @@ type RunnableIOSchema = {
|
|
|
19
19
|
*
|
|
20
20
|
* Should not change on patch releases.
|
|
21
21
|
*/
|
|
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 {
|
|
22
|
+
interface RunnableInterface<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends SerializableInterface {
|
|
27
23
|
lc_serializable: boolean;
|
|
28
24
|
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
29
25
|
batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
|
|
@@ -47,12 +43,9 @@ interface Node {
|
|
|
47
43
|
id: string;
|
|
48
44
|
name: string;
|
|
49
45
|
data: RunnableIOSchema | RunnableInterface;
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
46
|
metadata?: Record<string, any>;
|
|
52
47
|
}
|
|
53
|
-
interface RunnableConfig<
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
48
|
+
interface RunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
56
49
|
/**
|
|
57
50
|
* Runtime values for attributes previously made configurable on this Runnable,
|
|
58
51
|
* or sub-Runnables.
|
|
@@ -19,11 +19,7 @@ type RunnableIOSchema = {
|
|
|
19
19
|
*
|
|
20
20
|
* Should not change on patch releases.
|
|
21
21
|
*/
|
|
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 {
|
|
22
|
+
interface RunnableInterface<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends SerializableInterface {
|
|
27
23
|
lc_serializable: boolean;
|
|
28
24
|
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
29
25
|
batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
|
|
@@ -47,12 +43,9 @@ interface Node {
|
|
|
47
43
|
id: string;
|
|
48
44
|
name: string;
|
|
49
45
|
data: RunnableIOSchema | RunnableInterface;
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
46
|
metadata?: Record<string, any>;
|
|
52
47
|
}
|
|
53
|
-
interface RunnableConfig<
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
48
|
+
interface RunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
|
|
56
49
|
/**
|
|
57
50
|
* Runtime values for attributes previously made configurable on this Runnable,
|
|
58
51
|
* or sub-Runnables.
|
package/dist/runnables/utils.cjs
CHANGED
|
@@ -37,8 +37,13 @@ var _RootEventFilter = class {
|
|
|
37
37
|
return include;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
+
const toBase64Url = (str) => {
|
|
41
|
+
const encoded = btoa(str);
|
|
42
|
+
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
43
|
+
};
|
|
40
44
|
|
|
41
45
|
//#endregion
|
|
42
46
|
exports._RootEventFilter = _RootEventFilter;
|
|
43
47
|
exports.isRunnableInterface = isRunnableInterface;
|
|
48
|
+
exports.toBase64Url = toBase64Url;
|
|
44
49
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["thing: any","fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }","event: StreamEvent","rootType: string"],"sources":["../../src/runnables/utils.ts"],"sourcesContent":["import { StreamEvent } from \"../tracers/event_stream.js\";\nimport type { RunnableInterface } from \"./types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isRunnableInterface(thing: any): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n}\n\n/**\n * Utility to filter the root event in the streamEvents implementation.\n * This is simply binding the arguments to the namespace to make save on\n * a bit of typing in the streamEvents implementation.\n *\n * TODO: Refactor and remove.\n */\nexport class _RootEventFilter {\n includeNames?: string[];\n\n includeTypes?: string[];\n\n includeTags?: string[];\n\n excludeNames?: string[];\n\n excludeTypes?: string[];\n\n excludeTags?: string[];\n\n constructor(fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }) {\n this.includeNames = fields.includeNames;\n this.includeTypes = fields.includeTypes;\n this.includeTags = fields.includeTags;\n this.excludeNames = fields.excludeNames;\n this.excludeTypes = fields.excludeTypes;\n this.excludeTags = fields.excludeTags;\n }\n\n includeEvent(event: StreamEvent, rootType: string): boolean {\n let include =\n this.includeNames === undefined &&\n this.includeTypes === undefined &&\n this.includeTags === undefined;\n const eventTags = event.tags ?? [];\n\n if (this.includeNames !== undefined) {\n include = include || this.includeNames.includes(event.name);\n }\n if (this.includeTypes !== undefined) {\n include = include || this.includeTypes.includes(rootType);\n }\n if (this.includeTags !== undefined) {\n include =\n include || eventTags.some((tag) => this.includeTags?.includes(tag));\n }\n\n if (this.excludeNames !== undefined) {\n include = include && !this.excludeNames.includes(event.name);\n }\n if (this.excludeTypes !== undefined) {\n include = include && !this.excludeTypes.includes(rootType);\n }\n if (this.excludeTags !== undefined) {\n include =\n include && eventTags.every((tag) => !this.excludeTags?.includes(tag));\n }\n\n return include;\n }\n}\n"],"mappings":";;AAIA,SAAgB,oBAAoBA,OAAwC;AAC1E,QAAO,QAAQ,MAAM,cAAc;AACpC;;;;;;;;AASD,IAAa,mBAAb,MAA8B;CAC5B;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAYC,QAOT;EACD,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;EAC1B,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;CAC3B;CAED,aAAaC,OAAoBC,UAA2B;EAC1D,IAAI,UACF,KAAK,iBAAiB,UACtB,KAAK,iBAAiB,UACtB,KAAK,gBAAgB;EACvB,MAAM,YAAY,MAAM,QAAQ,CAAE;AAElC,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,MAAM,KAAK;AAE7D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,SAAS;AAE3D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,KAAK,CAAC,QAAQ,KAAK,aAAa,SAAS,IAAI,CAAC;AAGvE,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,MAAM,KAAK;AAE9D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,SAAS;AAE5D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAa,SAAS,IAAI,CAAC;AAGzE,SAAO;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["thing: any","fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }","event: StreamEvent","rootType: string","str: string"],"sources":["../../src/runnables/utils.ts"],"sourcesContent":["import { StreamEvent } from \"../tracers/event_stream.js\";\nimport type { RunnableInterface } from \"./types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isRunnableInterface(thing: any): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n}\n\n/**\n * Utility to filter the root event in the streamEvents implementation.\n * This is simply binding the arguments to the namespace to make save on\n * a bit of typing in the streamEvents implementation.\n *\n * TODO: Refactor and remove.\n */\nexport class _RootEventFilter {\n includeNames?: string[];\n\n includeTypes?: string[];\n\n includeTags?: string[];\n\n excludeNames?: string[];\n\n excludeTypes?: string[];\n\n excludeTags?: string[];\n\n constructor(fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }) {\n this.includeNames = fields.includeNames;\n this.includeTypes = fields.includeTypes;\n this.includeTags = fields.includeTags;\n this.excludeNames = fields.excludeNames;\n this.excludeTypes = fields.excludeTypes;\n this.excludeTags = fields.excludeTags;\n }\n\n includeEvent(event: StreamEvent, rootType: string): boolean {\n let include =\n this.includeNames === undefined &&\n this.includeTypes === undefined &&\n this.includeTags === undefined;\n const eventTags = event.tags ?? [];\n\n if (this.includeNames !== undefined) {\n include = include || this.includeNames.includes(event.name);\n }\n if (this.includeTypes !== undefined) {\n include = include || this.includeTypes.includes(rootType);\n }\n if (this.includeTags !== undefined) {\n include =\n include || eventTags.some((tag) => this.includeTags?.includes(tag));\n }\n\n if (this.excludeNames !== undefined) {\n include = include && !this.excludeNames.includes(event.name);\n }\n if (this.excludeTypes !== undefined) {\n include = include && !this.excludeTypes.includes(rootType);\n }\n if (this.excludeTags !== undefined) {\n include =\n include && eventTags.every((tag) => !this.excludeTags?.includes(tag));\n }\n\n return include;\n }\n}\n\nexport const toBase64Url = (str: string): string => {\n // Use btoa for compatibility, assume ASCII\n const encoded = btoa(str);\n return encoded.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n};\n"],"mappings":";;AAIA,SAAgB,oBAAoBA,OAAwC;AAC1E,QAAO,QAAQ,MAAM,cAAc;AACpC;;;;;;;;AASD,IAAa,mBAAb,MAA8B;CAC5B;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAYC,QAOT;EACD,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;EAC1B,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;CAC3B;CAED,aAAaC,OAAoBC,UAA2B;EAC1D,IAAI,UACF,KAAK,iBAAiB,UACtB,KAAK,iBAAiB,UACtB,KAAK,gBAAgB;EACvB,MAAM,YAAY,MAAM,QAAQ,CAAE;AAElC,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,MAAM,KAAK;AAE7D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,SAAS;AAE3D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,KAAK,CAAC,QAAQ,KAAK,aAAa,SAAS,IAAI,CAAC;AAGvE,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,MAAM,KAAK;AAE9D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,SAAS;AAE5D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAa,SAAS,IAAI,CAAC;AAGzE,SAAO;CACR;AACF;AAED,MAAa,cAAc,CAACC,QAAwB;CAElD,MAAM,UAAU,KAAK,IAAI;AACzB,QAAO,QAAQ,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAC1E"}
|
package/dist/runnables/utils.js
CHANGED
|
@@ -36,7 +36,11 @@ var _RootEventFilter = class {
|
|
|
36
36
|
return include;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
+
const toBase64Url = (str) => {
|
|
40
|
+
const encoded = btoa(str);
|
|
41
|
+
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
42
|
+
};
|
|
39
43
|
|
|
40
44
|
//#endregion
|
|
41
|
-
export { _RootEventFilter, isRunnableInterface };
|
|
45
|
+
export { _RootEventFilter, isRunnableInterface, toBase64Url };
|
|
42
46
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["thing: any","fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }","event: StreamEvent","rootType: string"],"sources":["../../src/runnables/utils.ts"],"sourcesContent":["import { StreamEvent } from \"../tracers/event_stream.js\";\nimport type { RunnableInterface } from \"./types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isRunnableInterface(thing: any): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n}\n\n/**\n * Utility to filter the root event in the streamEvents implementation.\n * This is simply binding the arguments to the namespace to make save on\n * a bit of typing in the streamEvents implementation.\n *\n * TODO: Refactor and remove.\n */\nexport class _RootEventFilter {\n includeNames?: string[];\n\n includeTypes?: string[];\n\n includeTags?: string[];\n\n excludeNames?: string[];\n\n excludeTypes?: string[];\n\n excludeTags?: string[];\n\n constructor(fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }) {\n this.includeNames = fields.includeNames;\n this.includeTypes = fields.includeTypes;\n this.includeTags = fields.includeTags;\n this.excludeNames = fields.excludeNames;\n this.excludeTypes = fields.excludeTypes;\n this.excludeTags = fields.excludeTags;\n }\n\n includeEvent(event: StreamEvent, rootType: string): boolean {\n let include =\n this.includeNames === undefined &&\n this.includeTypes === undefined &&\n this.includeTags === undefined;\n const eventTags = event.tags ?? [];\n\n if (this.includeNames !== undefined) {\n include = include || this.includeNames.includes(event.name);\n }\n if (this.includeTypes !== undefined) {\n include = include || this.includeTypes.includes(rootType);\n }\n if (this.includeTags !== undefined) {\n include =\n include || eventTags.some((tag) => this.includeTags?.includes(tag));\n }\n\n if (this.excludeNames !== undefined) {\n include = include && !this.excludeNames.includes(event.name);\n }\n if (this.excludeTypes !== undefined) {\n include = include && !this.excludeTypes.includes(rootType);\n }\n if (this.excludeTags !== undefined) {\n include =\n include && eventTags.every((tag) => !this.excludeTags?.includes(tag));\n }\n\n return include;\n }\n}\n"],"mappings":";AAIA,SAAgB,oBAAoBA,OAAwC;AAC1E,QAAO,QAAQ,MAAM,cAAc;AACpC;;;;;;;;AASD,IAAa,mBAAb,MAA8B;CAC5B;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAYC,QAOT;EACD,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;EAC1B,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;CAC3B;CAED,aAAaC,OAAoBC,UAA2B;EAC1D,IAAI,UACF,KAAK,iBAAiB,UACtB,KAAK,iBAAiB,UACtB,KAAK,gBAAgB;EACvB,MAAM,YAAY,MAAM,QAAQ,CAAE;AAElC,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,MAAM,KAAK;AAE7D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,SAAS;AAE3D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,KAAK,CAAC,QAAQ,KAAK,aAAa,SAAS,IAAI,CAAC;AAGvE,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,MAAM,KAAK;AAE9D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,SAAS;AAE5D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAa,SAAS,IAAI,CAAC;AAGzE,SAAO;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["thing: any","fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }","event: StreamEvent","rootType: string","str: string"],"sources":["../../src/runnables/utils.ts"],"sourcesContent":["import { StreamEvent } from \"../tracers/event_stream.js\";\nimport type { RunnableInterface } from \"./types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isRunnableInterface(thing: any): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n}\n\n/**\n * Utility to filter the root event in the streamEvents implementation.\n * This is simply binding the arguments to the namespace to make save on\n * a bit of typing in the streamEvents implementation.\n *\n * TODO: Refactor and remove.\n */\nexport class _RootEventFilter {\n includeNames?: string[];\n\n includeTypes?: string[];\n\n includeTags?: string[];\n\n excludeNames?: string[];\n\n excludeTypes?: string[];\n\n excludeTags?: string[];\n\n constructor(fields: {\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n }) {\n this.includeNames = fields.includeNames;\n this.includeTypes = fields.includeTypes;\n this.includeTags = fields.includeTags;\n this.excludeNames = fields.excludeNames;\n this.excludeTypes = fields.excludeTypes;\n this.excludeTags = fields.excludeTags;\n }\n\n includeEvent(event: StreamEvent, rootType: string): boolean {\n let include =\n this.includeNames === undefined &&\n this.includeTypes === undefined &&\n this.includeTags === undefined;\n const eventTags = event.tags ?? [];\n\n if (this.includeNames !== undefined) {\n include = include || this.includeNames.includes(event.name);\n }\n if (this.includeTypes !== undefined) {\n include = include || this.includeTypes.includes(rootType);\n }\n if (this.includeTags !== undefined) {\n include =\n include || eventTags.some((tag) => this.includeTags?.includes(tag));\n }\n\n if (this.excludeNames !== undefined) {\n include = include && !this.excludeNames.includes(event.name);\n }\n if (this.excludeTypes !== undefined) {\n include = include && !this.excludeTypes.includes(rootType);\n }\n if (this.excludeTags !== undefined) {\n include =\n include && eventTags.every((tag) => !this.excludeTags?.includes(tag));\n }\n\n return include;\n }\n}\n\nexport const toBase64Url = (str: string): string => {\n // Use btoa for compatibility, assume ASCII\n const encoded = btoa(str);\n return encoded.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n};\n"],"mappings":";AAIA,SAAgB,oBAAoBA,OAAwC;AAC1E,QAAO,QAAQ,MAAM,cAAc;AACpC;;;;;;;;AASD,IAAa,mBAAb,MAA8B;CAC5B;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAYC,QAOT;EACD,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;EAC1B,KAAK,eAAe,OAAO;EAC3B,KAAK,eAAe,OAAO;EAC3B,KAAK,cAAc,OAAO;CAC3B;CAED,aAAaC,OAAoBC,UAA2B;EAC1D,IAAI,UACF,KAAK,iBAAiB,UACtB,KAAK,iBAAiB,UACtB,KAAK,gBAAgB;EACvB,MAAM,YAAY,MAAM,QAAQ,CAAE;AAElC,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,MAAM,KAAK;AAE7D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,KAAK,aAAa,SAAS,SAAS;AAE3D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,KAAK,CAAC,QAAQ,KAAK,aAAa,SAAS,IAAI,CAAC;AAGvE,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,MAAM,KAAK;AAE9D,MAAI,KAAK,iBAAiB,QACxB,UAAU,WAAW,CAAC,KAAK,aAAa,SAAS,SAAS;AAE5D,MAAI,KAAK,gBAAgB,QACvB,UACE,WAAW,UAAU,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAa,SAAS,IAAI,CAAC;AAGzE,SAAO;CACR;AACF;AAED,MAAa,cAAc,CAACC,QAAwB;CAElD,MAAM,UAAU,KAAK,IAAI;AACzB,QAAO,QAAQ,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,GAAG;AAC1E"}
|
|
@@ -102,7 +102,6 @@ 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
|
|
106
105
|
declare function getContextVariable<T = any>(name: PropertyKey): T | undefined;
|
|
107
106
|
/**
|
|
108
107
|
* Register a callback configure hook to automatically add callback handlers to all runs.
|
|
@@ -153,7 +152,6 @@ declare const registerConfigureHook: (config: ConfigureHook) => void;
|
|
|
153
152
|
type ConfigureHook = {
|
|
154
153
|
contextVar?: string;
|
|
155
154
|
inheritable?: boolean;
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
155
|
handlerClass?: new (...args: any[]) => BaseCallbackHandler;
|
|
158
156
|
envVar?: string;
|
|
159
157
|
};
|
|
@@ -102,7 +102,6 @@ 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
|
|
106
105
|
declare function getContextVariable<T = any>(name: PropertyKey): T | undefined;
|
|
107
106
|
/**
|
|
108
107
|
* Register a callback configure hook to automatically add callback handlers to all runs.
|
|
@@ -153,7 +152,6 @@ declare const registerConfigureHook: (config: ConfigureHook) => void;
|
|
|
153
152
|
type ConfigureHook = {
|
|
154
153
|
contextVar?: string;
|
|
155
154
|
inheritable?: boolean;
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
155
|
handlerClass?: new (...args: any[]) => BaseCallbackHandler;
|
|
158
156
|
envVar?: string;
|
|
159
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.cjs","names":["queue: typeof
|
|
1
|
+
{"version":3,"file":"callbacks.cjs","names":["queue: (typeof PQueueMod)[\"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 PQueueMod)[\"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: typeof
|
|
1
|
+
{"version":3,"file":"callbacks.js","names":["queue: (typeof PQueueMod)[\"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 PQueueMod)[\"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,7 +50,6 @@ 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
|
|
54
53
|
declare class InMemoryStore<T = any> extends BaseStore<string, T> {
|
|
55
54
|
lc_namespace: string[];
|
|
56
55
|
protected store: Record<string, T>;
|
package/dist/stores.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ 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
|
|
54
53
|
declare class InMemoryStore<T = any> extends BaseStore<string, T> {
|
|
55
54
|
lc_namespace: string[];
|
|
56
55
|
protected store: Record<string, T>;
|
|
@@ -2,15 +2,12 @@
|
|
|
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
|
|
6
5
|
declare function isObject(obj: any): obj is object;
|
|
7
6
|
/**
|
|
8
7
|
* Checks if a provided filter is empty. The filter can be a function, an
|
|
9
8
|
* object, a string, or undefined.
|
|
10
9
|
*/
|
|
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;
|
|
10
|
+
declare function isFilterEmpty(filter: ((q: any) => any) | object | string | undefined): filter is undefined;
|
|
14
11
|
/**
|
|
15
12
|
* Checks if the provided value is an integer.
|
|
16
13
|
*/
|
|
@@ -2,15 +2,12 @@
|
|
|
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
|
|
6
5
|
declare function isObject(obj: any): obj is object;
|
|
7
6
|
/**
|
|
8
7
|
* Checks if a provided filter is empty. The filter can be a function, an
|
|
9
8
|
* object, a string, or undefined.
|
|
10
9
|
*/
|
|
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;
|
|
10
|
+
declare function isFilterEmpty(filter: ((q: any) => any) | object | string | undefined): filter is undefined;
|
|
14
11
|
/**
|
|
15
12
|
* Checks if the provided value is an integer.
|
|
16
13
|
*/
|
package/dist/tools/index.d.cts
CHANGED
|
@@ -94,7 +94,6 @@ 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
|
|
98
97
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
99
98
|
}
|
|
100
99
|
/**
|
|
@@ -111,9 +110,7 @@ declare class DynamicTool<ToolOutputT = ToolOutputType> extends Tool<ToolOutputT
|
|
|
111
110
|
*/
|
|
112
111
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
113
112
|
/** @ignore */
|
|
114
|
-
_call(input: string,
|
|
115
|
-
// DynamicTool's _call specifically expects a string after schema transformation
|
|
116
|
-
runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
113
|
+
_call(input: string, runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
117
114
|
}
|
|
118
115
|
/**
|
|
119
116
|
* A tool that can be created dynamically from a function, name, and
|
|
@@ -134,7 +131,6 @@ declare class DynamicStructuredTool<SchemaT = ToolInputSchemaBase, SchemaOutputT
|
|
|
134
131
|
/**
|
|
135
132
|
* @deprecated Use .invoke() instead. Will be removed in 0.3.0.
|
|
136
133
|
*/
|
|
137
|
-
// Match the base class signature
|
|
138
134
|
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig, /** @deprecated */
|
|
139
135
|
tags?: string[]): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
140
136
|
protected _call(arg: Parameters<DynamicStructuredToolInput<SchemaT, SchemaOutputT>["func"]>[0], runManager?: CallbackManagerForToolRun, parentConfig?: RunnableConfig): Promise<ToolOutputT>;
|
|
@@ -212,7 +208,6 @@ declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZ
|
|
|
212
208
|
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>;
|
|
213
209
|
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>;
|
|
214
210
|
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
|
|
216
211
|
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>;
|
|
217
212
|
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>;
|
|
218
213
|
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,7 +96,6 @@ 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
|
|
100
99
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
101
100
|
}
|
|
102
101
|
/**
|
|
@@ -113,9 +112,7 @@ declare class DynamicTool<ToolOutputT = ToolOutputType> extends Tool<ToolOutputT
|
|
|
113
112
|
*/
|
|
114
113
|
call<TArg extends string | undefined | z.input<this["schema"]> | ToolCall, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
115
114
|
/** @ignore */
|
|
116
|
-
_call(input: string,
|
|
117
|
-
// DynamicTool's _call specifically expects a string after schema transformation
|
|
118
|
-
runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
115
|
+
_call(input: string, runManager?: CallbackManagerForToolRun, parentConfig?: ToolRunnableConfig): Promise<ToolOutputT>;
|
|
119
116
|
}
|
|
120
117
|
/**
|
|
121
118
|
* A tool that can be created dynamically from a function, name, and
|
|
@@ -136,7 +133,6 @@ declare class DynamicStructuredTool<SchemaT = ToolInputSchemaBase, SchemaOutputT
|
|
|
136
133
|
/**
|
|
137
134
|
* @deprecated Use .invoke() instead. Will be removed in 0.3.0.
|
|
138
135
|
*/
|
|
139
|
-
// Match the base class signature
|
|
140
136
|
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, configArg?: TConfig, /** @deprecated */
|
|
141
137
|
tags?: string[]): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
142
138
|
protected _call(arg: Parameters<DynamicStructuredToolInput<SchemaT, SchemaOutputT>["func"]>[0], runManager?: CallbackManagerForToolRun, parentConfig?: RunnableConfig): Promise<ToolOutputT>;
|
|
@@ -214,7 +210,6 @@ declare function tool<SchemaT extends ZodObjectV3, SchemaOutputT = InferInteropZ
|
|
|
214
210
|
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>;
|
|
215
211
|
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>;
|
|
216
212
|
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
|
|
218
213
|
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>;
|
|
219
214
|
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>;
|
|
220
215
|
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,9 +11,7 @@ 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
|
|
15
14
|
type ToolOutputType = any;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
15
|
type ContentAndArtifact = [MessageContent, any];
|
|
18
16
|
/**
|
|
19
17
|
* Conditional type that determines the return type of the {@link StructuredTool.invoke} method.
|
|
@@ -75,11 +73,7 @@ interface ToolParams extends BaseLangChainParams {
|
|
|
75
73
|
*/
|
|
76
74
|
extras?: Record<string, unknown>;
|
|
77
75
|
}
|
|
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> & {
|
|
76
|
+
type ToolRunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>, ContextSchema = any> = RunnableConfig<ConfigurableFieldType> & {
|
|
83
77
|
toolCall?: ToolCall;
|
|
84
78
|
context?: ContextSchema;
|
|
85
79
|
};
|
|
@@ -134,9 +128,7 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
|
|
|
134
128
|
* This is primarily used for creating simple string-based tools where the LLM
|
|
135
129
|
* only needs to provide a single text value as input to the tool.
|
|
136
130
|
*/
|
|
137
|
-
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
-
any>;
|
|
131
|
+
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef, any>;
|
|
140
132
|
/**
|
|
141
133
|
* Interface that defines the shape of a LangChain structured tool.
|
|
142
134
|
*
|
|
@@ -211,9 +203,7 @@ interface ToolInterface<SchemaT = StringInputToolSchema, SchemaInputT = ToolInpu
|
|
|
211
203
|
* @param callbacks Optional callbacks for the tool.
|
|
212
204
|
* @returns A Promise that resolves with a string.
|
|
213
205
|
*/
|
|
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>>;
|
|
206
|
+
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
217
207
|
}
|
|
218
208
|
/**
|
|
219
209
|
* Base interface for the input parameters of the {@link DynamicTool} and
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -13,9 +13,7 @@ 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
|
|
17
16
|
type ToolOutputType = any;
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
17
|
type ContentAndArtifact = [MessageContent, any];
|
|
20
18
|
/**
|
|
21
19
|
* Conditional type that determines the return type of the {@link StructuredTool.invoke} method.
|
|
@@ -77,11 +75,7 @@ interface ToolParams extends BaseLangChainParams {
|
|
|
77
75
|
*/
|
|
78
76
|
extras?: Record<string, unknown>;
|
|
79
77
|
}
|
|
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> & {
|
|
78
|
+
type ToolRunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>, ContextSchema = any> = RunnableConfig<ConfigurableFieldType> & {
|
|
85
79
|
toolCall?: ToolCall;
|
|
86
80
|
context?: ContextSchema;
|
|
87
81
|
};
|
|
@@ -136,9 +130,7 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
|
|
|
136
130
|
* This is primarily used for creating simple string-based tools where the LLM
|
|
137
131
|
* only needs to provide a single text value as input to the tool.
|
|
138
132
|
*/
|
|
139
|
-
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef,
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
-
any>;
|
|
133
|
+
type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef, any>;
|
|
142
134
|
/**
|
|
143
135
|
* Interface that defines the shape of a LangChain structured tool.
|
|
144
136
|
*
|
|
@@ -213,9 +205,7 @@ interface ToolInterface<SchemaT = StringInputToolSchema, SchemaInputT = ToolInpu
|
|
|
213
205
|
* @param callbacks Optional callbacks for the tool.
|
|
214
206
|
* @returns A Promise that resolves with a string.
|
|
215
207
|
*/
|
|
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>>;
|
|
208
|
+
call<TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>, TConfig extends ToolRunnableConfig | undefined>(arg: TArg, callbacks?: TConfig): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;
|
|
219
209
|
}
|
|
220
210
|
/**
|
|
221
211
|
* Base interface for the input parameters of the {@link DynamicTool} and
|