langchain 0.0.195 → 0.0.196

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 (216) hide show
  1. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
  2. package/dist/base_language/count_tokens.cjs +5 -70
  3. package/dist/base_language/count_tokens.d.ts +1 -10
  4. package/dist/base_language/count_tokens.js +1 -65
  5. package/dist/base_language/index.cjs +6 -196
  6. package/dist/base_language/index.d.ts +1 -111
  7. package/dist/base_language/index.js +1 -191
  8. package/dist/cache/base.cjs +15 -37
  9. package/dist/cache/base.d.ts +1 -20
  10. package/dist/cache/base.js +1 -33
  11. package/dist/cache/index.cjs +2 -46
  12. package/dist/cache/index.d.ts +1 -29
  13. package/dist/cache/index.js +1 -45
  14. package/dist/callbacks/base.cjs +3 -139
  15. package/dist/callbacks/base.d.ts +1 -266
  16. package/dist/callbacks/base.js +1 -126
  17. package/dist/callbacks/handlers/console.cjs +14 -221
  18. package/dist/callbacks/handlers/console.d.ts +1 -117
  19. package/dist/callbacks/handlers/console.js +1 -217
  20. package/dist/callbacks/handlers/initialize.cjs +15 -30
  21. package/dist/callbacks/handlers/initialize.d.ts +1 -16
  22. package/dist/callbacks/handlers/initialize.js +1 -27
  23. package/dist/callbacks/handlers/log_stream.cjs +15 -293
  24. package/dist/callbacks/handlers/log_stream.d.ts +1 -100
  25. package/dist/callbacks/handlers/log_stream.js +1 -289
  26. package/dist/callbacks/handlers/run_collector.cjs +15 -48
  27. package/dist/callbacks/handlers/run_collector.d.ts +1 -26
  28. package/dist/callbacks/handlers/run_collector.js +1 -46
  29. package/dist/callbacks/handlers/tracer.cjs +15 -375
  30. package/dist/callbacks/handlers/tracer.d.ts +1 -70
  31. package/dist/callbacks/handlers/tracer.js +1 -373
  32. package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
  33. package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
  34. package/dist/callbacks/handlers/tracer_langchain.js +1 -102
  35. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
  36. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
  37. package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
  38. package/dist/callbacks/manager.cjs +15 -676
  39. package/dist/callbacks/manager.d.ts +1 -180
  40. package/dist/callbacks/manager.js +1 -666
  41. package/dist/callbacks/promises.cjs +14 -42
  42. package/dist/callbacks/promises.d.ts +1 -11
  43. package/dist/callbacks/promises.js +1 -37
  44. package/dist/chains/graph_qa/prompts.d.ts +1 -1
  45. package/dist/chains/openai_functions/structured_output.cjs +2 -2
  46. package/dist/chains/openai_functions/structured_output.d.ts +1 -1
  47. package/dist/chains/openai_functions/structured_output.js +1 -1
  48. package/dist/chat_models/baiduwenxin.d.ts +1 -1
  49. package/dist/chat_models/base.cjs +15 -296
  50. package/dist/chat_models/base.d.ts +1 -122
  51. package/dist/chat_models/base.js +1 -292
  52. package/dist/chat_models/bedrock/web.d.ts +1 -1
  53. package/dist/chat_models/fireworks.d.ts +1 -1
  54. package/dist/document.cjs +2 -24
  55. package/dist/document.d.ts +1 -12
  56. package/dist/document.js +1 -23
  57. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
  58. package/dist/document_loaders/web/s3.d.ts +1 -1
  59. package/dist/embeddings/base.cjs +15 -22
  60. package/dist/embeddings/base.d.ts +1 -33
  61. package/dist/embeddings/base.js +1 -20
  62. package/dist/embeddings/cache_backed.cjs +2 -2
  63. package/dist/embeddings/cache_backed.js +1 -1
  64. package/dist/evaluation/agents/trajectory.d.ts +1 -1
  65. package/dist/evaluation/criteria/prompt.d.ts +2 -2
  66. package/dist/evaluation/qa/prompt.d.ts +2 -2
  67. package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
  68. package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
  69. package/dist/llms/base.cjs +15 -278
  70. package/dist/llms/base.d.ts +1 -115
  71. package/dist/llms/base.js +1 -275
  72. package/dist/llms/bedrock/web.d.ts +1 -1
  73. package/dist/llms/fireworks.d.ts +1 -1
  74. package/dist/load/import_map.cjs +2 -1
  75. package/dist/load/import_map.d.ts +1 -0
  76. package/dist/load/import_map.js +1 -0
  77. package/dist/load/index.cjs +7 -148
  78. package/dist/load/index.js +7 -148
  79. package/dist/load/map_keys.cjs +0 -24
  80. package/dist/load/map_keys.d.ts +0 -6
  81. package/dist/load/map_keys.js +1 -17
  82. package/dist/load/serializable.cjs +15 -178
  83. package/dist/load/serializable.d.ts +1 -66
  84. package/dist/load/serializable.js +1 -175
  85. package/dist/memory/base.cjs +17 -92
  86. package/dist/memory/base.d.ts +2 -68
  87. package/dist/memory/base.js +2 -87
  88. package/dist/output_parsers/openai_functions.cjs +2 -2
  89. package/dist/output_parsers/openai_functions.d.ts +1 -1
  90. package/dist/output_parsers/openai_functions.js +1 -1
  91. package/dist/output_parsers/regex.d.ts +1 -1
  92. package/dist/output_parsers/structured.d.ts +1 -1
  93. package/dist/prompts/base.cjs +8 -183
  94. package/dist/prompts/base.d.ts +3 -132
  95. package/dist/prompts/base.js +3 -178
  96. package/dist/prompts/chat.cjs +15 -477
  97. package/dist/prompts/chat.d.ts +1 -219
  98. package/dist/prompts/chat.js +1 -466
  99. package/dist/prompts/few_shot.cjs +15 -353
  100. package/dist/prompts/few_shot.d.ts +1 -192
  101. package/dist/prompts/few_shot.js +1 -350
  102. package/dist/prompts/index.cjs +3 -2
  103. package/dist/prompts/index.d.ts +2 -1
  104. package/dist/prompts/index.js +2 -1
  105. package/dist/prompts/pipeline.cjs +15 -142
  106. package/dist/prompts/pipeline.d.ts +1 -98
  107. package/dist/prompts/pipeline.js +1 -140
  108. package/dist/prompts/prompt.cjs +15 -146
  109. package/dist/prompts/prompt.d.ts +1 -92
  110. package/dist/prompts/prompt.js +1 -144
  111. package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +15 -148
  112. package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
  113. package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
  114. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
  115. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
  116. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
  117. package/dist/prompts/selectors/conditional.cjs +15 -74
  118. package/dist/prompts/selectors/conditional.d.ts +1 -63
  119. package/dist/prompts/selectors/conditional.js +1 -69
  120. package/dist/prompts/serde.cjs +15 -0
  121. package/dist/prompts/serde.d.ts +1 -43
  122. package/dist/prompts/serde.js +1 -1
  123. package/dist/prompts/template.cjs +14 -88
  124. package/dist/prompts/template.d.ts +1 -36
  125. package/dist/prompts/template.js +1 -83
  126. package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
  127. package/dist/runnables/index.d.ts +1 -0
  128. package/dist/runnables/index.js +1 -0
  129. package/dist/schema/document.cjs +3 -34
  130. package/dist/schema/document.d.ts +2 -29
  131. package/dist/schema/document.js +2 -32
  132. package/dist/schema/index.cjs +37 -612
  133. package/dist/schema/index.d.ts +11 -311
  134. package/dist/schema/index.js +8 -583
  135. package/dist/schema/output_parser.cjs +15 -309
  136. package/dist/schema/output_parser.d.ts +1 -173
  137. package/dist/schema/output_parser.js +1 -301
  138. package/dist/schema/retriever.cjs +15 -77
  139. package/dist/schema/retriever.d.ts +1 -43
  140. package/dist/schema/retriever.js +1 -75
  141. package/dist/schema/runnable/base.cjs +10 -1072
  142. package/dist/schema/runnable/base.d.ts +1 -356
  143. package/dist/schema/runnable/base.js +1 -1060
  144. package/dist/schema/runnable/branch.cjs +2 -131
  145. package/dist/schema/runnable/branch.d.ts +1 -94
  146. package/dist/schema/runnable/branch.js +1 -130
  147. package/dist/schema/runnable/config.cjs +0 -6
  148. package/dist/schema/runnable/config.d.ts +1 -3
  149. package/dist/schema/runnable/config.js +1 -4
  150. package/dist/schema/runnable/index.cjs +15 -16
  151. package/dist/schema/runnable/index.d.ts +1 -5
  152. package/dist/schema/runnable/index.js +1 -4
  153. package/dist/schema/runnable/passthrough.cjs +3 -113
  154. package/dist/schema/runnable/passthrough.d.ts +1 -72
  155. package/dist/schema/runnable/passthrough.js +1 -111
  156. package/dist/schema/runnable/router.cjs +2 -71
  157. package/dist/schema/runnable/router.d.ts +1 -29
  158. package/dist/schema/runnable/router.js +1 -70
  159. package/dist/schema/storage.cjs +15 -8
  160. package/dist/schema/storage.d.ts +1 -57
  161. package/dist/schema/storage.js +1 -6
  162. package/dist/tools/bingserpapi.d.ts +1 -1
  163. package/dist/tools/searchapi.d.ts +1 -1
  164. package/dist/tools/serpapi.d.ts +1 -1
  165. package/dist/tools/serper.d.ts +1 -1
  166. package/dist/util/async_caller.cjs +14 -128
  167. package/dist/util/async_caller.d.ts +1 -45
  168. package/dist/util/async_caller.js +1 -124
  169. package/package.json +11 -5
  170. package/runnables.cjs +1 -0
  171. package/runnables.d.ts +1 -0
  172. package/runnables.js +1 -0
  173. package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
  174. package/dist/util/@cfworker/json-schema/index.js +0 -1
  175. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  176. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  177. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  178. package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
  179. package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
  180. package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
  181. package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
  182. package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
  183. package/dist/util/@cfworker/json-schema/src/format.js +0 -136
  184. package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
  185. package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
  186. package/dist/util/@cfworker/json-schema/src/index.js +0 -8
  187. package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
  188. package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
  189. package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
  190. package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
  191. package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
  192. package/dist/util/@cfworker/json-schema/src/types.js +0 -1
  193. package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  194. package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  195. package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
  196. package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
  197. package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
  198. package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
  199. package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
  200. package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
  201. package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
  202. package/dist/util/fast-json-patch/index.cjs +0 -49
  203. package/dist/util/fast-json-patch/index.d.ts +0 -22
  204. package/dist/util/fast-json-patch/index.js +0 -16
  205. package/dist/util/fast-json-patch/src/core.cjs +0 -469
  206. package/dist/util/fast-json-patch/src/core.d.ts +0 -111
  207. package/dist/util/fast-json-patch/src/core.js +0 -459
  208. package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
  209. package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
  210. package/dist/util/fast-json-patch/src/duplex.js +0 -230
  211. package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
  212. package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
  213. package/dist/util/fast-json-patch/src/helpers.js +0 -181
  214. package/dist/util/js-sha1/hash.cjs +0 -358
  215. package/dist/util/js-sha1/hash.d.ts +0 -1
  216. package/dist/util/js-sha1/hash.js +0 -355
