@langchain/core 0.2.34 → 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.
@@ -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?: RunnableConfig;
17
- } & RunnableConfig) | Record<string, any> | (Record<string, any> & {
16
+ config?: CallOptions;
17
+ } & CallOptions) | Record<string, any> | (Record<string, any> & {
18
18
  /** @deprecated Use top-level config fields instead. */
19
- config: RunnableConfig;
20
- } & RunnableConfig)) => RunOutput | Promise<RunOutput>;
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;
@@ -485,7 +485,7 @@ export declare class RunnableSequence<RunInput = any, RunOutput = any> extends R
485
485
  last: Runnable<any, RunOutput>;
486
486
  name?: string;
487
487
  });
488
- get steps(): Runnable<any, any, RunnableConfig>[];
488
+ get steps(): Runnable<any, any, RunnableConfig<Record<string, any>>>[];
489
489
  invoke(input: RunInput, options?: RunnableConfig): Promise<RunOutput>;
490
490
  batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
491
491
  returnExceptions?: false;
@@ -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>> | TraceableFunction<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>>): RunnableLambda<RunInput, RunOutput>;
564
- static from<RunInput, RunOutput>(func: TraceableFunction<RunnableFunc<RunInput, RunOutput | Runnable<RunInput, RunOutput>>>): RunnableLambda<RunInput, RunOutput>;
565
- _invoke(input: RunInput, config?: Partial<RunnableConfig>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
566
- invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
567
- _transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
568
- transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
569
- stream(input: RunInput, options?: Partial<RunnableConfig>): Promise<IterableReadableStream<RunOutput>>;
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
  }
@@ -599,7 +599,7 @@ export declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable
599
599
  runnable: Runnable<RunInput, RunOutput>;
600
600
  fallbacks: Runnable<RunInput, RunOutput>[];
601
601
  });
602
- runnables(): Generator<Runnable<RunInput, RunOutput, RunnableConfig>, void, unknown>;
602
+ runnables(): Generator<Runnable<RunInput, RunOutput, RunnableConfig<Record<string, any>>>, void, unknown>;
603
603
  invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
604
604
  _streamIterator(input: RunInput, options?: Partial<RunnableConfig> | undefined): AsyncGenerator<RunOutput>;
605
605
  batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
@@ -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
  }
@@ -15,7 +15,7 @@ export declare class Graph {
15
15
  */
16
16
  extend(graph: Graph, prefix?: string): ({
17
17
  id: string;
18
- data: RunnableIOSchema | RunnableInterface<any, any, import("./types.js").RunnableConfig>;
18
+ data: RunnableIOSchema | RunnableInterface<any, any, import("./types.js").RunnableConfig<Record<string, any>>>;
19
19
  } | undefined)[];
20
20
  trimFirstNode(): void;
21
21
  trimLastNode(): void;
@@ -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 = new base_js_1.RunnableLambda({
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({
@@ -87,6 +87,6 @@ export declare class RunnableWithMessageHistory<RunInput, RunOutput> extends Run
87
87
  _getOutputMessages(outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;
88
88
  _enterHistory(input: any, kwargs?: RunnableConfig): Promise<BaseMessage[]>;
89
89
  _exitHistory(run: Run, config: RunnableConfig): Promise<void>;
90
- _mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig>>;
90
+ _mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig<Record<string, any>>>>;
91
91
  }
92
92
  export {};
@@ -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 = new RunnableLambda({
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({
@@ -41,12 +41,12 @@ export interface Node {
41
41
  id: string;
42
42
  data: RunnableIOSchema | RunnableInterface;
43
43
  }
44
- export interface RunnableConfig extends BaseCallbackConfig {
44
+ export interface RunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends BaseCallbackConfig {
45
45
  /**
46
46
  * Runtime values for attributes previously made configurable on this Runnable,
47
47
  * or sub-Runnables.
48
48
  */
49
- configurable?: Record<string, any>;
49
+ configurable?: ConfigurableFieldType;
50
50
  /**
51
51
  * Maximum number of times a call can recurse. If not provided, defaults to 25.
52
52
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {