@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.
Files changed (190) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/agents.d.cts +2 -0
  3. package/dist/agents.d.ts +2 -0
  4. package/dist/callbacks/base.d.cts +60 -22
  5. package/dist/callbacks/base.d.ts +60 -22
  6. package/dist/callbacks/dispatch/index.d.cts +3 -1
  7. package/dist/callbacks/dispatch/index.d.ts +3 -1
  8. package/dist/callbacks/dispatch/web.d.cts +3 -1
  9. package/dist/callbacks/dispatch/web.d.ts +3 -1
  10. package/dist/callbacks/manager.d.cts +12 -2
  11. package/dist/callbacks/manager.d.ts +12 -2
  12. package/dist/chat_history.d.cts +1 -0
  13. package/dist/chat_history.d.ts +1 -0
  14. package/dist/document_loaders/langsmith.d.cts +3 -0
  15. package/dist/document_loaders/langsmith.d.ts +3 -0
  16. package/dist/documents/document.d.cts +12 -3
  17. package/dist/documents/document.d.ts +12 -3
  18. package/dist/example_selectors/length_based.d.cts +1 -1
  19. package/dist/example_selectors/length_based.d.ts +1 -1
  20. package/dist/indexing/base.d.cts +1 -0
  21. package/dist/indexing/base.d.ts +1 -0
  22. package/dist/indexing/record_manager.d.cts +1 -0
  23. package/dist/indexing/record_manager.d.ts +1 -0
  24. package/dist/language_models/base.d.cts +38 -8
  25. package/dist/language_models/base.d.ts +38 -8
  26. package/dist/language_models/chat_models.d.cts +33 -6
  27. package/dist/language_models/chat_models.d.ts +33 -6
  28. package/dist/language_models/llms.d.cts +6 -0
  29. package/dist/language_models/llms.d.ts +6 -0
  30. package/dist/load/import_type.d.cts +1 -0
  31. package/dist/load/import_type.d.ts +1 -0
  32. package/dist/load/map_keys.cjs +5 -4
  33. package/dist/load/map_keys.cjs.map +1 -1
  34. package/dist/load/map_keys.d.cts +1 -0
  35. package/dist/load/map_keys.d.ts +1 -0
  36. package/dist/load/map_keys.js +3 -3
  37. package/dist/load/map_keys.js.map +1 -1
  38. package/dist/load/serializable.d.cts +1 -0
  39. package/dist/load/serializable.d.ts +1 -0
  40. package/dist/memory.d.cts +3 -0
  41. package/dist/memory.d.ts +3 -0
  42. package/dist/messages/base.d.cts +13 -1
  43. package/dist/messages/base.d.ts +13 -1
  44. package/dist/messages/content/data.d.cts +7 -2
  45. package/dist/messages/content/data.d.ts +7 -2
  46. package/dist/messages/content/index.d.cts +4 -1
  47. package/dist/messages/content/index.d.ts +4 -1
  48. package/dist/messages/content/multimodal.d.cts +1 -0
  49. package/dist/messages/content/multimodal.d.ts +1 -0
  50. package/dist/messages/content/tools.d.cts +1 -0
  51. package/dist/messages/content/tools.d.ts +1 -0
  52. package/dist/messages/tool.d.cts +9 -2
  53. package/dist/messages/tool.d.ts +9 -2
  54. package/dist/messages/transformers.d.cts +3 -0
  55. package/dist/messages/transformers.d.ts +3 -0
  56. package/dist/messages/utils.d.cts +5 -2
  57. package/dist/messages/utils.d.ts +5 -2
  58. package/dist/output_parsers/json.d.cts +5 -1
  59. package/dist/output_parsers/json.d.ts +5 -1
  60. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +6 -2
  61. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +6 -2
  62. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +34 -10
  63. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +34 -10
  64. package/dist/output_parsers/transform.d.cts +1 -0
  65. package/dist/output_parsers/transform.d.ts +1 -0
  66. package/dist/outputs.d.cts +6 -0
  67. package/dist/outputs.d.ts +6 -0
  68. package/dist/prompts/base.d.cts +10 -2
  69. package/dist/prompts/base.d.ts +10 -2
  70. package/dist/prompts/chat.d.cts +51 -13
  71. package/dist/prompts/chat.d.ts +51 -13
  72. package/dist/prompts/few_shot.d.cts +5 -1
  73. package/dist/prompts/few_shot.d.ts +5 -1
  74. package/dist/prompts/image.d.cts +10 -2
  75. package/dist/prompts/image.d.ts +10 -2
  76. package/dist/prompts/prompt.d.cts +15 -4
  77. package/dist/prompts/prompt.d.ts +16 -4
  78. package/dist/prompts/serde.d.cts +1 -0
  79. package/dist/prompts/serde.d.ts +1 -0
  80. package/dist/prompts/string.d.cts +5 -1
  81. package/dist/prompts/string.d.ts +5 -1
  82. package/dist/prompts/structured.d.cts +16 -3
  83. package/dist/prompts/structured.d.ts +16 -3
  84. package/dist/retrievers/document_compressors/index.d.cts +1 -0
  85. package/dist/retrievers/document_compressors/index.d.ts +1 -0
  86. package/dist/retrievers/index.d.cts +6 -2
  87. package/dist/retrievers/index.d.ts +6 -2
  88. package/dist/runnables/base.cjs +7 -7
  89. package/dist/runnables/base.cjs.map +1 -1
  90. package/dist/runnables/base.d.cts +64 -12
  91. package/dist/runnables/base.d.ts +64 -12
  92. package/dist/runnables/base.js +1 -1
  93. package/dist/runnables/base.js.map +1 -1
  94. package/dist/runnables/branch.d.cts +2 -0
  95. package/dist/runnables/branch.d.ts +2 -0
  96. package/dist/runnables/config.d.cts +1 -0
  97. package/dist/runnables/config.d.ts +1 -0
  98. package/dist/runnables/graph.d.cts +5 -1
  99. package/dist/runnables/graph.d.ts +5 -1
  100. package/dist/runnables/history.d.cts +12 -4
  101. package/dist/runnables/history.d.ts +12 -4
  102. package/dist/runnables/passthrough.d.cts +2 -0
  103. package/dist/runnables/passthrough.d.ts +2 -0
  104. package/dist/runnables/router.d.cts +1 -0
  105. package/dist/runnables/router.d.ts +1 -0
  106. package/dist/runnables/types.d.cts +9 -2
  107. package/dist/runnables/types.d.ts +9 -2
  108. package/dist/singletons/async_local_storage/context.d.cts +2 -0
  109. package/dist/singletons/async_local_storage/context.d.ts +2 -0
  110. package/dist/singletons/async_local_storage/globals.d.cts +1 -0
  111. package/dist/singletons/async_local_storage/globals.d.ts +1 -0
  112. package/dist/singletons/callbacks.cjs.map +1 -1
  113. package/dist/singletons/callbacks.js.map +1 -1
  114. package/dist/stores.d.cts +1 -0
  115. package/dist/stores.d.ts +1 -0
  116. package/dist/structured_query/utils.d.cts +4 -1
  117. package/dist/structured_query/utils.d.ts +4 -1
  118. package/dist/tools/index.d.cts +6 -1
  119. package/dist/tools/index.d.ts +6 -1
  120. package/dist/tools/types.d.cts +13 -3
  121. package/dist/tools/types.d.ts +13 -3
  122. package/dist/tracers/base.d.cts +20 -1
  123. package/dist/tracers/base.d.ts +20 -1
  124. package/dist/tracers/console.cjs +3 -3
  125. package/dist/tracers/console.cjs.map +1 -1
  126. package/dist/tracers/console.d.cts +2 -0
  127. package/dist/tracers/console.d.ts +2 -0
  128. package/dist/tracers/console.js +3 -3
  129. package/dist/tracers/console.js.map +1 -1
  130. package/dist/tracers/event_stream.d.cts +4 -0
  131. package/dist/tracers/event_stream.d.ts +4 -0
  132. package/dist/tracers/log_stream.d.cts +6 -0
  133. package/dist/tracers/log_stream.d.ts +6 -0
  134. package/dist/types/_internal.d.cts +3 -0
  135. package/dist/types/_internal.d.ts +3 -0
  136. package/dist/types/type-utils.d.cts +2 -0
  137. package/dist/types/type-utils.d.ts +2 -0
  138. package/dist/utils/async_caller.cjs +1 -1
  139. package/dist/utils/async_caller.cjs.map +1 -1
  140. package/dist/utils/async_caller.d.cts +3 -0
  141. package/dist/utils/async_caller.d.ts +3 -0
  142. package/dist/utils/async_caller.js +1 -1
  143. package/dist/utils/async_caller.js.map +1 -1
  144. package/dist/utils/env.d.cts +4 -0
  145. package/dist/utils/env.d.ts +4 -0
  146. package/dist/utils/event_source_parse.d.cts +4 -1
  147. package/dist/utils/event_source_parse.d.ts +4 -1
  148. package/dist/utils/function_calling.d.cts +3 -1
  149. package/dist/utils/function_calling.d.ts +3 -1
  150. package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.cjs +1 -1
  151. package/dist/utils/is-network-error/index.cjs.map +1 -0
  152. package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.js +1 -1
  153. package/dist/utils/is-network-error/index.js.map +1 -0
  154. package/dist/utils/json.d.cts +1 -0
  155. package/dist/utils/json.d.ts +1 -0
  156. package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.cjs +2 -2
  157. package/dist/utils/p-retry/index.cjs.map +1 -0
  158. package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.js +2 -2
  159. package/dist/utils/p-retry/index.js.map +1 -0
  160. package/dist/utils/stream.d.cts +13 -1
  161. package/dist/utils/stream.d.ts +13 -1
  162. package/dist/utils/testing/chat_models.d.cts +11 -3
  163. package/dist/utils/testing/chat_models.d.ts +11 -3
  164. package/dist/utils/testing/retrievers.d.cts +3 -1
  165. package/dist/utils/testing/retrievers.d.ts +3 -1
  166. package/dist/utils/testing/vectorstores.d.cts +1 -0
  167. package/dist/utils/testing/vectorstores.d.ts +1 -0
  168. package/dist/utils/types/index.d.cts +2 -0
  169. package/dist/utils/types/index.d.ts +2 -0
  170. package/dist/utils/types/zod.d.cts +3 -0
  171. package/dist/utils/types/zod.d.ts +3 -0
  172. package/dist/vectorstores.d.cts +17 -5
  173. package/dist/vectorstores.d.ts +17 -5
  174. package/package.json +5 -6
  175. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +0 -169
  176. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +0 -1
  177. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +0 -168
  178. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +0 -1
  179. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +0 -122
  180. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +0 -1
  181. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +0 -121
  182. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +0 -1
  183. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +0 -18
  184. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +0 -1
  185. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +0 -17
  186. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +0 -1
  187. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +0 -1
  188. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +0 -1
  189. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +0 -1
  190. 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 | Record<string, any> | (Record<string, any> & CallOptions)) => RunOutput | Promise<RunOutput>;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
