@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
|
@@ -11,15 +11,33 @@ import { Graph } from "./graph.cjs";
|
|
|
11
11
|
import { TraceableFunction } from "langsmith/singletons/traceable";
|
|
12
12
|
|
|
13
13
|
//#region src/runnables/base.d.ts
|
|
14
|
-
type RunnableFunc<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> = (input: RunInput, options: CallOptions
|
|
14
|
+
type RunnableFunc<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> = (input: RunInput, options: CallOptions
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
| Record<string, any>
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
| (Record<string, any> & CallOptions)) => RunOutput | Promise<RunOutput>;
|
|
15
19
|
type RunnableMapLike<RunInput, RunOutput> = { [K in keyof RunOutput]: RunnableLike<RunInput, RunOutput[K]> };
|
|
16
|
-
type RunnableLike<
|
|
17
|
-
|
|
20
|
+
type RunnableLike<
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
RunInput = any,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
|
|
25
|
+
type RunnableRetryFailedAttemptHandler = (
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
error: any,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
input: any
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
) => any;
|
|
18
32
|
/**
|
|
19
33
|
* A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or
|
|
20
34
|
* transformed.
|
|
21
35
|
*/
|
|
22
|
-
declare abstract class Runnable<
|
|
36
|
+
declare abstract class Runnable<
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
RunInput = any,
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends Serializable implements RunnableInterface<RunInput, RunOutput, CallOptions> {
|
|
23
41
|
protected lc_runnable: boolean;
|
|
24
42
|
name?: string;
|
|
25
43
|
getName(suffix?: string): string;
|
|
@@ -263,6 +281,7 @@ declare abstract class Runnable<RunInput = any, RunOutput = any, CallOptions ext
|
|
|
263
281
|
}, streamOptions?: Omit<EventStreamCallbackHandlerInput, "autoClose">): IterableReadableStream<Uint8Array>;
|
|
264
282
|
private _streamEventsV2;
|
|
265
283
|
private _streamEventsV1;
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
285
|
static isRunnable(thing: any): thing is Runnable;
|
|
267
286
|
/**
|
|
268
287
|
* Bind lifecycle listeners to a Runnable, returning a new Runnable.
|
|
@@ -386,7 +405,11 @@ declare class RunnableBinding<RunInput, RunOutput, CallOptions extends RunnableC
|
|
|
386
405
|
version: "v1" | "v2";
|
|
387
406
|
encoding: "text/event-stream";
|
|
388
407
|
}, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): IterableReadableStream<Uint8Array>;
|
|
389
|
-
static isRunnableBinding(
|
|
408
|
+
static isRunnableBinding(
|
|
409
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
+
thing: any
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
412
|
+
): thing is RunnableBinding<any, any, any>;
|
|
390
413
|
/**
|
|
391
414
|
* Bind lifecycle listeners to a Runnable, returning a new Runnable.
|
|
392
415
|
* The Run object contains information about the run, including its id,
|
|
@@ -516,7 +539,11 @@ declare class RunnableEach<RunInputItem, RunOutputItem, CallOptions extends Runn
|
|
|
516
539
|
* });
|
|
517
540
|
* ```
|
|
518
541
|
*/
|
|
519
|
-
declare class RunnableRetry<
|
|
542
|
+
declare class RunnableRetry<
|
|
543
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
544
|
+
RunInput = any,
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
546
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends RunnableBinding<RunInput, RunOutput, CallOptions> {
|
|
520
547
|
static lc_name(): string;
|
|
521
548
|
lc_namespace: string[];
|
|
522
549
|
protected maxAttemptNumber: number;
|
|
@@ -550,6 +577,7 @@ declare class RunnableRetry<RunInput = any, RunOutput = any, CallOptions extends
|
|
|
550
577
|
type RunnableSequenceFields<RunInput, RunOutput> = {
|
|
551
578
|
first: Runnable<RunInput>;
|
|
552
579
|
middle?: Runnable[];
|
|
580
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
553
581
|
last: Runnable<any, RunOutput>;
|
|
554
582
|
name?: string;
|
|
555
583
|
omitSequenceTags?: boolean;
|
|
@@ -565,10 +593,15 @@ type RunnableSequenceFields<RunInput, RunOutput> = {
|
|
|
565
593
|
* const result = await chain.invoke({ topic: "bears" });
|
|
566
594
|
* ```
|
|
567
595
|
*/
|
|
568
|
-
declare class RunnableSequence<
|
|
596
|
+
declare class RunnableSequence<
|
|
597
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
598
|
+
RunInput = any,
|
|
599
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
600
|
+
RunOutput = any> extends Runnable<RunInput, RunOutput> {
|
|
569
601
|
static lc_name(): string;
|
|
570
602
|
protected first: Runnable<RunInput>;
|
|
571
603
|
protected middle: Runnable[];
|
|
604
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
572
605
|
protected last: Runnable<any, RunOutput>;
|
|
573
606
|
omitSequenceTags: boolean;
|
|
574
607
|
lc_serializable: boolean;
|
|
@@ -588,8 +621,12 @@ declare class RunnableSequence<RunInput = any, RunOutput = any> extends Runnable
|
|
|
588
621
|
_streamIterator(input: RunInput, options?: RunnableConfig): AsyncGenerator<RunOutput>;
|
|
589
622
|
getGraph(config?: RunnableConfig): Graph;
|
|
590
623
|
pipe<NewRunOutput>(coerceable: RunnableLike<RunOutput, NewRunOutput>): RunnableSequence<RunInput, Exclude<NewRunOutput, Error>>;
|
|
624
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
625
|
static isRunnableSequence(thing: any): thing is RunnableSequence;
|
|
592
|
-
|
|
626
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
627
|
+
static from<RunInput = any, RunOutput = any>([first, ...runnables]: [RunnableLike<RunInput>, ...RunnableLike[],
|
|
628
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
629
|
+
RunnableLike<any, RunOutput>], nameOrFields?: string | Omit<RunnableSequenceFields<RunInput, RunOutput>, "first" | "middle" | "last">): RunnableSequence<RunInput, Exclude<RunOutput, Error>>;
|
|
593
630
|
}
|
|
594
631
|
/**
|
|
595
632
|
* A runnable that runs a mapping of runnables in parallel,
|
|
@@ -607,7 +644,11 @@ declare class RunnableSequence<RunInput = any, RunOutput = any> extends Runnable
|
|
|
607
644
|
* const result = await mapChain.invoke({ topic: "bear" });
|
|
608
645
|
* ```
|
|
609
646
|
*/
|
|
610
|
-
declare class RunnableMap<
|
|
647
|
+
declare class RunnableMap<
|
|
648
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
649
|
+
RunInput = any,
|
|
650
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
651
|
+
RunOutput extends Record<string, any> = Record<string, any>> extends Runnable<RunInput, RunOutput> {
|
|
611
652
|
static lc_name(): string;
|
|
612
653
|
lc_namespace: string[];
|
|
613
654
|
lc_serializable: boolean;
|
|
@@ -616,7 +657,9 @@ declare class RunnableMap<RunInput = any, RunOutput extends Record<string, any>
|
|
|
616
657
|
constructor(fields: {
|
|
617
658
|
steps: RunnableMapLike<RunInput, RunOutput>;
|
|
618
659
|
});
|
|
619
|
-
static from<RunInput,
|
|
660
|
+
static from<RunInput,
|
|
661
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
662
|
+
RunOutput extends Record<string, any> = Record<string, any>>(steps: RunnableMapLike<RunInput, RunOutput>): RunnableMap<RunInput, RunOutput>;
|
|
620
663
|
invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
|
|
621
664
|
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
|
|
622
665
|
transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
|
|
@@ -786,6 +829,7 @@ declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable<RunInp
|
|
|
786
829
|
}): Promise<(RunOutput | Error)[]>;
|
|
787
830
|
batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
|
|
788
831
|
}
|
|
832
|
+
// TODO: Figure out why the compiler needs help eliminating Error as a RunOutput type
|
|
789
833
|
declare function _coerceToRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(coerceable: RunnableLike<RunInput, RunOutput, CallOptions>): Runnable<RunInput, Exclude<RunOutput, Error>, CallOptions>;
|
|
790
834
|
interface RunnableAssignFields<RunInput> {
|
|
791
835
|
mapper: RunnableMap<RunInput>;
|
|
@@ -821,7 +865,11 @@ interface RunnableAssignFields<RunInput> {
|
|
|
821
865
|
* // { name: "Alice", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: "Hello, Alice!" } }
|
|
822
866
|
* ```
|
|
823
867
|
*/
|
|
824
|
-
declare class RunnableAssign<
|
|
868
|
+
declare class RunnableAssign<
|
|
869
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
870
|
+
RunInput extends Record<string, any> = Record<string, any>,
|
|
871
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
872
|
+
RunOutput extends Record<string, any> = Record<string, any>, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnableAssignFields<RunInput> {
|
|
825
873
|
static lc_name(): string;
|
|
826
874
|
lc_namespace: string[];
|
|
827
875
|
lc_serializable: boolean;
|
|
@@ -859,7 +907,11 @@ interface RunnablePickFields {
|
|
|
859
907
|
* // { name: 'John', city: 'New York' }
|
|
860
908
|
* ```
|
|
861
909
|
*/
|
|
862
|
-
declare class RunnablePick<
|
|
910
|
+
declare class RunnablePick<
|
|
911
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
912
|
+
RunInput extends Record<string, any> = Record<string, any>,
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
914
|
+
RunOutput extends Record<string, any> | any = Record<string, any> | any, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnablePickFields {
|
|
863
915
|
static lc_name(): string;
|
|
864
916
|
lc_namespace: string[];
|
|
865
917
|
lc_serializable: boolean;
|
package/dist/runnables/base.d.ts
CHANGED
|
@@ -11,15 +11,33 @@ import { Graph } from "./graph.js";
|
|
|
11
11
|
import { TraceableFunction } from "langsmith/singletons/traceable";
|
|
12
12
|
|
|
13
13
|
//#region src/runnables/base.d.ts
|
|
14
|
-
type RunnableFunc<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> = (input: RunInput, options: CallOptions
|
|
14
|
+
type RunnableFunc<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> = (input: RunInput, options: CallOptions
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
| Record<string, any>
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
| (Record<string, any> & CallOptions)) => RunOutput | Promise<RunOutput>;
|
|
15
19
|
type RunnableMapLike<RunInput, RunOutput> = { [K in keyof RunOutput]: RunnableLike<RunInput, RunOutput[K]> };
|
|
16
|
-
type RunnableLike<
|
|
17
|
-
|
|
20
|
+
type RunnableLike<
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
RunInput = any,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
|
|
25
|
+
type RunnableRetryFailedAttemptHandler = (
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
error: any,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
input: any
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
) => any;
|
|
18
32
|
/**
|
|
19
33
|
* A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or
|
|
20
34
|
* transformed.
|
|
21
35
|
*/
|
|
22
|
-
declare abstract class Runnable<
|
|
36
|
+
declare abstract class Runnable<
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
RunInput = any,
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends Serializable implements RunnableInterface<RunInput, RunOutput, CallOptions> {
|
|
23
41
|
protected lc_runnable: boolean;
|
|
24
42
|
name?: string;
|
|
25
43
|
getName(suffix?: string): string;
|
|
@@ -263,6 +281,7 @@ declare abstract class Runnable<RunInput = any, RunOutput = any, CallOptions ext
|
|
|
263
281
|
}, streamOptions?: Omit<EventStreamCallbackHandlerInput, "autoClose">): IterableReadableStream<Uint8Array>;
|
|
264
282
|
private _streamEventsV2;
|
|
265
283
|
private _streamEventsV1;
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
285
|
static isRunnable(thing: any): thing is Runnable;
|
|
267
286
|
/**
|
|
268
287
|
* Bind lifecycle listeners to a Runnable, returning a new Runnable.
|
|
@@ -386,7 +405,11 @@ declare class RunnableBinding<RunInput, RunOutput, CallOptions extends RunnableC
|
|
|
386
405
|
version: "v1" | "v2";
|
|
387
406
|
encoding: "text/event-stream";
|
|
388
407
|
}, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): IterableReadableStream<Uint8Array>;
|
|
389
|
-
static isRunnableBinding(
|
|
408
|
+
static isRunnableBinding(
|
|
409
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
+
thing: any
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
412
|
+
): thing is RunnableBinding<any, any, any>;
|
|
390
413
|
/**
|
|
391
414
|
* Bind lifecycle listeners to a Runnable, returning a new Runnable.
|
|
392
415
|
* The Run object contains information about the run, including its id,
|
|
@@ -516,7 +539,11 @@ declare class RunnableEach<RunInputItem, RunOutputItem, CallOptions extends Runn
|
|
|
516
539
|
* });
|
|
517
540
|
* ```
|
|
518
541
|
*/
|
|
519
|
-
declare class RunnableRetry<
|
|
542
|
+
declare class RunnableRetry<
|
|
543
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
544
|
+
RunInput = any,
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
546
|
+
RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends RunnableBinding<RunInput, RunOutput, CallOptions> {
|
|
520
547
|
static lc_name(): string;
|
|
521
548
|
lc_namespace: string[];
|
|
522
549
|
protected maxAttemptNumber: number;
|
|
@@ -550,6 +577,7 @@ declare class RunnableRetry<RunInput = any, RunOutput = any, CallOptions extends
|
|
|
550
577
|
type RunnableSequenceFields<RunInput, RunOutput> = {
|
|
551
578
|
first: Runnable<RunInput>;
|
|
552
579
|
middle?: Runnable[];
|
|
580
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
553
581
|
last: Runnable<any, RunOutput>;
|
|
554
582
|
name?: string;
|
|
555
583
|
omitSequenceTags?: boolean;
|
|
@@ -565,10 +593,15 @@ type RunnableSequenceFields<RunInput, RunOutput> = {
|
|
|
565
593
|
* const result = await chain.invoke({ topic: "bears" });
|
|
566
594
|
* ```
|
|
567
595
|
*/
|
|
568
|
-
declare class RunnableSequence<
|
|
596
|
+
declare class RunnableSequence<
|
|
597
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
598
|
+
RunInput = any,
|
|
599
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
600
|
+
RunOutput = any> extends Runnable<RunInput, RunOutput> {
|
|
569
601
|
static lc_name(): string;
|
|
570
602
|
protected first: Runnable<RunInput>;
|
|
571
603
|
protected middle: Runnable[];
|
|
604
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
572
605
|
protected last: Runnable<any, RunOutput>;
|
|
573
606
|
omitSequenceTags: boolean;
|
|
574
607
|
lc_serializable: boolean;
|
|
@@ -588,8 +621,12 @@ declare class RunnableSequence<RunInput = any, RunOutput = any> extends Runnable
|
|
|
588
621
|
_streamIterator(input: RunInput, options?: RunnableConfig): AsyncGenerator<RunOutput>;
|
|
589
622
|
getGraph(config?: RunnableConfig): Graph;
|
|
590
623
|
pipe<NewRunOutput>(coerceable: RunnableLike<RunOutput, NewRunOutput>): RunnableSequence<RunInput, Exclude<NewRunOutput, Error>>;
|
|
624
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
625
|
static isRunnableSequence(thing: any): thing is RunnableSequence;
|
|
592
|
-
|
|
626
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
627
|
+
static from<RunInput = any, RunOutput = any>([first, ...runnables]: [RunnableLike<RunInput>, ...RunnableLike[],
|
|
628
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
629
|
+
RunnableLike<any, RunOutput>], nameOrFields?: string | Omit<RunnableSequenceFields<RunInput, RunOutput>, "first" | "middle" | "last">): RunnableSequence<RunInput, Exclude<RunOutput, Error>>;
|
|
593
630
|
}
|
|
594
631
|
/**
|
|
595
632
|
* A runnable that runs a mapping of runnables in parallel,
|
|
@@ -607,7 +644,11 @@ declare class RunnableSequence<RunInput = any, RunOutput = any> extends Runnable
|
|
|
607
644
|
* const result = await mapChain.invoke({ topic: "bear" });
|
|
608
645
|
* ```
|
|
609
646
|
*/
|
|
610
|
-
declare class RunnableMap<
|
|
647
|
+
declare class RunnableMap<
|
|
648
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
649
|
+
RunInput = any,
|
|
650
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
651
|
+
RunOutput extends Record<string, any> = Record<string, any>> extends Runnable<RunInput, RunOutput> {
|
|
611
652
|
static lc_name(): string;
|
|
612
653
|
lc_namespace: string[];
|
|
613
654
|
lc_serializable: boolean;
|
|
@@ -616,7 +657,9 @@ declare class RunnableMap<RunInput = any, RunOutput extends Record<string, any>
|
|
|
616
657
|
constructor(fields: {
|
|
617
658
|
steps: RunnableMapLike<RunInput, RunOutput>;
|
|
618
659
|
});
|
|
619
|
-
static from<RunInput,
|
|
660
|
+
static from<RunInput,
|
|
661
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
662
|
+
RunOutput extends Record<string, any> = Record<string, any>>(steps: RunnableMapLike<RunInput, RunOutput>): RunnableMap<RunInput, RunOutput>;
|
|
620
663
|
invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
|
|
621
664
|
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
|
|
622
665
|
transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
|
|
@@ -786,6 +829,7 @@ declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable<RunInp
|
|
|
786
829
|
}): Promise<(RunOutput | Error)[]>;
|
|
787
830
|
batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
|
|
788
831
|
}
|
|
832
|
+
// TODO: Figure out why the compiler needs help eliminating Error as a RunOutput type
|
|
789
833
|
declare function _coerceToRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(coerceable: RunnableLike<RunInput, RunOutput, CallOptions>): Runnable<RunInput, Exclude<RunOutput, Error>, CallOptions>;
|
|
790
834
|
interface RunnableAssignFields<RunInput> {
|
|
791
835
|
mapper: RunnableMap<RunInput>;
|
|
@@ -821,7 +865,11 @@ interface RunnableAssignFields<RunInput> {
|
|
|
821
865
|
* // { name: "Alice", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: "Hello, Alice!" } }
|
|
822
866
|
* ```
|
|
823
867
|
*/
|
|
824
|
-
declare class RunnableAssign<
|
|
868
|
+
declare class RunnableAssign<
|
|
869
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
870
|
+
RunInput extends Record<string, any> = Record<string, any>,
|
|
871
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
872
|
+
RunOutput extends Record<string, any> = Record<string, any>, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnableAssignFields<RunInput> {
|
|
825
873
|
static lc_name(): string;
|
|
826
874
|
lc_namespace: string[];
|
|
827
875
|
lc_serializable: boolean;
|
|
@@ -859,7 +907,11 @@ interface RunnablePickFields {
|
|
|
859
907
|
* // { name: 'John', city: 'New York' }
|
|
860
908
|
* ```
|
|
861
909
|
*/
|
|
862
|
-
declare class RunnablePick<
|
|
910
|
+
declare class RunnablePick<
|
|
911
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
912
|
+
RunInput extends Record<string, any> = Record<string, any>,
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
914
|
+
RunOutput extends Record<string, any> | any = Record<string, any> | any, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnablePickFields {
|
|
863
915
|
static lc_name(): string;
|
|
864
916
|
lc_namespace: string[];
|
|
865
917
|
lc_serializable: boolean;
|
package/dist/runnables/base.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Serializable } from "../load/serializable.js";
|
|
2
2
|
import { ToolInputParsingException, _isToolCall } from "../tools/utils.js";
|
|
3
|
-
import { pRetry } from "../node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js";
|
|
4
3
|
import { AsyncLocalStorageProviderSingleton } from "../singletons/async_local_storage/index.js";
|
|
5
4
|
import "../singletons/index.js";
|
|
6
5
|
import { DEFAULT_RECURSION_LIMIT, ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig, pickRunnableConfigKeys } from "./config.js";
|
|
@@ -8,6 +7,7 @@ import { getAbortSignalError, raceWithSignal } from "../utils/signal.js";
|
|
|
8
7
|
import { AsyncGeneratorWithSetup, IterableReadableStream, atee, concat, pipeGeneratorWithSetup } from "../utils/stream.js";
|
|
9
8
|
import { LogStreamCallbackHandler, RunLog, RunLogPatch, isLogStreamHandler } from "../tracers/log_stream.js";
|
|
10
9
|
import { EventStreamCallbackHandler, isStreamEventsHandler } from "../tracers/event_stream.js";
|
|
10
|
+
import { pRetry } from "../utils/p-retry/index.js";
|
|
11
11
|
import { AsyncCaller } from "../utils/async_caller.js";
|
|
12
12
|
import { RootListenersTracer } from "../tracers/root_listener.js";
|
|
13
13
|
import { _RootEventFilter, isRunnableInterface } from "./utils.js";
|