@langchain/core 0.2.35 → 0.2.36
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/dist/runnables/base.d.ts
CHANGED
|
@@ -11,17 +11,17 @@ import { Run } from "../tracers/base.js";
|
|
|
11
11
|
import { Graph } from "./graph.js";
|
|
12
12
|
import { ToolCall } from "../messages/tool.js";
|
|
13
13
|
export { type RunnableInterface, RunnableBatchOptions };
|
|
14
|
-
export type RunnableFunc<RunInput, RunOutput> = (input: RunInput, options?: ({
|
|
14
|
+
export type RunnableFunc<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> = (input: RunInput, options?: ({
|
|
15
15
|
/** @deprecated Use top-level config fields instead. */
|
|
16
|
-
config?:
|
|
17
|
-
} &
|
|
16
|
+
config?: CallOptions;
|
|
17
|
+
} & CallOptions) | Record<string, any> | (Record<string, any> & {
|
|
18
18
|
/** @deprecated Use top-level config fields instead. */
|
|
19
|
-
config:
|
|
20
|
-
} &
|
|
19
|
+
config: CallOptions;
|
|
20
|
+
} & CallOptions)) => RunOutput | Promise<RunOutput>;
|
|
21
21
|
export type RunnableMapLike<RunInput, RunOutput> = {
|
|
22
22
|
[K in keyof RunOutput]: RunnableLike<RunInput, RunOutput[K]>;
|
|
23
23
|
};
|
|
24
|
-
export type RunnableLike<RunInput = any, RunOutput = any> = RunnableInterface<RunInput, RunOutput> | RunnableFunc<RunInput, RunOutput> | RunnableMapLike<RunInput, RunOutput>;
|
|
24
|
+
export type RunnableLike<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
|
|
25
25
|
export type RunnableRetryFailedAttemptHandler = (error: any, input: any) => any;
|
|
26
26
|
export declare function _coerceToDict(value: any, defaultKey: string): any;
|
|
27
27
|
/**
|
|
@@ -123,7 +123,7 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
123
123
|
* Output values, with callbacks.
|
|
124
124
|
* Use this to implement `stream()` or `transform()` in Runnable subclasses.
|
|
125
125
|
*/
|
|
126
|
-
protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: CallbackManagerForChainRun, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: CallOptions & {
|
|
126
|
+
protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: CallbackManagerForChainRun, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: Partial<CallOptions> & {
|
|
127
127
|
runType?: string;
|
|
128
128
|
}): AsyncGenerator<O>;
|
|
129
129
|
getGraph(_?: RunnableConfig): Graph;
|
|
@@ -553,20 +553,20 @@ export declare class RunnableTraceable<RunInput, RunOutput> extends Runnable<Run
|
|
|
553
553
|
/**
|
|
554
554
|
* A runnable that runs a callable.
|
|
555
555
|
*/
|
|
556
|
-
export declare class RunnableLambda<RunInput, RunOutput> extends Runnable<RunInput, RunOutput> {
|
|
556
|
+
export declare class RunnableLambda<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> {
|
|
557
557
|
static lc_name(): string;
|
|
558
558
|
lc_namespace: string[];
|
|
559
|
-
protected func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
559
|
+
protected func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>;
|
|
560
560
|
constructor(fields: {
|
|
561
|
-
func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
561
|
+
func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions> | TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>>;
|
|
562
562
|
});
|
|
563
|
-
static from<RunInput, RunOutput>(func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
564
|
-
static from<RunInput, RunOutput>(func: TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
565
|
-
_invoke(input: RunInput, config?: Partial<
|
|
566
|
-
invoke(input: RunInput, options?: Partial<
|
|
567
|
-
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<
|
|
568
|
-
transform(generator: AsyncGenerator<RunInput>, options?: Partial<
|
|
569
|
-
stream(input: RunInput, options?: Partial<
|
|
563
|
+
static from<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>): RunnableLambda<RunInput, RunOutput, CallOptions>;
|
|
564
|
+
static from<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(func: TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>>): RunnableLambda<RunInput, RunOutput, CallOptions>;
|
|
565
|
+
_invoke(input: RunInput, config?: Partial<CallOptions>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
|
|
566
|
+
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
567
|
+
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
|
|
568
|
+
transform(generator: AsyncGenerator<RunInput>, options?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
|
|
569
|
+
stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStream<RunOutput>>;
|
|
570
570
|
}
|
|
571
571
|
export declare class RunnableParallel<RunInput> extends RunnableMap<RunInput> {
|
|
572
572
|
}
|
|
@@ -610,7 +610,7 @@ export declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable
|
|
|
610
610
|
}): Promise<(RunOutput | Error)[]>;
|
|
611
611
|
batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
|
|
612
612
|
}
|
|
613
|
-
export declare function _coerceToRunnable<RunInput, RunOutput>(coerceable: RunnableLike<RunInput, RunOutput>): Runnable<RunInput, Exclude<RunOutput, Error
|
|
613
|
+
export declare function _coerceToRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(coerceable: RunnableLike<RunInput, RunOutput, CallOptions>): Runnable<RunInput, Exclude<RunOutput, Error>, CallOptions>;
|
|
614
614
|
export interface RunnableAssignFields<RunInput> {
|
|
615
615
|
mapper: RunnableMap<RunInput>;
|
|
616
616
|
}
|
|
@@ -70,9 +70,7 @@ const passthrough_js_1 = require("./passthrough.cjs");
|
|
|
70
70
|
*/
|
|
71
71
|
class RunnableWithMessageHistory extends base_js_1.RunnableBinding {
|
|
72
72
|
constructor(fields) {
|
|
73
|
-
let historyChain =
|
|
74
|
-
func: (input, options) => this._enterHistory(input, options ?? {}),
|
|
75
|
-
}).withConfig({ runName: "loadHistory" });
|
|
73
|
+
let historyChain = base_js_1.RunnableLambda.from((input, options) => this._enterHistory(input, options ?? {})).withConfig({ runName: "loadHistory" });
|
|
76
74
|
const messagesKey = fields.historyMessagesKey ?? fields.inputMessagesKey;
|
|
77
75
|
if (messagesKey) {
|
|
78
76
|
historyChain = passthrough_js_1.RunnablePassthrough.assign({
|
|
@@ -67,9 +67,7 @@ import { RunnablePassthrough } from "./passthrough.js";
|
|
|
67
67
|
*/
|
|
68
68
|
export class RunnableWithMessageHistory extends RunnableBinding {
|
|
69
69
|
constructor(fields) {
|
|
70
|
-
let historyChain =
|
|
71
|
-
func: (input, options) => this._enterHistory(input, options ?? {}),
|
|
72
|
-
}).withConfig({ runName: "loadHistory" });
|
|
70
|
+
let historyChain = RunnableLambda.from((input, options) => this._enterHistory(input, options ?? {})).withConfig({ runName: "loadHistory" });
|
|
73
71
|
const messagesKey = fields.historyMessagesKey ?? fields.inputMessagesKey;
|
|
74
72
|
if (messagesKey) {
|
|
75
73
|
historyChain = RunnablePassthrough.assign({
|