17
- type RunnableRetryFailedAttemptHandler = (error: any, input: any) => any;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends Serializable implements RunnableInterface<RunInput, RunOutput, CallOptions> {
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(thing: any): thing is RunnableBinding<any, any, any>;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends RunnableBinding<RunInput, RunOutput, CallOptions> {
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<RunInput = any, RunOutput = any> extends Runnable<RunInput, RunOutput> {
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
- static from<RunInput = any, RunOutput = any>([first, ...runnables]: [RunnableLike<RunInput>, ...RunnableLike[], RunnableLike<any, RunOutput>], nameOrFields?: string | Omit<RunnableSequenceFields<RunInput, RunOutput>, "first" | "middle" | "last">): RunnableSequence<RunInput, Exclude<RunOutput, Error>>;
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<RunInput = any, RunOutput extends Record<string, any> = Record<string, any>> extends Runnable<RunInput, RunOutput> {
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, RunOutput extends Record<string, any> = Record<string, any>>(steps: RunnableMapLike<RunInput, RunOutput>): RunnableMap<RunInput, RunOutput>;
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<RunInput extends Record<string, any> = Record<string, any>, RunOutput extends Record<string, any> = Record<string, any>, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnableAssignFields<RunInput> {
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<RunInput extends Record<string, any> = Record<string, any>, RunOutput extends Record<string, any> | any = Record<string, any> | any, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnablePickFields {
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;
@@ -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 | Record<string, any> | (Record<string, any> & CallOptions)) => RunOutput | Promise<RunOutput>;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> = RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>;
17
- type RunnableRetryFailedAttemptHandler = (error: any, input: any) => any;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends Serializable implements RunnableInterface<RunInput, RunOutput, CallOptions> {
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(thing: any): thing is RunnableBinding<any, any, any>;
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<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends RunnableBinding<RunInput, RunOutput, CallOptions> {
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<RunInput = any, RunOutput = any> extends Runnable<RunInput, RunOutput> {
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
- static from<RunInput = any, RunOutput = any>([first, ...runnables]: [RunnableLike<RunInput>, ...RunnableLike[], RunnableLike<any, RunOutput>], nameOrFields?: string | Omit<RunnableSequenceFields<RunInput, RunOutput>, "first" | "middle" | "last">): RunnableSequence<RunInput, Exclude<RunOutput, Error>>;
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<RunInput = any, RunOutput extends Record<string, any> = Record<string, any>> extends Runnable<RunInput, RunOutput> {
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, RunOutput extends Record<string, any> = Record<string, any>>(steps: RunnableMapLike<RunInput, RunOutput>): RunnableMap<RunInput, RunOutput>;
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<RunInput extends Record<string, any> = Record<string, any>, RunOutput extends Record<string, any> = Record<string, any>, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnableAssignFields<RunInput> {
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<RunInput extends Record<string, any> = Record<string, any>, RunOutput extends Record<string, any> | any = Record<string, any> | any, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> implements RunnablePickFields {
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;
@@ -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";