@@ -1,356 +1 @@
1
- import { CallbackManager, CallbackManagerForChainRun, BaseCallbackConfig } from "../../callbacks/manager.js";
2
- import { LogStreamCallbackHandlerInput, RunLogPatch } from "../../callbacks/handlers/log_stream.js";
3
- import { Serializable } from "../../load/serializable.js";
4
- import { IterableReadableStream } from "../../util/stream.js";
5
- import { RunnableConfig } from "./config.js";
6
- export type RunnableFunc<RunInput, RunOutput> = (input: RunInput) => RunOutput | Promise<RunOutput>;
7
- export type RunnableLike<RunInput = any, RunOutput = any> = Runnable<RunInput, RunOutput> | RunnableFunc<RunInput, RunOutput> | {
8
- [key: string]: RunnableLike<RunInput, RunOutput>;
9
- };
10
- export type RunnableBatchOptions = {
11
- maxConcurrency?: number;
12
- returnExceptions?: boolean;
13
- };
14
- export type RunnableRetryFailedAttemptHandler = (error: any) => any;
15
- /**
16
- * A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or
17
- * transformed.
18
- */
19
- export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends Serializable {
20
- protected lc_runnable: boolean;
21
- abstract invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
22
- /**
23
- * Bind arguments to a Runnable, returning a new Runnable.
24
- * @param kwargs
25
- * @returns A new RunnableBinding that, when invoked, will apply the bound args.
26
- */
27
- bind(kwargs: Partial<CallOptions>): Runnable<RunInput, RunOutput, CallOptions>;
28
- /**
29
- * Return a new Runnable that maps a list of inputs to a list of outputs,
30
- * by calling invoke() with each input.
31
- */
32
- map(): Runnable<RunInput[], RunOutput[], CallOptions>;
33
- /**
34
- * Add retry logic to an existing runnable.
35
- * @param kwargs
36
- * @returns A new RunnableRetry that, when invoked, will retry according to the parameters.
37
- */
38
- withRetry(fields?: {
39
- stopAfterAttempt?: number;
40
- onFailedAttempt?: RunnableRetryFailedAttemptHandler;
41
- }): RunnableRetry<RunInput, RunOutput, CallOptions>;
42
- /**
43
- * Bind config to a Runnable, returning a new Runnable.
44
- * @param config New configuration parameters to attach to the new runnable.
45
- * @returns A new RunnableBinding with a config matching what's passed.
46
- */
47
- withConfig(config: RunnableConfig): RunnableBinding<RunInput, RunOutput, CallOptions>;
48
- /**
49
- * Create a new runnable from the current one that will try invoking
50
- * other passed fallback runnables if the initial invocation fails.
51
- * @param fields.fallbacks Other runnables to call if the runnable errors.
52
- * @returns A new RunnableWithFallbacks.
53
- */
54
- withFallbacks(fields: {
55
- fallbacks: Runnable<RunInput, RunOutput>[];
56
- }): RunnableWithFallbacks<RunInput, RunOutput>;
57
- protected _getOptionsList(options: Partial<CallOptions> | Partial<CallOptions>[], length?: number): Partial<CallOptions & {
58
- runType?: string;
59
- }>[];
60
- /**
61
- * Default implementation of batch, which calls invoke N times.
62
- * Subclasses should override this method if they can batch more efficiently.
63
- * @param inputs Array of inputs to each batch call.
64
- * @param options Either a single call options object to apply to each batch call or an array for each call.
65
- * @param batchOptions.maxConcurrency Maximum number of calls to run at once.
66
- * @param batchOptions.returnExceptions Whether to return errors rather than throwing on the first one
67
- * @returns An array of RunOutputs, or mixed RunOutputs and errors if batchOptions.returnExceptions is set
68
- */
69
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
70
- returnExceptions?: false;
71
- }): Promise<RunOutput[]>;
72
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
73
- returnExceptions: true;
74
- }): Promise<(RunOutput | Error)[]>;
75
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
76
- /**
77
- * Default streaming implementation.
78
- * Subclasses should override this method if they support streaming output.
79
- * @param input
80
- * @param options
81
- */
82
- _streamIterator(input: RunInput, options?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
83
- /**
84
- * Stream output in chunks.
85
- * @param input
86
- * @param options
87
- * @returns A readable stream that is also an iterable.
88
- */
89
- stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStream<RunOutput>>;
90
- protected _separateRunnableConfigFromCallOptions(options?: Partial<CallOptions>): [RunnableConfig, Omit<Partial<CallOptions>, keyof RunnableConfig>];
91
- protected _callWithConfig<T extends RunInput>(func: ((input: T) => Promise<RunOutput>) | ((input: T, config?: Partial<CallOptions>, runManager?: CallbackManagerForChainRun) => Promise<RunOutput>), input: T, options?: Partial<CallOptions> & {
92
- runType?: string;
93
- }): Promise<RunOutput>;
94
- /**
95
- * Internal method that handles batching and configuration for a runnable
96
- * It takes a function, input values, and optional configuration, and
97
- * returns a promise that resolves to the output values.
98
- * @param func The function to be executed for each input value.
99
- * @param input The input values to be processed.
100
- * @param config Optional configuration for the function execution.
101
- * @returns A promise that resolves to the output values.
102
- */
103
- _batchWithConfig<T extends RunInput>(func: (inputs: T[], options?: Partial<CallOptions>[], runManagers?: (CallbackManagerForChainRun | undefined)[], batchOptions?: RunnableBatchOptions) => Promise<(RunOutput | Error)[]>, inputs: T[], options?: Partial<CallOptions & {
104
- runType?: string;
105
- }> | Partial<CallOptions & {
106
- runType?: string;
107
- }>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
108
- /**
109
- * Helper method to transform an Iterator of Input values into an Iterator of
110
- * Output values, with callbacks.
111
- * Use this to implement `stream()` or `transform()` in Runnable subclasses.
112
- */
113
- protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: CallbackManagerForChainRun, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: CallOptions & {
114
- runType?: string;
115
- }): AsyncGenerator<O>;
116
- _patchConfig(config?: Partial<CallOptions>, callbackManager?: CallbackManager | undefined): Partial<CallOptions>;
117
- /**
118
- * Create a new runnable sequence that runs each individual runnable in series,
119
- * piping the output of one runnable into another runnable or runnable-like.
120
- * @param coerceable A runnable, function, or object whose values are functions or runnables.
121
- * @returns A new runnable sequence.
122
- */
123
- pipe<NewRunOutput>(coerceable: RunnableLike<RunOutput, NewRunOutput>): RunnableSequence<RunInput, Exclude<NewRunOutput, Error>>;
124
- /**
125
- * Default implementation of transform, which buffers input and then calls stream.
126
- * Subclasses should override this method if they can start producing output while
127
- * input is still being generated.
128
- * @param generator
129
- * @param options
130
- */
131
- transform(generator: AsyncGenerator<RunInput>, options: Partial<CallOptions>): AsyncGenerator<RunOutput>;
132
- /**
133
- * Stream all output from a runnable, as reported to the callback system.
134
- * This includes all inner runs of LLMs, Retrievers, Tools, etc.
135
- * Output is streamed as Log objects, which include a list of
136
- * jsonpatch ops that describe how the state of the run has changed in each
137
- * step, and the final state of the run.
138
- * The jsonpatch ops can be applied in order to construct state.
139
- * @param input
140
- * @param options
141
- * @param streamOptions
142
- */
143
- streamLog(input: RunInput, options?: Partial<CallOptions>, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<RunLogPatch>;
144
- static isRunnable(thing: any): thing is Runnable;
145
- }
146
- export type RunnableBindingArgs<RunInput, RunOutput, CallOptions extends RunnableConfig> = {
147
- bound: Runnable<RunInput, RunOutput, CallOptions>;
148
- kwargs: Partial<CallOptions>;
149
- config: RunnableConfig;
150
- };
151
- /**
152
- * A runnable that delegates calls to another runnable with a set of kwargs.
153
- */
154
- export declare class RunnableBinding<RunInput, RunOutput, CallOptions extends RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> {
155
- static lc_name(): string;
156
- lc_namespace: string[];
157
- lc_serializable: boolean;
158
- bound: Runnable<RunInput, RunOutput, CallOptions>;
159
- config: RunnableConfig;
160
- protected kwargs: Partial<CallOptions>;
161
- constructor(fields: RunnableBindingArgs<RunInput, RunOutput, CallOptions>);
162
- _mergeConfig(options?: Record<string, any>): Partial<CallOptions>;
163
- bind(kwargs: Partial<CallOptions>): RunnableBinding<RunInput, RunOutput, CallOptions>;
164
- withConfig(config: RunnableConfig): RunnableBinding<RunInput, RunOutput, CallOptions>;
165
- withRetry(fields?: {
166
- stopAfterAttempt?: number;
167
- onFailedAttempt?: RunnableRetryFailedAttemptHandler;
168
- }): RunnableRetry<RunInput, RunOutput, CallOptions>;
169
- invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
170
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
171
- returnExceptions?: false;
172
- }): Promise<RunOutput[]>;
173
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
174
- returnExceptions: true;
175
- }): Promise<(RunOutput | Error)[]>;
176
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
177
- _streamIterator(input: RunInput, options?: Partial<CallOptions> | undefined): AsyncGenerator<Awaited<RunOutput>, void, unknown>;
178
- stream(input: RunInput, options?: Partial<CallOptions> | undefined): Promise<IterableReadableStream<RunOutput>>;
179
- transform(generator: AsyncGenerator<RunInput>, options: Partial<CallOptions>): AsyncGenerator<RunOutput>;
180
- static isRunnableBinding(thing: any): thing is RunnableBinding<any, any, any>;
181
- }
182
- /**
183
- * A runnable that delegates calls to another runnable
184
- * with each element of the input sequence.
185
- */
186
- export declare class RunnableEach<RunInputItem, RunOutputItem, CallOptions extends BaseCallbackConfig> extends Runnable<RunInputItem[], RunOutputItem[], CallOptions> {
187
- static lc_name(): string;
188
- lc_serializable: boolean;
189
- lc_namespace: string[];
190
- bound: Runnable<RunInputItem, RunOutputItem, CallOptions>;
191
- constructor(fields: {
192
- bound: Runnable<RunInputItem, RunOutputItem, CallOptions>;
193
- });
194
- /**
195
- * Binds the runnable with the specified arguments.
196
- * @param args The arguments to bind the runnable with.
197
- * @returns A new instance of the `RunnableEach` class that is bound with the specified arguments.
198
- */
199
- bind(kwargs: Partial<CallOptions>): RunnableEach<RunInputItem, RunOutputItem, CallOptions>;
200
- /**
201
- * Invokes the runnable with the specified input and configuration.
202
- * @param input The input to invoke the runnable with.
203
- * @param config The configuration to invoke the runnable with.
204
- * @returns A promise that resolves to the output of the runnable.
205
- */
206
- invoke(inputs: RunInputItem[], config?: Partial<CallOptions>): Promise<RunOutputItem[]>;
207
- /**
208
- * A helper method that is used to invoke the runnable with the specified input and configuration.
209
- * @param input The input to invoke the runnable with.
210
- * @param config The configuration to invoke the runnable with.
211
- * @returns A promise that resolves to the output of the runnable.
212
- */
213
- protected _invoke(inputs: RunInputItem[], config?: Partial<CallOptions>, runManager?: CallbackManagerForChainRun): Promise<RunOutputItem[]>;
214
- }
215
- /**
216
- * Base class for runnables that can be retried a
217
- * specified number of times.
218
- */
219
- export declare class RunnableRetry<RunInput = any, RunOutput = any, CallOptions extends RunnableConfig = RunnableConfig> extends RunnableBinding<RunInput, RunOutput, CallOptions> {
220
- static lc_name(): string;
221
- lc_namespace: string[];
222
- protected maxAttemptNumber: number;
223
- onFailedAttempt?: RunnableRetryFailedAttemptHandler;
224
- constructor(fields: RunnableBindingArgs<RunInput, RunOutput, CallOptions> & {
225
- maxAttemptNumber?: number;
226
- onFailedAttempt?: RunnableRetryFailedAttemptHandler;
227
- });
228
- _patchConfigForRetry(attempt: number, config?: Partial<CallOptions>, runManager?: CallbackManagerForChainRun): Partial<CallOptions>;
229
- protected _invoke(input: RunInput, config?: CallOptions, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
230
- /**
231
- * Method that invokes the runnable with the specified input, run manager,
232
- * and config. It handles the retry logic by catching any errors and
233
- * recursively invoking itself with the updated config for the next retry
234
- * attempt.
235
- * @param input The input for the runnable.
236
- * @param runManager The run manager for the runnable.
237
- * @param config The config for the runnable.
238
- * @returns A promise that resolves to the output of the runnable.
239
- */
240
- invoke(input: RunInput, config?: CallOptions): Promise<RunOutput>;
241
- _batch<ReturnExceptions extends boolean = false>(inputs: RunInput[], configs?: RunnableConfig[], runManagers?: (CallbackManagerForChainRun | undefined)[], batchOptions?: RunnableBatchOptions): Promise<ReturnExceptions extends false ? RunOutput[] : (Error | RunOutput)[]>;
242
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
243
- returnExceptions?: false;
244
- }): Promise<RunOutput[]>;
245
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions & {
246
- returnExceptions: true;
247
- }): Promise<(RunOutput | Error)[]>;
248
- batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
249
- }
250
- /**
251
- * A sequence of runnables, where the output of each is the input of the next.
252
- * @example
253
- * ```typescript
254
- * const promptTemplate = PromptTemplate.fromTemplate(
255
- * "Tell me a joke about {topic}",
256
- * );
257
- * const chain = RunnableSequence.from([promptTemplate, new ChatOpenAI({})]);
258
- * const result = await chain.invoke({ topic: "bears" });
259
- * ```
260
- */
261
- export declare class RunnableSequence<RunInput = any, RunOutput = any> extends Runnable<RunInput, RunOutput> {
262
- static lc_name(): string;
263
- protected first: Runnable<RunInput>;
264
- protected middle: Runnable[];
265
- protected last: Runnable<any, RunOutput>;
266
- lc_serializable: boolean;
267
- lc_namespace: string[];
268
- constructor(fields: {
269
- first: Runnable<RunInput>;
270
- middle?: Runnable[];
271
- last: Runnable<any, RunOutput>;
272
- });
273
- get steps(): Runnable<RunInput, any, BaseCallbackConfig>[];
274
- invoke(input: RunInput, options?: RunnableConfig): Promise<RunOutput>;
275
- batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
276
- returnExceptions?: false;
277
- }): Promise<RunOutput[]>;
278
- batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
279
- returnExceptions: true;
280
- }): Promise<(RunOutput | Error)[]>;
281
- batch(inputs: RunInput[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
282
- _streamIterator(input: RunInput, options?: RunnableConfig): AsyncGenerator<RunOutput>;
283
- pipe<NewRunOutput>(coerceable: RunnableLike<RunOutput, NewRunOutput>): RunnableSequence<RunInput, Exclude<NewRunOutput, Error>>;
284
- static isRunnableSequence(thing: any): thing is RunnableSequence;
285
- static from<RunInput = any, RunOutput = any>([first, ...runnables]: [
286
- RunnableLike<RunInput>,
287
- ...RunnableLike[],
288
- RunnableLike<any, RunOutput>
289
- ]): RunnableSequence<RunInput, Exclude<RunOutput, Error>>;
290
- }
291
- /**
292
- * A runnable that runs a mapping of runnables in parallel,
293
- * and returns a mapping of their outputs.
294
- * @example
295
- * ```typescript
296
- * const mapChain = RunnableMap.from({
297
- * joke: PromptTemplate.fromTemplate("Tell me a joke about {topic}").pipe(
298
- * new ChatAnthropic({}),
299
- * ),
300
- * poem: PromptTemplate.fromTemplate("write a 2-line poem about {topic}").pipe(
301
- * new ChatAnthropic({}),
302
- * ),
303
- * });
304
- * const result = await mapChain.invoke({ topic: "bear" });
305
- * ```
306
- */
307
- export declare class RunnableMap<RunInput> extends Runnable<RunInput, Record<string, any>> {
308
- static lc_name(): string;
309
- lc_namespace: string[];
310
- lc_serializable: boolean;
311
- protected steps: Record<string, Runnable<RunInput>>;
312
- getStepsKeys(): string[];
313
- constructor(fields: {
314
- steps: Record<string, RunnableLike<RunInput>>;
315
- });
316
- static from<RunInput>(steps: Record<string, RunnableLike<RunInput>>): RunnableMap<RunInput>;
317
- invoke(input: RunInput, options?: Partial<BaseCallbackConfig>): Promise<Record<string, any>>;
318
- }
319
- /**
320
- * A runnable that runs a callable.
321
- */
322
- export declare class RunnableLambda<RunInput, RunOutput> extends Runnable<RunInput, RunOutput> {
323
- static lc_name(): string;
324
- lc_namespace: string[];
325
- protected func: RunnableFunc<RunInput, RunOutput>;
326
- constructor(fields: {
327
- func: RunnableFunc<RunInput, RunOutput>;
328
- });
329
- static from<RunInput, RunOutput>(func: RunnableFunc<RunInput, RunOutput>): RunnableLambda<RunInput, RunOutput>;
330
- _invoke(input: RunInput, config?: Partial<BaseCallbackConfig>, runManager?: CallbackManagerForChainRun): Promise<RunOutput>;
331
- invoke(input: RunInput, options?: Partial<BaseCallbackConfig>): Promise<RunOutput>;
332
- }
333
- /**
334
- * A Runnable that can fallback to other Runnables if it fails.
335
- */
336
- export declare class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable<RunInput, RunOutput> {
337
- static lc_name(): string;
338
- lc_namespace: string[];
339
- lc_serializable: boolean;
340
- runnable: Runnable<RunInput, RunOutput>;
341
- fallbacks: Runnable<RunInput, RunOutput>[];
342
- constructor(fields: {
343
- runnable: Runnable<RunInput, RunOutput>;
344
- fallbacks: Runnable<RunInput, RunOutput>[];
345
- });
346
- runnables(): Generator<Runnable<RunInput, RunOutput, BaseCallbackConfig>, void, unknown>;
347
- invoke(input: RunInput, options?: Partial<BaseCallbackConfig>): Promise<RunOutput>;
348
- batch(inputs: RunInput[], options?: Partial<BaseCallbackConfig> | Partial<BaseCallbackConfig>[], batchOptions?: RunnableBatchOptions & {
349
- returnExceptions?: false;
350
- }): Promise<RunOutput[]>;
351
- batch(inputs: RunInput[], options?: Partial<BaseCallbackConfig> | Partial<BaseCallbackConfig>[], batchOptions?: RunnableBatchOptions & {
352
- returnExceptions: true;
353
- }): Promise<(RunOutput | Error)[]>;
354
- batch(inputs: RunInput[], options?: Partial<BaseCallbackConfig> | Partial<BaseCallbackConfig>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
355
- }
356
- export declare function _coerceToRunnable<RunInput, RunOutput>(coerceable: RunnableLike<RunInput, RunOutput>): Runnable<RunInput, Exclude<RunOutput, Error>>;
1
+ export { type RunnableFunc, type RunnableLike, type RunnableBatchOptions, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableLambda, RunnableWithFallbacks, _coerceToRunnable, } from "langchain-core/runnables";