@langchain/core 0.3.8 → 0.3.9-rc.1
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,11 +11,11 @@ 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: CallOptions | Record<string, any> | (Record<string, any> & CallOptions)) => RunOutput | Promise<RunOutput>;
|
|
15
15
|
export type RunnableMapLike<RunInput, RunOutput> = {
|
|
16
16
|
[K in keyof RunOutput]: RunnableLike<RunInput, RunOutput[K]>;
|
|
17
17
|
};
|
|
18
|
-
export type RunnableLike<RunInput = any, RunOutput = any> = RunnableInterface<RunInput, RunOutput> | RunnableFunc<RunInput, RunOutput> | RunnableMapLike<RunInput, RunOutput>;
|
|
18
|
+
export type RunnableLike<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
|
|
19
19
|
export type RunnableRetryFailedAttemptHandler = (error: any, input: any) => any;
|
|
20
20
|
export declare function _coerceToDict(value: any, defaultKey: string): any;
|
|
21
21
|
/**
|
|
@@ -117,7 +117,7 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
117
117
|
* Output values, with callbacks.
|
|
118
118
|
* Use this to implement `stream()` or `transform()` in Runnable subclasses.
|
|
119
119
|
*/
|
|
120
|
-
protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: CallbackManagerForChainRun, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: CallOptions & {
|
|
120
|
+
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> & {
|
|
121
121
|
runType?: string;
|
|
122
122
|
}): AsyncGenerator<O>;
|
|
123
123
|
getGraph(_?: RunnableConfig): Graph;
|
|
@@ -547,20 +547,20 @@ export declare class RunnableTraceable<RunInput, RunOutput> extends Runnable<Run
|
|
|
547
547
|
/**
|
|
548
548
|
* A runnable that runs a callable.
|
|
549
549
|
*/
|
|
550
|
-
export declare class RunnableLambda<RunInput, RunOutput> extends Runnable<RunInput, RunOutput> {
|
|
550
|
+
export declare class RunnableLambda<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> {
|
|
551
551
|
static lc_name(): string;
|
|
552
552
|
lc_namespace: string[];
|
|
553
|
-
protected func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
553
|
+
protected func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>;
|
|
554
554
|
constructor(fields: {
|
|
555
|
-
func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
555
|
+
func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions> | TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>>;
|
|
556
556
|
});
|
|
557
|
-
static from<RunInput, RunOutput>(func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
558
|
-
static from<RunInput, RunOutput>(func: TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput
|
|
559
|
-
_invoke(input: RunInput, config?: Partial<
|
|
560
|
-
invoke(input: RunInput, options?: Partial<
|
|
561
|
-
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<
|
|
562
|
-
transform(generator: AsyncGenerator<RunInput>, options?: Partial<
|
|
563
|
-
stream(input: RunInput, options?: Partial<
|
|
557
|
+
static from<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(func: RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>): RunnableLambda<RunInput, RunOutput, CallOptions>;
|
|
558
|
+
static from<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(func: TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput, CallOptions>, CallOptions>>): RunnableLambda<RunInput, RunOutput, CallOptions>;
|
|
559
|
+
_invoke(input: RunInput, config?: Partial<CallOptions>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
|
|
560
|
+
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
561
|
+
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
|
|
562
|
+
transform(generator: AsyncGenerator<RunInput>, options?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
|
|
563
|
+
stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStream<RunOutput>>;
|
|
564
564
|
}
|
|
565
565
|
export declare class RunnableParallel<RunInput> extends RunnableMap<RunInput> {
|
|
566
566
|
}
|
|
@@ -604,7 +604,7 @@ export declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable
|
|
|
604
604
|
}): Promise<(RunOutput | Error)[]>;
|
|
605
605
|
batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
|
|
606
606
|
}
|
|
607
|
-
export declare function _coerceToRunnable<RunInput, RunOutput>(coerceable: RunnableLike<RunInput, RunOutput>): Runnable<RunInput, Exclude<RunOutput, Error
|
|
607
|
+
export declare function _coerceToRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig>(coerceable: RunnableLike<RunInput, RunOutput, CallOptions>): Runnable<RunInput, Exclude<RunOutput, Error>, CallOptions>;
|
|
608
608
|
export interface RunnableAssignFields<RunInput> {
|
|
609
609
|
mapper: RunnableMap<RunInput>;
|
|
610
610
|
}
|
|
@@ -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({
|