15de5b7dc8d05cc2c47466ca78cf93948acaa1922b261dfcd973b17aa04463e8.json 293 KB

1
  1. {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport _asyncGeneratorDelegate from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js\";\nimport _asyncIterator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncIterator.js\";\nimport _awaitAsyncGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js\";\nimport _wrapAsyncGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js\";\nimport { z } from \"zod\";\nimport pRetry from \"p-retry\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { isTraceableFunction } from \"langsmith/singletons/traceable\";\nimport { LogStreamCallbackHandler, RunLog, RunLogPatch, isLogStreamHandler } from \"../tracers/log_stream.js\";\nimport { EventStreamCallbackHandler, isStreamEventsHandler } from \"../tracers/event_stream.js\";\nimport { Serializable } from \"../load/serializable.js\";\nimport { IterableReadableStream, concat, atee, pipeGeneratorWithSetup, AsyncGeneratorWithSetup } from \"../utils/stream.js\";\nimport { raceWithSignal } from \"../utils/signal.js\";\nimport { DEFAULT_RECURSION_LIMIT, ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig } from \"./config.js\";\nimport { AsyncCaller } from \"../utils/async_caller.js\";\nimport { RootListenersTracer } from \"../tracers/root_listener.js\";\nimport { _RootEventFilter, isRunnableInterface } from \"./utils.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../singletons/index.js\";\nimport { Graph } from \"./graph.js\";\nimport { convertToHttpEventStream } from \"./wrappers.js\";\nimport { consumeAsyncIterableInContext, consumeIteratorInContext, isAsyncIterable, isIterableIterator, isIterator } from \"./iter.js\";\nimport { _isToolCall, ToolInputParsingException } from \"../tools/utils.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value, defaultKey) {\n return value && !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) && typeof value === \"object\" ? value : {\n [defaultKey]: value\n };\n}\n/**\n * A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or\n * transformed.\n */\nexport class Runnable extends Serializable {\n constructor() {\n super(...arguments);\n Object.defineProperty(this, \"lc_runnable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n getName(suffix) {\n var _ref2, _this$name;\n const name = // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (_ref2 = (_this$name = this.name) !== null && _this$name !== void 0 ? _this$name : this.constructor.lc_name()) !== null && _ref2 !== void 0 ? _ref2 : this.constructor.name;\n return suffix ? `${name}${suffix}` : name;\n }\n /**\n * Bind arguments to a Runnable, returning a new Runnable.\n * @param kwargs\n * @returns A new RunnableBinding that, when invoked, will apply the bound args.\n */\n bind(kwargs) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({\n bound: this,\n kwargs,\n config: {}\n });\n }\n /**\n * Return a new Runnable that maps a list of inputs to a list of outputs,\n * by calling invoke() with each input.\n */\n map() {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableEach({\n bound: this\n });\n }\n /**\n * Add retry logic to an existing runnable.\n * @param kwargs\n * @returns A new RunnableRetry that, when invoked, will retry according to the parameters.\n */\n withRetry(fields) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableRetry({\n bound: this,\n kwargs: {},\n config: {},\n maxAttemptNumber: fields === null || fields === void 0 ? void 0 : fields.stopAfterAttempt,\n ...fields\n });\n }\n /**\n * Bind config to a Runnable, returning a new Runnable.\n * @param config New configuration parameters to attach to the new runnable.\n * @returns A new RunnableBinding with a config matching what's passed.\n */\n withConfig(config) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({\n bound: this,\n config,\n kwargs: {}\n });\n }\n /**\n * Create a new runnable from the current one that will try invoking\n * other passed fallback runnables if the initial invocation fails.\n * @param fields.fallbacks Other runnables to call if the runnable errors.\n * @returns A new RunnableWithFallbacks.\n */\n withFallbacks(fields) {\n const fallbacks = Array.isArray(fields) ? fields : fields.fallbacks;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableWithFallbacks({\n runnable: this,\n fallbacks\n });\n }\n _getOptionsList(options, length = 0) {\n if (Array.isArray(options) && options.length !== length) {\n throw new Error(`Passed \"options\" must be an array with the same length as the inputs, but got ${options.length} options for ${length} inputs`);\n }\n if (Array.isArray(options)) {\n return options.map(ensureConfig);\n }\n if (length > 1 && !Array.isArray(options) && options.runId) {\n console.warn(\"Provided runId will be used only for the first element of the batch.\");\n const subsequent = Object.fromEntries(Object.entries(options).filter(([key]) => key !== \"runId\"));\n return Array.from({\n length\n }, (_, i) => ensureConfig(i === 0 ? options : subsequent));\n }\n return Array.from({\n length\n }, () => ensureConfig(options));\n }\n batch(inputs, options, batchOptions) {\n var _this17 = this;\n return _asyncToGenerator(function* () {\n var _configList$0$maxConc, _configList$;\n const configList = _this17._getOptionsList(options !== null && options !== void 0 ? options : {}, inputs.length);\n const maxConcurrency = (_configList$0$maxConc = (_configList$ = configList[0]) === null || _configList$ === void 0 ? void 0 : _configList$.maxConcurrency) !== null && _configList$0$maxConc !== void 0 ? _configList$0$maxConc : batchOptions === null || batchOptions === void 0 ? void 0 : batchOptions.maxConcurrency;\n const caller = new AsyncCaller({\n maxConcurrency,\n onFailedAttempt: e => {\n throw e;\n }\n });\n const batchCalls = inputs.map((input, i) => caller.call( /*#__PURE__*/_asyncToGenerator(function* () {\n try {\n const result = yield _this17.invoke(input, configList[i]);\n return result;\n } catch (e) {\n if (batchOptions !== null && batchOptions !== void 0 && batchOptions.returnExceptions) {\n return e;\n }\n throw e;\n }\n })));\n return Promise.all(batchCalls);\n })();\n }\n /**\n * Default streaming implementation.\n * Subclasses should override this method if they support streaming output.\n * @param input\n * @param options\n */\n _streamIterator(input, options) {\n var _this = this;\n return _wrapAsyncGenerator(function* () {\n yield _this.invoke(input, options);\n })();\n }\n /**\n * Stream output in chunks.\n * @param input\n * @param options\n * @returns A readable stream that is also an iterable.\n */\n stream(input, options) {\n var _this18 = this;\n return _asyncToGenerator(function* () {\n // Buffer the first streamed chunk to allow for initial errors\n // to surface immediately.\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: _this18._streamIterator(input, config),\n config\n });\n yield wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n })();\n }\n _separateRunnableConfigFromCallOptions(options) {\n let runnableConfig;\n if (options === undefined) {\n runnableConfig = ensureConfig(options);\n } else {\n runnableConfig = ensureConfig({\n callbacks: options.callbacks,\n tags: options.tags,\n metadata: options.metadata,\n runName: options.runName,\n configurable: options.configurable,\n recursionLimit: options.recursionLimit,\n maxConcurrency: options.maxConcurrency,\n runId: options.runId,\n timeout: options.timeout,\n signal: options.signal\n });\n }\n const callOptions = {\n ...options\n };\n delete callOptions.callbacks;\n delete callOptions.tags;\n delete callOptions.metadata;\n delete callOptions.runName;\n delete callOptions.configurable;\n delete callOptions.recursionLimit;\n delete callOptions.maxConcurrency;\n delete callOptions.runId;\n delete callOptions.timeout;\n delete callOptions.signal;\n return [runnableConfig, callOptions];\n }\n _callWithConfig(func, input, options) {\n var _this19 = this;\n return _asyncToGenerator(function* () {\n var _config$runName;\n const config = ensureConfig(options);\n const callbackManager_ = yield getCallbackManagerForConfig(config);\n const runManager = yield callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this19.toJSON(), _coerceToDict(input, \"input\"), config.runId, config === null || config === void 0 ? void 0 : config.runType, undefined, undefined, (_config$runName = config === null || config === void 0 ? void 0 : config.runName) !== null && _config$runName !== void 0 ? _config$runName : _this19.getName());\n delete config.runId;\n let output;\n try {\n const promise = func.call(_this19, input, config, runManager);\n output = yield raceWithSignal(promise, options === null || options === void 0 ? void 0 : options.signal);\n } catch (e) {\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e);\n throw e;\n }\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(output, \"output\"));\n return output;\n })();\n }\n /**\n * Internal method that handles batching and configuration for a runnable\n * It takes a function, input values, and optional configuration, and\n * returns a promise that resolves to the output values.\n * @param func The function to be executed for each input value.\n * @param input The input values to be processed.\n * @param config Optional configuration for the function execution.\n * @returns A promise that resolves to the output values.\n */\n _batchWithConfig(func, inputs, options, batchOptions) {\n var _this20 = this;\n return _asyncToGenerator(function* () {\n const optionsList = _this20._getOptionsList(options !== null && options !== void 0 ? options : {}, inputs.length);\n const callbackManagers = yield Promise.all(optionsList.map(getCallbackManagerForConfig));\n const runManagers = yield Promise.all(callbackManagers.map( /*#__PURE__*/function () {\n var _ref4 = _asyncToGenerator(function* (callbackManager, i) {\n var _optionsList$i$runNam;\n const handleStartRes = yield callbackManager === null || callbackManager === void 0 ? void 0 : callbackManager.handleChainStart(_this20.toJSON(), _coerceToDict(inputs[i], \"input\"), optionsList[i].runId, optionsList[i].runType, undefined, undefined, (_optionsList$i$runNam = optionsList[i].runName) !== null && _optionsList$i$runNam !== void 0 ? _optionsList$i$runNam : _this20.getName());\n delete optionsList[i].runId;\n return handleStartRes;\n });\n return function (_x, _x2) {\n return _ref4.apply(this, arguments);\n };\n }()));\n let outputs;\n try {\n var _optionsList$;\n const promise = func.call(_this20, inputs, optionsList, runManagers, batchOptions);\n outputs = yield raceWithSignal(promise, optionsList === null || optionsList === void 0 || (_optionsList$ = optionsList[0]) === null || _optionsList$ === void 0 ? void 0 : _optionsList$.signal);\n } catch (e) {\n yield Promise.all(runManagers.map(runManager => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e)));\n throw e;\n }\n yield Promise.all(runManagers.map(runManager => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(outputs, \"output\"))));\n return outputs;\n })();\n }\n /**\n * Helper method to transform an Iterator of Input values into an Iterator of\n * Output values, with callbacks.\n * Use this to implement `stream()` or `transform()` in Runnable subclasses.\n */\n _transformStreamWithConfig(inputGenerator, transformer, options) {\n var _this2 = this;\n return _wrapAsyncGenerator(function* () {\n var _runManager4, _finalOutput;\n let finalInput;\n let finalInputSupported = true;\n let finalOutput;\n let finalOutputSupported = true;\n const config = ensureConfig(options);\n const callbackManager_ = yield _awaitAsyncGenerator(getCallbackManagerForConfig(config));\n function wrapInputForTracing() {\n return _wrapInputForTracing.apply(this, arguments);\n }\n function _wrapInputForTracing() {\n _wrapInputForTracing = _wrapAsyncGenerator(function* () {\n var _iteratorAbruptCompletion2 = false;\n var _didIteratorError2 = false;\n var _iteratorError2;\n try {\n for (var _iterator2 = _asyncIterator(inputGenerator), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _awaitAsyncGenerator(_iterator2.next())).done; _iteratorAbruptCompletion2 = false) {\n const chunk = _step2.value;\n {\n if (finalInputSupported) {\n if (finalInput === undefined) {\n finalInput = chunk;\n } else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalInput = concat(finalInput, chunk);\n } catch {\n finalInput = undefined;\n finalInputSupported = false;\n }\n }\n }\n yield chunk;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion2 && _iterator2.return != null) {\n yield _awaitAsyncGenerator(_iterator2.return());\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n });\n return _wrapInputForTracing.apply(this, arguments);\n }\n let runManager;\n try {\n var _runManager, _runManager2;\n const pipe = yield _awaitAsyncGenerator(pipeGeneratorWithSetup(transformer.bind(_this2), wrapInputForTracing(), /*#__PURE__*/_asyncToGenerator(function* () {\n var _config$runName2;\n return callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this2.toJSON(), {\n input: \"\"\n }, config.runId, config.runType, undefined, undefined, (_config$runName2 = config.runName) !== null && _config$runName2 !== void 0 ? _config$runName2 : _this2.getName());\n }), options === null || options === void 0 ? void 0 : options.signal, config));\n delete config.runId;\n runManager = pipe.setup;\n const streamEventsHandler = (_runManager = runManager) === null || _runManager === void 0 ? void 0 : _runManager.handlers.find(isStreamEventsHandler);\n let iterator = pipe.output;\n if (streamEventsHandler !== undefined && runManager !== undefined) {\n iterator = streamEventsHandler.tapOutputIterable(runManager.runId, iterator);\n }\n const streamLogHandler = (_runManager2 = runManager) === null || _runManager2 === void 0 ? void 0 : _runManager2.handlers.find(isLogStreamHandler);\n if (streamLogHandler !== undefined && runManager !== undefined) {\n iterator = streamLogHandler.tapOutputIterable(runManager.runId, iterator);\n }\n var _iteratorAbruptCompletion = false;\n var _didIteratorError = false;\n var _iteratorError;\n try {\n for (var _iterator = _asyncIterator(iterator), _step; _iteratorAbruptCompletion = !(_step = yield _awaitAsyncGenerator(_iterator.next())).done; _iteratorAbruptCompletion = false) {\n const chunk = _step.value;\n {\n yield chunk;\n if (finalOutputSupported) {\n if (finalOutput === undefined) {\n finalOutput = chunk;\n } else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n } catch {\n finalOutput = undefined;\n finalOutputSupported = false;\n }\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion && _iterator.return != null) {\n yield _awaitAsyncGenerator(_iterator.return());\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } catch (e) {\n var _runManager3;\n yield _awaitAsyncGenerator((_runManager3 = runManager) === null || _runManager3 === void 0 ? void 0 : _runManager3.handleChainError(e, undefined, undefined, undefined, {\n inputs: _coerceToDict(finalInput, \"input\")\n }));\n throw e;\n }\n yield _awaitAsyncGenerator((_runManager4 = runManager) === null || _runManager4 === void 0 ? void 0 : _runManager4.handleChainEnd((_finalOutput = finalOutput) !== null && _finalOutput !== void 0 ? _finalOutput : {}, undefined, undefined, undefined, {\n inputs: _coerceToDict(finalInput, \"input\")\n }));\n })();\n }\n getGraph(_) {\n const graph = new Graph();\n // TODO: Add input schema for runnables\n const inputNode = graph.addNode({\n name: `${this.getName()}Input`,\n schema: z.any()\n });\n const runnableNode = graph.addNode(this);\n // TODO: Add output schemas for runnables\n const outputNode = graph.addNode({\n name: `${this.getName()}Output`,\n schema: z.any()\n });\n graph.addEdge(inputNode, runnableNode);\n graph.addEdge(runnableNode, outputNode);\n return graph;\n }\n /**\n * Create a new runnable sequence that runs each individual runnable in series,\n * piping the output of one runnable into another runnable or runnable-like.\n * @param coerceable A runnable, function, or object whose values are functions or runnables.\n * @returns A new runnable sequence.\n */\n pipe(coerceable) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableSequence({\n first: this,\n last: _coerceToRunnable(coerceable)\n });\n }\n /**\n * Pick keys from the dict output of this runnable. Returns a new runnable.\n */\n pick(keys) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return this.pipe(new RunnablePick(keys));\n }\n /**\n * Assigns new fields to the dict output of this runnable. Returns a new runnable.\n */\n assign(mapping) {\n return this.pipe(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new RunnableAssign(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new RunnableMap({\n steps: mapping\n })));\n }\n /**\n * Default implementation of transform, which buffers input and then calls stream.\n * Subclasses should override this method if they can start producing output while\n * input is still being generated.\n * @param generator\n * @param options\n */\n transform(generator, options) {\n var _this3 = this;\n return _wrapAsyncGenerator(function* () {\n let finalChunk;\n var _iteratorAbruptCompletion3 = false;\n var _didIteratorError3 = false;\n var _iteratorError3;\n try {\n for (var _iterator3 = _asyncIterator(generator), _step3; _iteratorAbruptCompletion3 = !(_step3 = yield _awaitAsyncGenerator(_iterator3.next())).done; _iteratorAbruptCompletion3 = false) {\n const chunk = _step3.value;\n {\n if (finalChunk === undefined) {\n finalChunk = chunk;\n } else {\n // Make a best effort to gather, for any type that supports concat.\n // This method should throw an error if gathering fails.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalChunk = concat(finalChunk, chunk);\n }\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion3 && _iterator3.return != null) {\n yield _awaitAsyncGenerator(_iterator3.return());\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n yield* _asyncGeneratorDelegate(_asyncIterator(_this3._streamIterator(finalChunk, ensureConfig(options))), _awaitAsyncGenerator);\n })();\n }\n /**\n * Stream all output from a runnable, as reported to the callback system.\n * This includes all inner runs of LLMs, Retrievers, Tools, etc.\n * Output is streamed as Log objects, which include a list of\n * jsonpatch ops that describe how the state of the run has changed in each\n * step, and the final state of the run.\n * The jsonpatch ops can be applied in order to construct state.\n * @param input\n * @param options\n * @param streamOptions\n */\n streamLog(input, options, streamOptions) {\n var _this4 = this;\n return _wrapAsyncGenerator(function* () {\n const logStreamCallbackHandler = new LogStreamCallbackHandler({\n ...streamOptions,\n autoClose: false,\n _schemaFormat: \"original\"\n });\n const config = ensureConfig(options);\n yield* _asyncGeneratorDelegate(_asyncIterator(_this4._streamLog(input, logStreamCallbackHandler, config)), _awaitAsyncGenerator);\n })();\n }\n _streamLog(input, logStreamCallbackHandler, config) {\n var _this5 = this;\n return _wrapAsyncGenerator(function* () {\n const {\n callbacks\n } = config;\n if (callbacks === undefined) {\n // eslint-disable-next-line no-param-reassign\n config.callbacks = [logStreamCallbackHandler];\n } else if (Array.isArray(callbacks)) {\n // eslint-disable-next-line no-param-reassign\n config.callbacks = callbacks.concat([logStreamCallbackHandler]);\n } else {\n const copiedCallbacks = callbacks.copy();\n copiedCallbacks.addHandler(logStreamCallbackHandler, true);\n // eslint-disable-next-line no-param-reassign\n config.callbacks = copiedCallbacks;\n }\n const runnableStreamPromise = _this5.stream(input, config);\n function consumeRunnableStream() {\n return _consumeRunnableStream.apply(this, arguments);\n }\n function _consumeRunnableStream() {\n _consumeRunnableStream = _asyncToGenerator(function* () {\n try {\n const runnableStream = yield runnableStreamPromise;\n var _iteratorAbruptCompletion5 = false;\n var _didIteratorError5 = false;\n var _iteratorError5;\n try {\n for (var _iterator5 = _asyncIterator(runnableStream), _step5; _iteratorAbruptCompletion5 = !(_step5 = yield _iterator5.next()).done; _iteratorAbruptCompletion5 = false) {\n const chunk = _step5.value;\n {\n const patch = new RunLogPatch({\n ops: [{\n op: \"add\",\n path: \"/streamed_output/-\",\n value: chunk\n }]\n });\n yield logStreamCallbackHandler.writer.write(patch);\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion5 && _iterator5.return != null) {\n yield _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n } finally {\n yield logStreamCallbackHandler.writer.close();\n }\n });\n return _consumeRunnableStream.apply(this, arguments);\n }\n const runnableStreamConsumePromise = consumeRunnableStream();\n try {\n var _iteratorAbruptCompletion4 = false;\n var _didIteratorError4 = false;\n var _iteratorError4;\n try {\n for (var _iterator4 = _asyncIterator(logStreamCallbackHandler), _step4; _iteratorAbruptCompletion4 = !(_step4 = yield _awaitAsyncGenerator(_iterator4.next())).done; _iteratorAbruptCompletion4 = false) {\n const log = _step4.value;\n {\n yield log;\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion4 && _iterator4.return != null) {\n yield _awaitAsyncGenerator(_iterator4.return());\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } finally {\n yield _awaitAsyncGenerator(runnableStreamConsumePromise);\n }\n })();\n }\n streamEvents(input, options, streamOptions) {\n let stream;\n if (options.version === \"v1\") {\n stream = this._streamEventsV1(input, options, streamOptions);\n } else if (options.version === \"v2\") {\n stream = this._streamEventsV2(input, options, streamOptions);\n } else {\n throw new Error(`Only versions \"v1\" and \"v2\" of the schema are currently supported.`);\n }\n if (options.encoding === \"text/event-stream\") {\n return convertToHttpEventStream(stream);\n } else {\n return IterableReadableStream.fromAsyncGenerator(stream);\n }\n }\n _streamEventsV2(input, options, streamOptions) {\n var _this6 = this;\n return _wrapAsyncGenerator(function* () {\n var _config$runId;\n const eventStreamer = new EventStreamCallbackHandler({\n ...streamOptions,\n autoClose: false\n });\n const config = ensureConfig(options);\n const runId = (_config$runId = config.runId) !== null && _config$runId !== void 0 ? _config$runId : uuidv4();\n config.runId = runId;\n const callbacks = config.callbacks;\n if (callbacks === undefined) {\n config.callbacks = [eventStreamer];\n } else if (Array.isArray(callbacks)) {\n config.callbacks = callbacks.concat(eventStreamer);\n } else {\n const copiedCallbacks = callbacks.copy();\n copiedCallbacks.addHandler(eventStreamer, true);\n // eslint-disable-next-line no-param-reassign\n config.callbacks = copiedCallbacks;\n }\n // Call the runnable in streaming mode,\n // add each chunk to the output stream\n const outerThis = _this6;\n function consumeRunnableStream() {\n return _consumeRunnableStream2.apply(this, arguments);\n }\n function _consumeRunnableStream2() {\n _consumeRunnableStream2 = _asyncToGenerator(function* () {\n try {\n const runnableStream = yield outerThis.stream(input, config);\n const tappedStream = eventStreamer.tapOutputIterable(runId, runnableStream);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n var _iteratorAbruptCompletion7 = false;\n var _didIteratorError7 = false;\n var _iteratorError7;\n try {\n for (var _iterator7 = _asyncIterator(tappedStream), _step7; _iteratorAbruptCompletion7 = !(_step7 = yield _iterator7.next()).done; _iteratorAbruptCompletion7 = false) {\n const _ = _step7.value;\n } // Just iterate so that the callback handler picks up events\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion7 && _iterator7.return != null) {\n yield _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n } finally {\n yield eventStreamer.finish();\n }\n });\n return _consumeRunnableStream2.apply(this, arguments);\n }\n const runnableStreamConsumePromise = consumeRunnableStream();\n let firstEventSent = false;\n let firstEventRunId;\n try {\n var _iteratorAbruptCompletion6 = false;\n var _didIteratorError6 = false;\n var _iteratorError6;\n try {\n for (var _iterator6 = _asyncIterator(eventStreamer), _step6; _iteratorAbruptCompletion6 = !(_step6 = yield _awaitAsyncGenerator(_iterator6.next())).done; _iteratorAbruptCompletion6 = false) {\n const event = _step6.value;\n {\n // This is a work-around an issue where the inputs into the\n // chain are not available until the entire input is consumed.\n // As a temporary solution, we'll modify the input to be the input\n // that was passed into the chain.\n if (!firstEventSent) {\n event.data.input = input;\n firstEventSent = true;\n firstEventRunId = event.run_id;\n yield event;\n continue;\n }\n if (event.run_id === firstEventRunId && event.event.endsWith(\"_end\")) {\n var _event$data;\n // If it's the end event corresponding to the root runnable\n // we dont include the input in the event since it's guaranteed\n // to be included in the first event.\n if ((_event$data = event.data) !== null && _event$data !== void 0 && _event$data.input) {\n delete event.data.input;\n }\n }\n yield event;\n }\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion6 && _iterator6.return != null) {\n yield _awaitAsyncGenerator(_iterator6.return());\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n } finally {\n yield _awaitAsyncGenerator(runnableStreamConsumePromise);\n }\n })();\n }\n _streamEventsV1(input, options, streamOptions) {\n var _this7 = this;\n return _wrapAsyncGenerator(function* () {\n var _config$tags, _config$metadata, _config$runName3, _runLog;\n let runLog;\n let hasEncounteredStartEvent = false;\n const config = ensureConfig(options);\n const rootTags = (_config$tags = config.tags) !== null && _config$tags !== void 0 ? _config$tags : [];\n const rootMetadata = (_config$metadata = config.metadata) !== null && _config$metadata !== void 0 ? _config$metadata : {};\n const rootName = (_config$runName3 = config.runName) !== null && _config$runName3 !== void 0 ? _config$runName3 : _this7.getName();\n const logStreamCallbackHandler = new LogStreamCallbackHandler({\n ...streamOptions,\n autoClose: false,\n _schemaFormat: \"streaming_events\"\n });\n const rootEventFilter = new _RootEventFilter({\n ...streamOptions\n });\n const logStream = _this7._streamLog(input, logStreamCallbackHandler, config);\n var _iteratorAbruptCompletion8 = false;\n var _didIteratorError8 = false;\n var _iteratorError8;\n try {\n for (var _iterator8 = _asyncIterator(logStream), _step8; _iteratorAbruptCompletion8 = !(_step8 = yield _awaitAsyncGenerator(_iterator8.next())).done; _iteratorAbruptCompletion8 = false) {\n const log = _step8.value;\n {\n if (!runLog) {\n runLog = RunLog.fromRunLogPatch(log);\n } else {\n runLog = runLog.concat(log);\n }\n if (runLog.state === undefined) {\n throw new Error(`Internal error: \"streamEvents\" state is missing. Please open a bug report.`);\n }\n // Yield the start event for the root runnable if it hasn't been seen.\n // The root run is never filtered out\n if (!hasEncounteredStartEvent) {\n hasEncounteredStartEvent = true;\n const state = {\n ...runLog.state\n };\n const event = {\n run_id: state.id,\n event: `on_${state.type}_start`,\n name: rootName,\n tags: rootTags,\n metadata: rootMetadata,\n data: {\n input\n }\n };\n if (rootEventFilter.includeEvent(event, state.type)) {\n yield event;\n }\n }\n const paths = log.ops.filter(op => op.path.startsWith(\"/logs/\")).map(op => op.path.split(\"/\")[2]);\n const dedupedPaths = [...new Set(paths)];\n for (const path of dedupedPaths) {\n let eventType;\n let data = {};\n const logEntry = runLog.state.logs[path];\n if (logEntry.end_time === undefined) {\n if (logEntry.streamed_output.length > 0) {\n eventType = \"stream\";\n } else {\n eventType = \"start\";\n }\n } else {\n eventType = \"end\";\n }\n if (eventType === \"start\") {\n // Include the inputs with the start event if they are available.\n // Usually they will NOT be available for components that operate\n // on streams, since those components stream the input and\n // don't know its final value until the end of the stream.\n if (logEntry.inputs !== undefined) {\n data.input = logEntry.inputs;\n }\n } else if (eventType === \"end\") {\n if (logEntry.inputs !== undefined) {\n data.input = logEntry.inputs;\n }\n data.output = logEntry.final_output;\n } else if (eventType === \"stream\") {\n const chunkCount = logEntry.streamed_output.length;\n if (chunkCount !== 1) {\n throw new Error(`Expected exactly one chunk of streamed output, got ${chunkCount} instead. Encountered in: \"${logEntry.name}\"`);\n }\n data = {\n chunk: logEntry.streamed_output[0]\n };\n // Clean up the stream, we don't need it anymore.\n // And this avoids duplicates as well!\n logEntry.streamed_output = [];\n }\n yield {\n event: `on_${logEntry.type}_${eventType}`,\n name: logEntry.name,\n run_id: logEntry.id,\n tags: logEntry.tags,\n metadata: logEntry.metadata,\n data\n };\n }\n // Finally, we take care of the streaming output from the root chain\n // if there is any.\n const {\n state\n } = runLog;\n if (state.streamed_output.length > 0) {\n const chunkCount = state.streamed_output.length;\n if (chunkCount !== 1) {\n throw new Error(`Expected exactly one chunk of streamed output, got ${chunkCount} instead. Encountered in: \"${state.name}\"`);\n }\n const data = {\n chunk: state.streamed_output[0]\n };\n // Clean up the stream, we don't need it anymore.\n state.streamed_output = [];\n const event = {\n event: `on_${state.type}_stream`,\n run_id: state.id,\n tags: rootTags,\n metadata: rootMetadata,\n name: rootName,\n data\n };\n if (rootEventFilter.includeEvent(event, state.type)) {\n yield event;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion8 && _iterator8.return != null) {\n yield _awaitAsyncGenerator(_iterator8.return());\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n const state = (_runLog = runLog) === null || _runLog === void 0 ? void 0 : _runLog.state;\n if (state !== undefined) {\n // Finally, yield the end event for the root runnable.\n const event = {\n event: `on_${state.type}_end`,\n name: rootName,\n run_id: state.id,\n tags: rootTags,\n metadata: rootMetadata,\n data: {\n output: state.final_output\n }\n };\n if (rootEventFilter.includeEvent(event, state.type)) yield event;\n }\n })();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static isRunnable(thing) {\n return isRunnableInterface(thing);\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({\n onStart,\n onEnd,\n onError\n }) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({\n bound: this,\n config: {},\n configFactories: [config => ({\n callbacks: [new RootListenersTracer({\n config,\n onStart,\n onEnd,\n onError\n })]\n })]\n });\n }\n /**\n * Convert a runnable to a tool. Return a new instance of `RunnableToolLike`\n * which contains the runnable, name, description and schema.\n *\n * @template {T extends RunInput = RunInput} RunInput - The input type of the runnable. Should be the same as the `RunInput` type of the runnable.\n *\n * @param fields\n * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable.\n * @param {string | undefined} [fields.description] The description of the tool. Falls back to the description on the Zod schema if not provided, or undefined if neither are provided.\n * @param {z.ZodType<T>} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable.\n * @returns {RunnableToolLike<z.ZodType<T>, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool.\n */\n asTool(fields) {\n return convertRunnableToTool(this, fields);\n }\n}\n/**\n * A runnable that delegates calls to another runnable with a set of kwargs.\n * @example\n * ```typescript\n * import {\n * type RunnableConfig,\n * RunnableLambda,\n * } from \"@langchain/core/runnables\";\n *\n * const enhanceProfile = (\n * profile: Record<string, any>,\n * config?: RunnableConfig\n * ) => {\n * if (config?.configurable?.role) {\n * return { ...profile, role: config.configurable.role };\n * }\n * return profile;\n * };\n *\n * const runnable = RunnableLambda.from(enhanceProfile);\n *\n * // Bind configuration to the runnable to set the user's role dynamically\n * const adminRunnable = runnable.bind({ configurable: { role: \"Admin\" } });\n * const userRunnable = runnable.bind({ configurable: { role: \"User\" } });\n *\n * const result1 = await adminRunnable.invoke({\n * name: \"Alice\",\n * email: \"alice@example.com\"\n * });\n *\n * // { name: \"Alice\", email: \"alice@example.com\", role: \"Admin\" }\n *\n * const result2 = await userRunnable.invoke({\n * name: \"Bob\",\n * email: \"bob@example.com\"\n * });\n *\n * // { name: \"Bob\", email: \"bob@example.com\", role: \"User\" }\n * ```\n */\nexport class RunnableBinding extends Runnable {\n static lc_name() {\n return \"RunnableBinding\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"bound\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"config\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"kwargs\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"configFactories\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.bound = fields.bound;\n this.kwargs = fields.kwargs;\n this.config = fields.config;\n this.configFactories = fields.configFactories;\n }\n getName(suffix) {\n return this.bound.getName(suffix);\n }\n _mergeConfig(...options) {\n var _this21 = this;\n return _asyncToGenerator(function* () {\n const config = mergeConfigs(_this21.config, ...options);\n return mergeConfigs(config, ...(_this21.configFactories ? yield Promise.all(_this21.configFactories.map( /*#__PURE__*/function () {\n var _ref6 = _asyncToGenerator(function* (configFactory) {\n return yield configFactory(config);\n });\n return function (_x3) {\n return _ref6.apply(this, arguments);\n };\n }())) : []));\n })();\n }\n bind(kwargs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound,\n kwargs: {\n ...this.kwargs,\n ...kwargs\n },\n config: this.config\n });\n }\n withConfig(config) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound,\n kwargs: this.kwargs,\n config: {\n ...this.config,\n ...config\n }\n });\n }\n withRetry(fields) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound.withRetry(fields),\n kwargs: this.kwargs,\n config: this.config\n });\n }\n invoke(input, options) {\n var _this22 = this;\n return _asyncToGenerator(function* () {\n return _this22.bound.invoke(input, yield _this22._mergeConfig(ensureConfig(options), _this22.kwargs));\n })();\n }\n batch(inputs, options, batchOptions) {\n var _this23 = this;\n return _asyncToGenerator(function* () {\n const mergedOptions = Array.isArray(options) ? yield Promise.all(options.map( /*#__PURE__*/function () {\n var _ref7 = _asyncToGenerator(function* (individualOption) {\n return _this23._mergeConfig(ensureConfig(individualOption), _this23.kwargs);\n });\n return function (_x4) {\n return _ref7.apply(this, arguments);\n };\n }())) : yield _this23._mergeConfig(ensureConfig(options), _this23.kwargs);\n return _this23.bound.batch(inputs, mergedOptions, batchOptions);\n })();\n }\n _streamIterator(input, options) {\n var _this8 = this;\n return _wrapAsyncGenerator(function* () {\n yield* _asyncGeneratorDelegate(_asyncIterator(_this8.bound._streamIterator(input, yield _awaitAsyncGenerator(_this8._mergeConfig(ensureConfig(options), _this8.kwargs)))), _awaitAsyncGenerator);\n })();\n }\n stream(input, options) {\n var _this24 = this;\n return _asyncToGenerator(function* () {\n return _this24.bound.stream(input, yield _this24._mergeConfig(ensureConfig(options), _this24.kwargs));\n })();\n }\n transform(generator, options) {\n var _this9 = this;\n return _wrapAsyncGenerator(function* () {\n yield* _asyncGeneratorDelegate(_asyncIterator(_this9.bound.transform(generator, yield _awaitAsyncGenerator(_this9._mergeConfig(ensureConfig(options), _this9.kwargs)))), _awaitAsyncGenerator);\n })();\n }\n streamEvents(input, options, streamOptions) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const outerThis = this;\n const generator = /*#__PURE__*/function () {\n var _ref = _wrapAsyncGenerator(function* () {\n yield* _asyncGeneratorDelegate(_asyncIterator(outerThis.bound.streamEvents(input, {\n ...(yield _awaitAsyncGenerator(outerThis._mergeConfig(ensureConfig(options), outerThis.kwargs))),\n version: options.version\n }, streamOptions)), _awaitAsyncGenerator);\n });\n return function generator() {\n return _ref.apply(this, arguments);\n };\n }();\n return IterableReadableStream.fromAsyncGenerator(generator());\n }\n static isRunnableBinding(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) {\n return thing.bound && Runnable.isRunnable(thing.bound);\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({\n onStart,\n onEnd,\n onError\n }) {\n return new RunnableBinding({\n bound: this.bound,\n kwargs: this.kwargs,\n config: this.config,\n configFactories: [config => ({\n callbacks: [new RootListenersTracer({\n config,\n onStart,\n onEnd,\n onError\n })]\n })]\n });\n }\n}\n/**\n * A runnable that delegates calls to another runnable\n * with each element of the input sequence.\n * @example\n * ```typescript\n * import { RunnableEach, RunnableLambda } from \"@langchain/core/runnables\";\n *\n * const toUpperCase = (input: string): string => input.toUpperCase();\n * const addGreeting = (input: string): string => `Hello, ${input}!`;\n *\n * const upperCaseLambda = RunnableLambda.from(toUpperCase);\n * const greetingLambda = RunnableLambda.from(addGreeting);\n *\n * const chain = new RunnableEach({\n * bound: upperCaseLambda.pipe(greetingLambda),\n * });\n *\n * const result = await chain.invoke([\"alice\", \"bob\", \"carol\"])\n *\n * // [\"Hello, ALICE!\", \"Hello, BOB!\", \"Hello, CAROL!\"]\n * ```\n */\nexport class RunnableEach extends Runnable {\n static lc_name() {\n return \"RunnableEach\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"bound\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.bound = fields.bound;\n }\n /**\n * Binds the runnable with the specified arguments.\n * @param kwargs The arguments to bind the runnable with.\n * @returns A new instance of the `RunnableEach` class that is bound with the specified arguments.\n */\n bind(kwargs) {\n return new RunnableEach({\n bound: this.bound.bind(kwargs)\n });\n }\n /**\n * Invokes the runnable with the specified input and configuration.\n * @param input The input to invoke the runnable with.\n * @param config The configuration to invoke the runnable with.\n * @returns A promise that resolves to the output of the runnable.\n */\n invoke(inputs, config) {\n var _this25 = this;\n return _asyncToGenerator(function* () {\n return _this25._callWithConfig(_this25._invoke.bind(_this25), inputs, config);\n })();\n }\n /**\n * A helper method that is used to invoke the runnable with the specified input and configuration.\n * @param input The input to invoke the runnable with.\n * @param config The configuration to invoke the runnable with.\n * @returns A promise that resolves to the output of the runnable.\n */\n _invoke(inputs, config, runManager) {\n var _this26 = this;\n return _asyncToGenerator(function* () {\n return _this26.bound.batch(inputs, patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild()\n }));\n })();\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({\n onStart,\n onEnd,\n onError\n }) {\n return new RunnableEach({\n bound: this.bound.withListeners({\n onStart,\n onEnd,\n onError\n })\n });\n }\n}\n/**\n * Base class for runnables that can be retried a\n * specified number of times.\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableRetry,\n * } from \"@langchain/core/runnables\";\n *\n * // Simulate an API call that fails\n * const simulateApiCall = (input: string): string => {\n * console.log(`Attempting API call with input: ${input}`);\n * throw new Error(\"API call failed due to network issue\");\n * };\n *\n * const apiCallLambda = RunnableLambda.from(simulateApiCall);\n *\n * // Apply retry logic using the .withRetry() method\n * const apiCallWithRetry = apiCallLambda.withRetry({ stopAfterAttempt: 3 });\n *\n * // Alternatively, create a RunnableRetry instance manually\n * const manualRetry = new RunnableRetry({\n * bound: apiCallLambda,\n * maxAttemptNumber: 3,\n * config: {},\n * });\n *\n * // Example invocation using the .withRetry() method\n * const res = await apiCallWithRetry\n * .invoke(\"Request 1\")\n * .catch((error) => {\n * console.error(\"Failed after multiple retries:\", error.message);\n * });\n *\n * // Example invocation using the manual retry instance\n * const res2 = await manualRetry\n * .invoke(\"Request 2\")\n * .catch((error) => {\n * console.error(\"Failed after multiple retries:\", error.message);\n * });\n * ```\n */\nexport class RunnableRetry extends RunnableBinding {\n static lc_name() {\n return \"RunnableRetry\";\n }\n constructor(fields) {\n var _fields$maxAttemptNum, _fields$onFailedAttem;\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"maxAttemptNumber\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 3\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"onFailedAttempt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: () => {}\n });\n this.maxAttemptNumber = (_fields$maxAttemptNum = fields.maxAttemptNumber) !== null && _fields$maxAttemptNum !== void 0 ? _fields$maxAttemptNum : this.maxAttemptNumber;\n this.onFailedAttempt = (_fields$onFailedAttem = fields.onFailedAttempt) !== null && _fields$onFailedAttem !== void 0 ? _fields$onFailedAttem : this.onFailedAttempt;\n }\n _patchConfigForRetry(attempt, config, runManager) {\n const tag = attempt > 1 ? `retry:attempt:${attempt}` : undefined;\n return patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(tag)\n });\n }\n _invoke(input, config, runManager) {\n var _superprop_getInvoke = () => super.invoke,\n _this27 = this;\n return _asyncToGenerator(function* () {\n return pRetry(attemptNumber => _superprop_getInvoke().call(_this27, input, _this27._patchConfigForRetry(attemptNumber, config, runManager)), {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onFailedAttempt: error => _this27.onFailedAttempt(error, input),\n retries: Math.max(_this27.maxAttemptNumber - 1, 0),\n randomize: true\n });\n })();\n }\n /**\n * Method that invokes the runnable with the specified input, run manager,\n * and config. It handles the retry logic by catching any errors and\n * recursively invoking itself with the updated config for the next retry\n * attempt.\n * @param input The input for the runnable.\n * @param runManager The run manager for the runnable.\n * @param config The config for the runnable.\n * @returns A promise that resolves to the output of the runnable.\n */\n invoke(input, config) {\n var _this28 = this;\n return _asyncToGenerator(function* () {\n return _this28._callWithConfig(_this28._invoke.bind(_this28), input, config);\n })();\n }\n _batch(inputs, configs, runManagers, batchOptions) {\n var _superprop_getBatch = () => super.batch,\n _this29 = this;\n return _asyncToGenerator(function* () {\n const resultsMap = {};\n try {\n yield pRetry( /*#__PURE__*/function () {\n var _ref8 = _asyncToGenerator(function* (attemptNumber) {\n const remainingIndexes = inputs.map((_, i) => i).filter(i => resultsMap[i.toString()] === undefined ||\n // eslint-disable-next-line no-instanceof/no-instanceof\n resultsMap[i.toString()] instanceof Error);\n const remainingInputs = remainingIndexes.map(i => inputs[i]);\n const patchedConfigs = remainingIndexes.map(i => _this29._patchConfigForRetry(attemptNumber, configs === null || configs === void 0 ? void 0 : configs[i], runManagers === null || runManagers === void 0 ? void 0 : runManagers[i]));\n const results = yield _superprop_getBatch().call(_this29, remainingInputs, patchedConfigs, {\n ...batchOptions,\n returnExceptions: true\n });\n let firstException;\n for (let i = 0; i < results.length; i += 1) {\n const result = results[i];\n const resultMapIndex = remainingIndexes[i];\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (result instanceof Error) {\n if (firstException === undefined) {\n firstException = result;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstException.input = remainingInputs[i];\n }\n }\n resultsMap[resultMapIndex.toString()] = result;\n }\n if (firstException) {\n throw firstException;\n }\n return results;\n });\n return function (_x5) {\n return _ref8.apply(this, arguments);\n };\n }(), {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onFailedAttempt: error => _this29.onFailedAttempt(error, error.input),\n retries: Math.max(_this29.maxAttemptNumber - 1, 0),\n randomize: true\n });\n } catch (e) {\n if ((batchOptions === null || batchOptions === void 0 ? void 0 : batchOptions.returnExceptions) !== true) {\n throw e;\n }\n }\n return Object.keys(resultsMap).sort((a, b) => parseInt(a, 10) - parseInt(b, 10)).map(key => resultsMap[parseInt(key, 10)]);\n })();\n }\n batch(inputs, options, batchOptions) {\n var _this30 = this;\n return _asyncToGenerator(function* () {\n return _this30._batchWithConfig(_this30._batch.bind(_this30), inputs, options, batchOptions);\n })();\n }\n}\n/**\n * A sequence of runnables, where the output of each is the input of the next.\n * @example\n * ```typescript\n * const promptTemplate = PromptTemplate.fromTemplate(\n * \"Tell me a joke about {topic}\",\n * );\n * const chain = RunnableSequence.from([promptTemplate, new ChatOpenAI({})]);\n * const result = await chain.invoke({ topic: \"bears\" });\n * ```\n */\nexport class RunnableSequence extends Runnable {\n static lc_name() {\n return \"RunnableSequence\";\n }\n constructor(fields) {\n var _fields$middle, _fields$omitSequenceT;\n super(fields);\n Object.defineProperty(this, \"first\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"middle\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: []\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"last\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"omitSequenceTags\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n this.first = fields.first;\n this.middle = (_fields$middle = fields.middle) !== null && _fields$middle !== void 0 ? _fields$middle : this.middle;\n this.last = fields.last;\n this.name = fields.name;\n this.omitSequenceTags = (_fields$omitSequenceT = fields.omitSequenceTags) !== null && _fields$omitSequenceT !== void 0 ? _fields$omitSequenceT : this.omitSequenceTags;\n }\n get steps() {\n return [this.first, ...this.middle, this.last];\n }\n invoke(input, options) {\n var _this31 = this;\n return _asyncToGenerator(function* () {\n const config = ensureConfig(options);\n const callbackManager_ = yield getCallbackManagerForConfig(config);\n const runManager = yield callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this31.toJSON(), _coerceToDict(input, \"input\"), config.runId, undefined, undefined, undefined, config === null || config === void 0 ? void 0 : config.runName);\n delete config.runId;\n let nextStepInput = input;\n let finalOutput;\n try {\n var _options$signal;\n const initialSteps = [_this31.first, ..._this31.middle];\n for (let i = 0; i < initialSteps.length; i += 1) {\n const step = initialSteps[i];\n const promise = step.invoke(nextStepInput, patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(_this31.omitSequenceTags ? undefined : `seq:step:${i + 1}`)\n }));\n nextStepInput = yield raceWithSignal(promise, options === null || options === void 0 ? void 0 : options.signal);\n }\n // TypeScript can't detect that the last output of the sequence returns RunOutput, so call it out of the loop here\n if (options !== null && options !== void 0 && (_options$signal = options.signal) !== null && _options$signal !== void 0 && _options$signal.aborted) {\n throw new Error(\"Aborted\");\n }\n finalOutput = yield _this31.last.invoke(nextStepInput, patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(_this31.omitSequenceTags ? undefined : `seq:step:${_this31.steps.length}`)\n }));\n } catch (e) {\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e);\n throw e;\n }\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(finalOutput, \"output\"));\n return finalOutput;\n })();\n }\n batch(inputs, options, batchOptions) {\n var _this32 = this;\n return _asyncToGenerator(function* () {\n const configList = _this32._getOptionsList(options !== null && options !== void 0 ? options : {}, inputs.length);\n const callbackManagers = yield Promise.all(configList.map(getCallbackManagerForConfig));\n const runManagers = yield Promise.all(callbackManagers.map( /*#__PURE__*/function () {\n var _ref9 = _asyncToGenerator(function* (callbackManager, i) {\n const handleStartRes = yield callbackManager === null || callbackManager === void 0 ? void 0 : callbackManager.handleChainStart(_this32.toJSON(), _coerceToDict(inputs[i], \"input\"), configList[i].runId, undefined, undefined, undefined, configList[i].runName);\n delete configList[i].runId;\n return handleStartRes;\n });\n return function (_x6, _x7) {\n return _ref9.apply(this, arguments);\n };\n }()));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let nextStepInputs = inputs;\n try {\n for (let i = 0; i < _this32.steps.length; i += 1) {\n var _configList$2;\n const step = _this32.steps[i];\n const promise = step.batch(nextStepInputs, runManagers.map((runManager, j) => {\n const childRunManager = runManager === null || runManager === void 0 ? void 0 : runManager.getChild(_this32.omitSequenceTags ? undefined : `seq:step:${i + 1}`);\n return patchConfig(configList[j], {\n callbacks: childRunManager\n });\n }), batchOptions);\n nextStepInputs = yield raceWithSignal(promise, (_configList$2 = configList[0]) === null || _configList$2 === void 0 ? void 0 : _configList$2.signal);\n }\n } catch (e) {\n yield Promise.all(runManagers.map(runManager => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e)));\n throw e;\n }\n yield Promise.all(runManagers.map(runManager => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(nextStepInputs, \"output\"))));\n return nextStepInputs;\n })();\n }\n _streamIterator(input, options) {\n var _this10 = this;\n return _wrapAsyncGenerator(function* () {\n const callbackManager_ = yield _awaitAsyncGenerator(getCallbackManagerForConfig(options));\n const {\n runId,\n ...otherOptions\n } = options !== null && options !== void 0 ? options : {};\n const runManager = yield _awaitAsyncGenerator(callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this10.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherOptions === null || otherOptions === void 0 ? void 0 : otherOptions.runName));\n const steps = [_this10.first, ..._this10.middle, _this10.last];\n let concatSupported = true;\n let finalOutput;\n function inputGenerator() {\n return _inputGenerator.apply(this, arguments);\n }\n function _inputGenerator() {\n _inputGenerator = _wrapAsyncGenerator(function* () {\n yield input;\n });\n return _inputGenerator.apply(this, arguments);\n }\n try {\n let finalGenerator = steps[0].transform(inputGenerator(), patchConfig(otherOptions, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(_this10.omitSequenceTags ? undefined : `seq:step:1`)\n }));\n for (let i = 1; i < steps.length; i += 1) {\n const step = steps[i];\n finalGenerator = yield _awaitAsyncGenerator(step.transform(finalGenerator, patchConfig(otherOptions, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(_this10.omitSequenceTags ? undefined : `seq:step:${i + 1}`)\n })));\n }\n var _iteratorAbruptCompletion9 = false;\n var _didIteratorError9 = false;\n var _iteratorError9;\n try {\n for (var _iterator9 = _asyncIterator(finalGenerator), _step9; _iteratorAbruptCompletion9 = !(_step9 = yield _awaitAsyncGenerator(_iterator9.next())).done; _iteratorAbruptCompletion9 = false) {\n const chunk = _step9.value;\n {\n var _options$signal2;\n options === null || options === void 0 || (_options$signal2 = options.signal) === null || _options$signal2 === void 0 || _options$signal2.throwIfAborted();\n yield chunk;\n if (concatSupported) {\n if (finalOutput === undefined) {\n finalOutput = chunk;\n } else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n } catch (e) {\n finalOutput = undefined;\n concatSupported = false;\n }\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError9 = true;\n _iteratorError9 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion9 && _iterator9.return != null) {\n yield _awaitAsyncGenerator(_iterator9.return());\n }\n } finally {\n if (_didIteratorError9) {\n throw _iteratorError9;\n }\n }\n }\n } catch (e) {\n yield _awaitAsyncGenerator(runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e));\n throw e;\n }\n yield _awaitAsyncGenerator(runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(finalOutput, \"output\")));\n })();\n }\n getGraph(config) {\n const graph = new Graph();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentLastNode = null;\n this.steps.forEach((step, index) => {\n const stepGraph = step.getGraph(config);\n if (index !== 0) {\n stepGraph.trimFirstNode();\n }\n if (index !== this.steps.length - 1) {\n stepGraph.trimLastNode();\n }\n graph.extend(stepGraph);\n const stepFirstNode = stepGraph.firstNode();\n if (!stepFirstNode) {\n throw new Error(`Runnable ${step} has no first node`);\n }\n if (currentLastNode) {\n graph.addEdge(currentLastNode, stepFirstNode);\n }\n currentLastNode = stepGraph.lastNode();\n });\n return graph;\n }\n pipe(coerceable) {\n if (RunnableSequence.isRunnableSequence(coerceable)) {\n var _this$name2;\n return new RunnableSequence({\n first: this.first,\n middle: this.middle.concat([this.last, coerceable.first, ...coerceable.middle]),\n last: coerceable.last,\n name: (_this$name2 = this.name) !== null && _this$name2 !== void 0 ? _this$name2 : coerceable.name\n });\n } else {\n return new RunnableSequence({\n first: this.first,\n middle: [...this.middle, this.last],\n last: _coerceToRunnable(coerceable),\n name: this.name\n });\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static isRunnableSequence(thing) {\n return Array.isArray(thing.middle) && Runnable.isRunnable(thing);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static from([first, ...runnables], nameOrFields) {\n let extra = {};\n if (typeof nameOrFields === \"string\") {\n extra.name = nameOrFields;\n } else if (nameOrFields !== undefined) {\n extra = nameOrFields;\n }\n return new RunnableSequence({\n ...extra,\n first: _coerceToRunnable(first),\n middle: runnables.slice(0, -1).map(_coerceToRunnable),\n last: _coerceToRunnable(runnables[runnables.length - 1])\n });\n }\n}\n/**\n * A runnable that runs a mapping of runnables in parallel,\n * and returns a mapping of their outputs.\n * @example\n * ```typescript\n * const mapChain = RunnableMap.from({\n * joke: PromptTemplate.fromTemplate(\"Tell me a joke about {topic}\").pipe(\n * new ChatAnthropic({}),\n * ),\n * poem: PromptTemplate.fromTemplate(\"write a 2-line poem about {topic}\").pipe(\n * new ChatAnthropic({}),\n * ),\n * });\n * const result = await mapChain.invoke({ topic: \"bear\" });\n * ```\n */\nexport class RunnableMap extends Runnable {\n static lc_name() {\n return \"RunnableMap\";\n }\n getStepsKeys() {\n return Object.keys(this.steps);\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"steps\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.steps = {};\n for (const [key, value] of Object.entries(fields.steps)) {\n this.steps[key] = _coerceToRunnable(value);\n }\n }\n static from(steps) {\n return new RunnableMap({\n steps\n });\n }\n invoke(input, options) {\n var _this33 = this;\n return _asyncToGenerator(function* () {\n const config = ensureConfig(options);\n const callbackManager_ = yield getCallbackManagerForConfig(config);\n const runManager = yield callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this33.toJSON(), {\n input\n }, config.runId, undefined, undefined, undefined, config === null || config === void 0 ? void 0 : config.runName);\n delete config.runId;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const output = {};\n try {\n const promises = Object.entries(_this33.steps).map( /*#__PURE__*/function () {\n var _ref10 = _asyncToGenerator(function* ([key, runnable]) {\n output[key] = yield runnable.invoke(input, patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(`map:key:${key}`)\n }));\n });\n return function (_x8) {\n return _ref10.apply(this, arguments);\n };\n }());\n yield raceWithSignal(Promise.all(promises), options === null || options === void 0 ? void 0 : options.signal);\n } catch (e) {\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e);\n throw e;\n }\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(output);\n return output;\n })();\n }\n _transform(generator, runManager, options) {\n var _this11 = this;\n return _wrapAsyncGenerator(function* () {\n // shallow copy steps to ignore changes while iterating\n const steps = {\n ..._this11.steps\n };\n // each step gets a copy of the input iterator\n const inputCopies = atee(generator, Object.keys(steps).length);\n // start the first iteration of each output iterator\n const tasks = new Map(Object.entries(steps).map(([key, runnable], i) => {\n const gen = runnable.transform(inputCopies[i], patchConfig(options, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(`map:key:${key}`)\n }));\n return [key, gen.next().then(result => ({\n key,\n gen,\n result\n }))];\n }));\n // yield chunks as they become available,\n // starting new iterations as needed,\n // until all iterators are done\n while (tasks.size) {\n const promise = Promise.race(tasks.values());\n const {\n key,\n result,\n gen\n } = yield _awaitAsyncGenerator(raceWithSignal(promise, options === null || options === void 0 ? void 0 : options.signal));\n tasks.delete(key);\n if (!result.done) {\n yield {\n [key]: result.value\n };\n tasks.set(key, gen.next().then(result => ({\n key,\n gen,\n result\n })));\n }\n }\n })();\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n stream(input, options) {\n var _this34 = this;\n return _asyncToGenerator(function* () {\n function generator() {\n return _generator.apply(this, arguments);\n }\n function _generator() {\n _generator = _wrapAsyncGenerator(function* () {\n yield input;\n });\n return _generator.apply(this, arguments);\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: _this34.transform(generator(), config),\n config\n });\n yield wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n })();\n }\n}\n/**\n * A runnable that wraps a traced LangSmith function.\n */\nexport class RunnableTraceable extends Runnable {\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"func\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n if (!isTraceableFunction(fields.func)) {\n throw new Error(\"RunnableTraceable requires a function that is wrapped in traceable higher-order function\");\n }\n this.func = fields.func;\n }\n invoke(input, options) {\n var _this35 = this;\n return _asyncToGenerator(function* () {\n const [config] = _this35._getOptionsList(options !== null && options !== void 0 ? options : {}, 1);\n const callbacks = yield getCallbackManagerForConfig(config);\n const promise = _this35.func(patchConfig(config, {\n callbacks\n }), input);\n return raceWithSignal(promise, config === null || config === void 0 ? void 0 : config.signal);\n })();\n }\n _streamIterator(input, options) {\n var _this12 = this;\n return _wrapAsyncGenerator(function* () {\n const [config] = _this12._getOptionsList(options !== null && options !== void 0 ? options : {}, 1);\n const result = yield _awaitAsyncGenerator(_this12.invoke(input, options));\n if (isAsyncIterable(result)) {\n var _iteratorAbruptCompletion10 = false;\n var _didIteratorError10 = false;\n var _iteratorError10;\n try {\n for (var _iterator10 = _asyncIterator(result), _step10; _iteratorAbruptCompletion10 = !(_step10 = yield _awaitAsyncGenerator(_iterator10.next())).done; _iteratorAbruptCompletion10 = false) {\n const item = _step10.value;\n {\n var _config$signal;\n config === null || config === void 0 || (_config$signal = config.signal) === null || _config$signal === void 0 || _config$signal.throwIfAborted();\n yield item;\n }\n }\n } catch (err) {\n _didIteratorError10 = true;\n _iteratorError10 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion10 && _iterator10.return != null) {\n yield _awaitAsyncGenerator(_iterator10.return());\n }\n } finally {\n if (_didIteratorError10) {\n throw _iteratorError10;\n }\n }\n }\n return;\n }\n if (isIterator(result)) {\n while (true) {\n var _config$signal2;\n config === null || config === void 0 || (_config$signal2 = config.signal) === null || _config$signal2 === void 0 || _config$signal2.throwIfAborted();\n const state = result.next();\n if (state.done) break;\n yield state.value;\n }\n return;\n }\n yield result;\n })();\n }\n static from(func) {\n return new RunnableTraceable({\n func\n });\n }\n}\nfunction assertNonTraceableFunction(func) {\n if (isTraceableFunction(func)) {\n throw new Error(\"RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.\");\n }\n}\n/**\n * A runnable that wraps an arbitrary function that takes a single argument.\n * @example\n * ```typescript\n * import { RunnableLambda } from \"@langchain/core/runnables\";\n *\n * const add = (input: { x: number; y: number }) => input.x + input.y;\n *\n * const multiply = (input: { value: number; multiplier: number }) =>\n * input.value * input.multiplier;\n *\n * // Create runnables for the functions\n * const addLambda = RunnableLambda.from(add);\n * const multiplyLambda = RunnableLambda.from(multiply);\n *\n * // Chain the lambdas for a mathematical operation\n * const chainedLambda = addLambda.pipe((result) =>\n * multiplyLambda.invoke({ value: result, multiplier: 2 })\n * );\n *\n * // Example invocation of the chainedLambda\n * const result = await chainedLambda.invoke({ x: 2, y: 3 });\n *\n * // Will log \"10\" (since (2 + 3) * 2 = 10)\n * ```\n */\nexport class RunnableLambda extends Runnable {\n static lc_name() {\n return \"RunnableLambda\";\n }\n constructor(fields) {\n if (isTraceableFunction(fields.func)) {\n // eslint-disable-next-line no-constructor-return\n return RunnableTraceable.from(fields.func);\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"func\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n assertNonTraceableFunction(fields.func);\n this.func = fields.func;\n }\n static from(func) {\n return new RunnableLambda({\n func\n });\n }\n _invoke(input, config, runManager) {\n var _this36 = this;\n return _asyncToGenerator(function* () {\n return new Promise((resolve, reject) => {\n var _config$recursionLimi;\n const childConfig = patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(),\n recursionLimit: ((_config$recursionLimi = config === null || config === void 0 ? void 0 : config.recursionLimit) !== null && _config$recursionLimi !== void 0 ? _config$recursionLimi : DEFAULT_RECURSION_LIMIT) - 1\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(childConfig, /*#__PURE__*/_asyncToGenerator(function* () {\n try {\n let output = yield _this36.func(input, {\n ...childConfig\n });\n if (output && Runnable.isRunnable(output)) {\n var _childConfig$recursio;\n if ((config === null || config === void 0 ? void 0 : config.recursionLimit) === 0) {\n throw new Error(\"Recursion limit reached.\");\n }\n output = yield output.invoke(input, {\n ...childConfig,\n recursionLimit: ((_childConfig$recursio = childConfig.recursionLimit) !== null && _childConfig$recursio !== void 0 ? _childConfig$recursio : DEFAULT_RECURSION_LIMIT) - 1\n });\n } else if (isAsyncIterable(output)) {\n let finalOutput;\n var _iteratorAbruptCompletion11 = false;\n var _didIteratorError11 = false;\n var _iteratorError11;\n try {\n for (var _iterator11 = _asyncIterator(consumeAsyncIterableInContext(childConfig, output)), _step11; _iteratorAbruptCompletion11 = !(_step11 = yield _iterator11.next()).done; _iteratorAbruptCompletion11 = false) {\n const chunk = _step11.value;\n {\n var _config$signal3;\n config === null || config === void 0 || (_config$signal3 = config.signal) === null || _config$signal3 === void 0 || _config$signal3.throwIfAborted();\n if (finalOutput === undefined) {\n finalOutput = chunk;\n } else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n } catch (e) {\n finalOutput = chunk;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError11 = true;\n _iteratorError11 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion11 && _iterator11.return != null) {\n yield _iterator11.return();\n }\n } finally {\n if (_didIteratorError11) {\n throw _iteratorError11;\n }\n }\n }\n output = finalOutput;\n } else if (isIterableIterator(output)) {\n let finalOutput;\n for (const chunk of consumeIteratorInContext(childConfig, output)) {\n var _config$signal4;\n config === null || config === void 0 || (_config$signal4 = config.signal) === null || _config$signal4 === void 0 || _config$signal4.throwIfAborted();\n if (finalOutput === undefined) {\n finalOutput = chunk;\n } else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n } catch (e) {\n finalOutput = chunk;\n }\n }\n }\n output = finalOutput;\n }\n resolve(output);\n } catch (e) {\n reject(e);\n }\n }));\n });\n })();\n }\n invoke(input, options) {\n var _this37 = this;\n return _asyncToGenerator(function* () {\n return _this37._callWithConfig(_this37._invoke.bind(_this37), input, options);\n })();\n }\n _transform(generator, runManager, config) {\n var _this13 = this;\n return _wrapAsyncGenerator(function* () {\n var _config$recursionLimi2;\n let finalChunk;\n var _iteratorAbruptCompletion12 = false;\n var _didIteratorError12 = false;\n var _iteratorError12;\n try {\n for (var _iterator12 = _asyncIterator(generator), _step12; _iteratorAbruptCompletion12 = !(_step12 = yield _awaitAsyncGenerator(_iterator12.next())).done; _iteratorAbruptCompletion12 = false) {\n const chunk = _step12.value;\n {\n if (finalChunk === undefined) {\n finalChunk = chunk;\n } else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalChunk = concat(finalChunk, chunk);\n } catch (e) {\n finalChunk = chunk;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError12 = true;\n _iteratorError12 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion12 && _iterator12.return != null) {\n yield _awaitAsyncGenerator(_iterator12.return());\n }\n } finally {\n if (_didIteratorError12) {\n throw _iteratorError12;\n }\n }\n }\n const childConfig = patchConfig(config, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild(),\n recursionLimit: ((_config$recursionLimi2 = config === null || config === void 0 ? void 0 : config.recursionLimit) !== null && _config$recursionLimi2 !== void 0 ? _config$recursionLimi2 : DEFAULT_RECURSION_LIMIT) - 1\n });\n const output = yield _awaitAsyncGenerator(new Promise((resolve, reject) => {\n void AsyncLocalStorageProviderSingleton.runWithConfig(childConfig, /*#__PURE__*/_asyncToGenerator(function* () {\n try {\n const res = yield _this13.func(finalChunk, {\n ...childConfig,\n config: childConfig\n });\n resolve(res);\n } catch (e) {\n reject(e);\n }\n }));\n }));\n if (output && Runnable.isRunnable(output)) {\n if ((config === null || config === void 0 ? void 0 : config.recursionLimit) === 0) {\n throw new Error(\"Recursion limit reached.\");\n }\n const stream = yield _awaitAsyncGenerator(output.stream(finalChunk, childConfig));\n var _iteratorAbruptCompletion13 = false;\n var _didIteratorError13 = false;\n var _iteratorError13;\n try {\n for (var _iterator13 = _asyncIterator(stream), _step13; _iteratorAbruptCompletion13 = !(_step13 = yield _awaitAsyncGenerator(_iterator13.next())).done; _iteratorAbruptCompletion13 = false) {\n const chunk = _step13.value;\n {\n yield chunk;\n }\n }\n } catch (err) {\n _didIteratorError13 = true;\n _iteratorError13 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion13 && _iterator13.return != null) {\n yield _awaitAsyncGenerator(_iterator13.return());\n }\n } finally {\n if (_didIteratorError13) {\n throw _iteratorError13;\n }\n }\n }\n } else if (isAsyncIterable(output)) {\n var _iteratorAbruptCompletion14 = false;\n var _didIteratorError14 = false;\n var _iteratorError14;\n try {\n for (var _iterator14 = _asyncIterator(consumeAsyncIterableInContext(childConfig, output)), _step14; _iteratorAbruptCompletion14 = !(_step14 = yield _awaitAsyncGenerator(_iterator14.next())).done; _iteratorAbruptCompletion14 = false) {\n const chunk = _step14.value;\n {\n var _config$signal5;\n config === null || config === void 0 || (_config$signal5 = config.signal) === null || _config$signal5 === void 0 || _config$signal5.throwIfAborted();\n yield chunk;\n }\n }\n } catch (err) {\n _didIteratorError14 = true;\n _iteratorError14 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion14 && _iterator14.return != null) {\n yield _awaitAsyncGenerator(_iterator14.return());\n }\n } finally {\n if (_didIteratorError14) {\n throw _iteratorError14;\n }\n }\n }\n } else if (isIterableIterator(output)) {\n for (const chunk of consumeIteratorInContext(childConfig, output)) {\n var _config$signal6;\n config === null || config === void 0 || (_config$signal6 = config.signal) === null || _config$signal6 === void 0 || _config$signal6.throwIfAborted();\n yield chunk;\n }\n } else {\n yield output;\n }\n })();\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n stream(input, options) {\n var _this38 = this;\n return _asyncToGenerator(function* () {\n function generator() {\n return _generator2.apply(this, arguments);\n }\n function _generator2() {\n _generator2 = _wrapAsyncGenerator(function* () {\n yield input;\n });\n return _generator2.apply(this, arguments);\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: _this38.transform(generator(), config),\n config\n });\n yield wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n })();\n }\n}\n/**\n * A runnable that runs a mapping of runnables in parallel,\n * and returns a mapping of their outputs.\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableParallel,\n * } from \"@langchain/core/runnables\";\n *\n * const addYears = (age: number): number => age + 5;\n * const yearsToFifty = (age: number): number => 50 - age;\n * const yearsToHundred = (age: number): number => 100 - age;\n *\n * const addYearsLambda = RunnableLambda.from(addYears);\n * const milestoneFiftyLambda = RunnableLambda.from(yearsToFifty);\n * const milestoneHundredLambda = RunnableLambda.from(yearsToHundred);\n *\n * // Pipe will coerce objects into RunnableParallel by default, but we\n * // explicitly instantiate one here to demonstrate\n * const sequence = addYearsLambda.pipe(\n * RunnableParallel.from({\n * years_to_fifty: milestoneFiftyLambda,\n * years_to_hundred: milestoneHundredLambda,\n * })\n * );\n *\n * // Invoke the sequence with a single age input\n * const res = sequence.invoke(25);\n *\n * // { years_to_fifty: 25, years_to_hundred: 75 }\n * ```\n */\nexport class RunnableParallel extends RunnableMap {}\n/**\n * A Runnable that can fallback to other Runnables if it fails.\n * External APIs (e.g., APIs for a language model) may at times experience\n * degraded performance or even downtime.\n *\n * In these cases, it can be useful to have a fallback Runnable that can be\n * used in place of the original Runnable (e.g., fallback to another LLM provider).\n *\n * Fallbacks can be defined at the level of a single Runnable, or at the level\n * of a chain of Runnables. Fallbacks are tried in order until one succeeds or\n * all fail.\n *\n * While you can instantiate a `RunnableWithFallbacks` directly, it is usually\n * more convenient to use the `withFallbacks` method on an existing Runnable.\n *\n * When streaming, fallbacks will only be called on failures during the initial\n * stream creation. Errors that occur after a stream starts will not fallback\n * to the next Runnable.\n *\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableWithFallbacks,\n * } from \"@langchain/core/runnables\";\n *\n * const primaryOperation = (input: string): string => {\n * if (input !== \"safe\") {\n * throw new Error(\"Primary operation failed due to unsafe input\");\n * }\n * return `Processed: ${input}`;\n * };\n *\n * // Define a fallback operation that processes the input differently\n * const fallbackOperation = (input: string): string =>\n * `Fallback processed: ${input}`;\n *\n * const primaryRunnable = RunnableLambda.from(primaryOperation);\n * const fallbackRunnable = RunnableLambda.from(fallbackOperation);\n *\n * // Apply the fallback logic using the .withFallbacks() method\n * const runnableWithFallback = primaryRunnable.withFallbacks([fallbackRunnable]);\n *\n * // Alternatively, create a RunnableWithFallbacks instance manually\n * const manualFallbackChain = new RunnableWithFallbacks({\n * runnable: primaryRunnable,\n * fallbacks: [fallbackRunnable],\n * });\n *\n * // Example invocation using .withFallbacks()\n * const res = await runnableWithFallback\n * .invoke(\"unsafe input\")\n * .catch((error) => {\n * console.error(\"Failed after all attempts:\", error.message);\n * });\n *\n * // \"Fallback processed: unsafe input\"\n *\n * // Example invocation using manual instantiation\n * const res = await manualFallbackChain\n * .invoke(\"safe\")\n * .catch((error) => {\n * console.error(\"Failed after all attempts:\", error.message);\n * });\n *\n * // \"Processed: safe\"\n * ```\n */\nexport class RunnableWithFallbacks extends Runnable {\n static lc_name() {\n return \"RunnableWithFallbacks\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"runnable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"fallbacks\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.runnable = fields.runnable;\n this.fallbacks = fields.fallbacks;\n }\n *runnables() {\n yield this.runnable;\n for (const fallback of this.fallbacks) {\n yield fallback;\n }\n }\n invoke(input, options) {\n var _this39 = this;\n return _asyncToGenerator(function* () {\n const config = ensureConfig(options);\n const callbackManager_ = yield getCallbackManagerForConfig(options);\n const {\n runId,\n ...otherConfigFields\n } = config;\n const runManager = yield callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this39.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherConfigFields === null || otherConfigFields === void 0 ? void 0 : otherConfigFields.runName);\n let firstError;\n for (const runnable of _this39.runnables()) {\n var _config$signal7;\n config === null || config === void 0 || (_config$signal7 = config.signal) === null || _config$signal7 === void 0 || _config$signal7.throwIfAborted();\n try {\n const output = yield runnable.invoke(input, patchConfig(otherConfigFields, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild()\n }));\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(output, \"output\"));\n return output;\n } catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (firstError === undefined) {\n throw new Error(\"No error stored at end of fallback.\");\n }\n yield runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(firstError);\n throw firstError;\n })();\n }\n _streamIterator(input, options) {\n var _this14 = this;\n return _wrapAsyncGenerator(function* () {\n const config = ensureConfig(options);\n const callbackManager_ = yield _awaitAsyncGenerator(getCallbackManagerForConfig(options));\n const {\n runId,\n ...otherConfigFields\n } = config;\n const runManager = yield _awaitAsyncGenerator(callbackManager_ === null || callbackManager_ === void 0 ? void 0 : callbackManager_.handleChainStart(_this14.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherConfigFields === null || otherConfigFields === void 0 ? void 0 : otherConfigFields.runName));\n let firstError;\n let stream;\n for (const runnable of _this14.runnables()) {\n var _config$signal8;\n config === null || config === void 0 || (_config$signal8 = config.signal) === null || _config$signal8 === void 0 || _config$signal8.throwIfAborted();\n const childConfig = patchConfig(otherConfigFields, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild()\n });\n try {\n stream = yield _awaitAsyncGenerator(runnable.stream(input, childConfig));\n break;\n } catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (stream === undefined) {\n var _firstError;\n const error = (_firstError = firstError) !== null && _firstError !== void 0 ? _firstError : new Error(\"No error stored at end of fallback.\");\n yield _awaitAsyncGenerator(runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(error));\n throw error;\n }\n let output;\n try {\n var _iteratorAbruptCompletion15 = false;\n var _didIteratorError15 = false;\n var _iteratorError15;\n try {\n for (var _iterator15 = _asyncIterator(stream), _step15; _iteratorAbruptCompletion15 = !(_step15 = yield _awaitAsyncGenerator(_iterator15.next())).done; _iteratorAbruptCompletion15 = false) {\n const chunk = _step15.value;\n {\n yield chunk;\n try {\n output = output === undefined ? output : concat(output, chunk);\n } catch (e) {\n output = undefined;\n }\n }\n }\n } catch (err) {\n _didIteratorError15 = true;\n _iteratorError15 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion15 && _iterator15.return != null) {\n yield _awaitAsyncGenerator(_iterator15.return());\n }\n } finally {\n if (_didIteratorError15) {\n throw _iteratorError15;\n }\n }\n }\n } catch (e) {\n yield _awaitAsyncGenerator(runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(e));\n throw e;\n }\n yield _awaitAsyncGenerator(runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(output, \"output\")));\n })();\n }\n batch(inputs, options, batchOptions) {\n var _this40 = this;\n return _asyncToGenerator(function* () {\n if (batchOptions !== null && batchOptions !== void 0 && batchOptions.returnExceptions) {\n throw new Error(\"Not implemented.\");\n }\n const configList = _this40._getOptionsList(options !== null && options !== void 0 ? options : {}, inputs.length);\n const callbackManagers = yield Promise.all(configList.map(config => getCallbackManagerForConfig(config)));\n const runManagers = yield Promise.all(callbackManagers.map( /*#__PURE__*/function () {\n var _ref13 = _asyncToGenerator(function* (callbackManager, i) {\n const handleStartRes = yield callbackManager === null || callbackManager === void 0 ? void 0 : callbackManager.handleChainStart(_this40.toJSON(), _coerceToDict(inputs[i], \"input\"), configList[i].runId, undefined, undefined, undefined, configList[i].runName);\n delete configList[i].runId;\n return handleStartRes;\n });\n return function (_x9, _x10) {\n return _ref13.apply(this, arguments);\n };\n }()));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let firstError;\n for (const runnable of _this40.runnables()) {\n var _configList$0$signal;\n (_configList$0$signal = configList[0].signal) === null || _configList$0$signal === void 0 || _configList$0$signal.throwIfAborted();\n try {\n const outputs = yield runnable.batch(inputs, runManagers.map((runManager, j) => patchConfig(configList[j], {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild()\n })), batchOptions);\n yield Promise.all(runManagers.map((runManager, i) => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainEnd(_coerceToDict(outputs[i], \"output\"))));\n return outputs;\n } catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (!firstError) {\n throw new Error(\"No error stored at end of fallbacks.\");\n }\n yield Promise.all(runManagers.map(runManager => runManager === null || runManager === void 0 ? void 0 : runManager.handleChainError(firstError)));\n throw firstError;\n })();\n }\n}\n// TODO: Figure out why the compiler needs help eliminating Error as a RunOutput type\nexport function _coerceToRunnable(coerceable) {\n if (typeof coerceable === \"function\") {\n return new RunnableLambda({\n func: coerceable\n });\n } else if (Runnable.isRunnable(coerceable)) {\n return coerceable;\n } else if (!Array.isArray(coerceable) && typeof coerceable === \"object\") {\n const runnables = {};\n for (const [key, value] of Object.entries(coerceable)) {\n runnables[key] = _coerceToRunnable(value);\n }\n return new RunnableMap({\n steps: runnables\n });\n } else {\n throw new Error(`Expected a Runnable, function or object.\\nInstead got an unsupported type.`);\n }\n}\n/**\n * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.\n * @example\n * ```typescript\n * import {\n * RunnableAssign,\n * RunnableLambda,\n * RunnableParallel,\n * } from \"@langchain/core/runnables\";\n *\n * const calculateAge = (x: { birthYear: number }): { age: number } => {\n * const currentYear = new Date().getFullYear();\n * return { age: currentYear - x.birthYear };\n * };\n *\n * const createGreeting = (x: { name: string }): { greeting: string } => {\n * return { greeting: `Hello, ${x.name}!` };\n * };\n *\n * const mapper = RunnableParallel.from({\n * age_step: RunnableLambda.from(calculateAge),\n * greeting_step: RunnableLambda.from(createGreeting),\n * });\n *\n * const runnableAssign = new RunnableAssign({ mapper });\n *\n * const res = await runnableAssign.invoke({ name: \"Alice\", birthYear: 1990 });\n *\n * // { name: \"Alice\", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: \"Hello, Alice!\" } }\n * ```\n */\nexport class RunnableAssign extends Runnable {\n static lc_name() {\n return \"RunnableAssign\";\n }\n constructor(fields) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (fields instanceof RunnableMap) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n mapper: fields\n };\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"mapper\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.mapper = fields.mapper;\n }\n invoke(input, options) {\n var _this41 = this;\n return _asyncToGenerator(function* () {\n const mapperResult = yield _this41.mapper.invoke(input, options);\n return {\n ...input,\n ...mapperResult\n };\n })();\n }\n _transform(generator, runManager, options) {\n var _this15 = this;\n return _wrapAsyncGenerator(function* () {\n // collect mapper keys\n const mapperKeys = _this15.mapper.getStepsKeys();\n // create two input gens, one for the mapper, one for the input\n const [forPassthrough, forMapper] = atee(generator);\n // create mapper output gen\n const mapperOutput = _this15.mapper.transform(forMapper, patchConfig(options, {\n callbacks: runManager === null || runManager === void 0 ? void 0 : runManager.getChild()\n }));\n // start the mapper\n const firstMapperChunkPromise = mapperOutput.next();\n // yield the passthrough\n var _iteratorAbruptCompletion16 = false;\n var _didIteratorError16 = false;\n var _iteratorError16;\n try {\n for (var _iterator16 = _asyncIterator(forPassthrough), _step16; _iteratorAbruptCompletion16 = !(_step16 = yield _awaitAsyncGenerator(_iterator16.next())).done; _iteratorAbruptCompletion16 = false) {\n const chunk = _step16.value;\n {\n if (typeof chunk !== \"object\" || Array.isArray(chunk)) {\n throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof chunk}`);\n }\n const filtered = Object.fromEntries(Object.entries(chunk).filter(([key]) => !mapperKeys.includes(key)));\n if (Object.keys(filtered).length > 0) {\n yield filtered;\n }\n }\n }\n // yield the mapper output\n } catch (err) {\n _didIteratorError16 = true;\n _iteratorError16 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion16 && _iterator16.return != null) {\n yield _awaitAsyncGenerator(_iterator16.return());\n }\n } finally {\n if (_didIteratorError16) {\n throw _iteratorError16;\n }\n }\n }\n yield (yield _awaitAsyncGenerator(firstMapperChunkPromise)).value;\n var _iteratorAbruptCompletion17 = false;\n var _didIteratorError17 = false;\n var _iteratorError17;\n try {\n for (var _iterator17 = _asyncIterator(mapperOutput), _step17; _iteratorAbruptCompletion17 = !(_step17 = yield _awaitAsyncGenerator(_iterator17.next())).done; _iteratorAbruptCompletion17 = false) {\n const chunk = _step17.value;\n {\n yield chunk;\n }\n }\n } catch (err) {\n _didIteratorError17 = true;\n _iteratorError17 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion17 && _iterator17.return != null) {\n yield _awaitAsyncGenerator(_iterator17.return());\n }\n } finally {\n if (_didIteratorError17) {\n throw _iteratorError17;\n }\n }\n }\n })();\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n stream(input, options) {\n var _this42 = this;\n return _asyncToGenerator(function* () {\n function generator() {\n return _generator3.apply(this, arguments);\n }\n function _generator3() {\n _generator3 = _wrapAsyncGenerator(function* () {\n yield input;\n });\n return _generator3.apply(this, arguments);\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: _this42.transform(generator(), config),\n config\n });\n yield wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n })();\n }\n}\n/**\n * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.\n * Useful for streaming, can be automatically created and chained by calling `runnable.pick();`.\n * @example\n * ```typescript\n * import { RunnablePick } from \"@langchain/core/runnables\";\n *\n * const inputData = {\n * name: \"John\",\n * age: 30,\n * city: \"New York\",\n * country: \"USA\",\n * email: \"john.doe@example.com\",\n * phone: \"+1234567890\",\n * };\n *\n * const basicInfoRunnable = new RunnablePick([\"name\", \"city\"]);\n *\n * // Example invocation\n * const res = await basicInfoRunnable.invoke(inputData);\n *\n * // { name: 'John', city: 'New York' }\n * ```\n */\nexport class RunnablePick extends Runnable {\n static lc_name() {\n return \"RunnablePick\";\n }\n constructor(fields) {\n if (typeof fields === \"string\" || Array.isArray(fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n keys: fields\n };\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"keys\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.keys = fields.keys;\n }\n _pick(input) {\n var _this43 = this;\n return _asyncToGenerator(function* () {\n if (typeof _this43.keys === \"string\") {\n return input[_this43.keys];\n } else {\n const picked = _this43.keys.map(key => [key, input[key]]).filter(v => v[1] !== undefined);\n return picked.length === 0 ? undefined : Object.fromEntries(picked);\n }\n })();\n }\n invoke(input, options) {\n var _this44 = this;\n return _asyncToGenerator(function* () {\n return _this44._callWithConfig(_this44._pick.bind(_this44), input, options);\n })();\n }\n _transform(generator) {\n var _this16 = this;\n return _wrapAsyncGenerator(function* () {\n var _iteratorAbruptCompletion18 = false;\n var _didIteratorError18 = false;\n var _iteratorError18;\n try {\n for (var _iterator18 = _asyncIterator(generator), _step18; _iteratorAbruptCompletion18 = !(_step18 = yield _awaitAsyncGenerator(_iterator18.next())).done; _iteratorAbruptCompletion18 = false) {\n const chunk = _step18.value;\n {\n const picked = yield _awaitAsyncGenerator(_this16._pick(chunk));\n if (picked !== undefined) {\n yield picked;\n }\n }\n }\n } catch (err) {\n _didIteratorError18 = true;\n _iteratorError18 = err;\n } finally {\n try {\n if (_iteratorAbruptCompletion18 && _iterator18.return != null) {\n yield _awaitAsyncGenerator(_iterator18.return());\n }\n } finally {\n if (_didIteratorError18) {\n throw _iteratorError18;\n }\n }\n }\n })();\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n stream(input, options) {\n var _this45 = this;\n return _asyncToGenerator(function* () {\n function generator() {\n return _generator4.apply(this, arguments);\n }\n function _generator4() {\n _generator4 = _wrapAsyncGenerator(function* () {\n yield input;\n });\n return _generator4.apply(this, arguments);\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: _this45.transform(generator(), config),\n config\n });\n yield wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n })();\n }\n}\nexport class RunnableToolLike extends RunnableBinding {\n constructor(fields) {\n var _this46;\n const sequence = RunnableSequence.from([RunnableLambda.from( /*#__PURE__*/function () {\n var _ref14 = _asyncToGenerator(function* (input) {\n let toolInput;\n if (_isToolCall(input)) {\n try {\n toolInput = yield _this46.schema.parseAsync(input.args);\n } catch (e) {\n throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(input.args));\n }\n } else {\n toolInput = input;\n }\n return toolInput;\n });\n return function (_x11) {\n return _ref14.apply(this, arguments);\n };\n }()).withConfig({\n runName: `${fields.name}:parse_input`\n }), fields.bound]).withConfig({\n runName: fields.name\n });\n super({\n bound: sequence,\n config: fields.config ?? {}\n });\n _this46 = this;\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"description\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"schema\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = fields.name;\n this.description = fields.description;\n this.schema = fields.schema;\n }\n static lc_name() {\n return \"RunnableToolLike\";\n }\n}\n/**\n * Given a runnable and a Zod schema, convert the runnable to a tool.\n *\n * @template RunInput The input type for the runnable.\n * @template RunOutput The output type for the runnable.\n *\n * @param {Runnable<RunInput, RunOutput>} runnable The runnable to convert to a tool.\n * @param fields\n * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable.\n * @param {string | undefined} [fields.description] The description of the tool. Falls back to the description on the Zod schema if not provided, or undefined if neither are provided.\n * @param {z.ZodType<RunInput>} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable.\n * @returns {RunnableToolLike<z.ZodType<RunInput>, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool.\n */\nexport function convertRunnableToTool(runnable, fields) {\n var _fields$name, _fields$description, _fields$schema;\n const name = (_fields$name = fields.name) !== null && _fields$name !== void 0 ? _fields$name : runnable.getName();\n const description = (_fields$description = fields.description) !== null && _fields$description !== void 0 ? _fields$description : (_fields$schema = fields.schema) === null || _fields$schema === void 0 ? void 0 : _fields$schema.description;\n if (fields.schema.constructor === z.ZodString) {\n return new RunnableToolLike({\n name,\n description,\n schema: z.object({\n input: z.string()\n }).transform(input => input.input),\n bound: runnable\n });\n }\n return new RunnableToolLike({\n name,\n description,\n schema: fields.schema,\n bound: runnable\n });\n}","map":{"version":3,"names":["z","pRetry","v4","uuidv4","isTraceableFunction","LogStreamCallbackHandler","RunLog","RunLogPatch","isLogStreamHandler","EventStreamCallbackHandler","isStreamEventsHandler","Serializable","IterableReadableStream","concat","atee","pipeGeneratorWithSetup","AsyncGeneratorWithSetup","raceWithSignal","DEFAULT_RECURSION_LIMIT","ensureConfig","getCallbackManagerForConfig","mergeConfigs","patchConfig","AsyncCaller","RootListenersTracer","_RootEventFilter","isRunnableInterface","AsyncLocalStorageProviderSingleton","Graph","convertToHttpEventStream","consumeAsyncIterableInContext","consumeIteratorInContext","isAsyncIterable","isIterableIterator","isIterator","_isToolCall","ToolInputParsingException","_coerceToDict","value","defaultKey","Array","isArray","Date","Runnable","constructor","arguments","Object","defineProperty","enumerable","configurable","writable","getName","suffix","_ref2","_this$name","name","lc_name","bind","kwargs","RunnableBinding","bound","config","map","RunnableEach","withRetry","fields","RunnableRetry","maxAttemptNumber","stopAfterAttempt","withConfig","withFallbacks","fallbacks","RunnableWithFallbacks","runnable","_getOptionsList","options","length","Error","runId","console","warn","subsequent","fromEntries","entries","filter","key","from","_","i","batch","inputs","batchOptions","_this17","_asyncToGenerator","_configList$0$maxConc","_configList$","configList","maxConcurrency","caller","onFailedAttempt","e","batchCalls","input","call","result","invoke","returnExceptions","Promise","all","_streamIterator","_this","_wrapAsyncGenerator","stream","_this18","wrappedGenerator","generator","setup","fromAsyncGenerator","_separateRunnableConfigFromCallOptions","runnableConfig","undefined","callbacks","tags","metadata","runName","recursionLimit","timeout","signal","callOptions","_callWithConfig","func","_this19","_config$runName","callbackManager_","runManager","handleChainStart","toJSON","runType","output","promise","handleChainError","handleChainEnd","_batchWithConfig","_this20","optionsList","callbackManagers","runManagers","_ref4","callbackManager","_optionsList$i$runNam","handleStartRes","_x","_x2","apply","outputs","_optionsList$","_transformStreamWithConfig","inputGenerator","transformer","_this2","_runManager4","_finalOutput","finalInput","finalInputSupported","finalOutput","finalOutputSupported","_awaitAsyncGenerator","wrapInputForTracing","_wrapInputForTracing","_iteratorAbruptCompletion2","_didIteratorError2","_iteratorError2","_iterator2","_asyncIterator","_step2","next","done","chunk","err","return","_runManager","_runManager2","pipe","_config$runName2","streamEventsHandler","handlers","find","iterator","tapOutputIterable","streamLogHandler","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_step","_runManager3","getGraph","graph","inputNode","addNode","schema","any","runnableNode","outputNode","addEdge","coerceable","RunnableSequence","first","last","_coerceToRunnable","pick","keys","RunnablePick","assign","mapping","RunnableAssign","RunnableMap","steps","transform","_this3","finalChunk","_iteratorAbruptCompletion3","_didIteratorError3","_iteratorError3","_iterator3","_step3","_asyncGeneratorDelegate","streamLog","streamOptions","_this4","logStreamCallbackHandler","autoClose","_schemaFormat","_streamLog","_this5","copiedCallbacks","copy","addHandler","runnableStreamPromise","consumeRunnableStream","_consumeRunnableStream","runnableStream","_iteratorAbruptCompletion5","_didIteratorError5","_iteratorError5","_iterator5","_step5","patch","ops","op","path","writer","write","close","runnableStreamConsumePromise","_iteratorAbruptCompletion4","_didIteratorError4","_iteratorError4","_iterator4","_step4","log","streamEvents","version","_streamEventsV1","_streamEventsV2","encoding","_this6","_config$runId","eventStreamer","outerThis","_consumeRunnableStream2","tappedStream","_iteratorAbruptCompletion7","_didIteratorError7","_iteratorError7","_iterator7","_step7","finish","firstEventSent","firstEventRunId","_iteratorAbruptCompletion6","_didIteratorError6","_iteratorError6","_iterator6","_step6","event","data","run_id","endsWith","_event$data","_this7","_config$tags","_config$metadata","_config$runName3","_runLog","runLog","hasEncounteredStartEvent","rootTags","rootMetadata","rootName","rootEventFilter","logStream","_iteratorAbruptCompletion8","_didIteratorError8","_iteratorError8","_iterator8","_step8","fromRunLogPatch","state","id","type","includeEvent","paths","startsWith","split","dedupedPaths","Set","eventType","logEntry","logs","end_time","streamed_output","final_output","chunkCount","isRunnable","thing","withListeners","onStart","onEnd","onError","configFactories","asTool","convertRunnableToTool","_mergeConfig","_this21","_ref6","configFactory","_x3","_this22","_this23","mergedOptions","_ref7","individualOption","_x4","_this8","_this24","_this9","_ref","isRunnableBinding","_this25","_invoke","_this26","getChild","_fields$maxAttemptNum","_fields$onFailedAttem","_patchConfigForRetry","attempt","tag","_superprop_getInvoke","_this27","attemptNumber","error","retries","Math","max","randomize","_this28","_batch","configs","_superprop_getBatch","_this29","resultsMap","_ref8","remainingIndexes","toString","remainingInputs","patchedConfigs","results","firstException","resultMapIndex","_x5","sort","a","b","parseInt","_this30","_fields$middle","_fields$omitSequenceT","middle","omitSequenceTags","_this31","nextStepInput","_options$signal","initialSteps","step","aborted","_this32","_ref9","_x6","_x7","nextStepInputs","_configList$2","j","childRunManager","_this10","otherOptions","concatSupported","_inputGenerator","finalGenerator","_iteratorAbruptCompletion9","_didIteratorError9","_iteratorError9","_iterator9","_step9","_options$signal2","throwIfAborted","currentLastNode","forEach","index","stepGraph","trimFirstNode","trimLastNode","extend","stepFirstNode","firstNode","lastNode","isRunnableSequence","_this$name2","runnables","nameOrFields","extra","slice","getStepsKeys","_this33","promises","_ref10","_x8","_transform","_this11","inputCopies","tasks","Map","gen","then","size","race","values","delete","set","_this34","_generator","RunnableTraceable","_this35","_this12","_iteratorAbruptCompletion10","_didIteratorError10","_iteratorError10","_iterator10","_step10","item","_config$signal","_config$signal2","assertNonTraceableFunction","RunnableLambda","_this36","resolve","reject","_config$recursionLimi","childConfig","runWithConfig","_childConfig$recursio","_iteratorAbruptCompletion11","_didIteratorError11","_iteratorError11","_iterator11","_step11","_config$signal3","_config$signal4","_this37","_this13","_config$recursionLimi2","_iteratorAbruptCompletion12","_didIteratorError12","_iteratorError12","_iterator12","_step12","res","_iteratorAbruptCompletion13","_didIteratorError13","_iteratorError13","_iterator13","_step13","_iteratorAbruptCompletion14","_didIteratorError14","_iteratorError14","_iterator14","_step14","_config$signal5","_config$signal6","_this38","_generator2","RunnableParallel","fallback","_this39","otherConfigFields","firstError","_config$signal7","_this14","_config$signal8","_firstError","_iteratorAbruptCompletion15","_didIteratorError15","_iteratorError15","_iterator15","_step15","_this40","_ref13","_x9","_x10","_configList$0$signal","mapper","_this41","mapperResult","_this15","mapperKeys","forPassthrough","forMapper","mapperOutput","firstMapperChunkPromise","_iteratorAbruptCompletion16","_didIteratorError16","_iteratorError16","_iterator16","_step16","filtered","includes","_iteratorAbruptCompletion17","_didIteratorError17","_iteratorError17","_iterator17","_step17","_this42","_generator3","_pick","_this43","picked","v","_this44","_this16","_iteratorAbruptCompletion18","_didIteratorError18","_iteratorError18","_iterator18","_step18","_this45","_generator4","RunnableToolLike","_this46","sequence","_ref14","toolInput","parseAsync","args","JSON","stringify","_x11","this","description","_fields$name","_fields$description","_fields$schema","ZodString","object","string"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/dist/runnables/base.js"],"sourcesContent":["import { z } from \"zod\";\nimport pRetry from \"p-retry\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { isTraceableFunction, } from \"langsmith/singletons/traceable\";\nimport { LogStreamCallbackHandler, RunLog, RunLogPatch, isLogStreamHandler, } from \"../tracers/log_stream.js\";\nimport { EventStreamCallbackHandler, isStreamEventsHandler, } from \"../tracers/event_stream.js\";\nimport { Serializable } from \"../load/serializable.js\";\nimport { IterableReadableStream, concat, atee, pipeGeneratorWithSetup, AsyncGeneratorWithSetup, } from \"../utils/stream.js\";\nimport { raceWithSignal } from \"../utils/signal.js\";\nimport { DEFAULT_RECURSION_LIMIT, ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig, } from \"./config.js\";\nimport { AsyncCaller } from \"../utils/async_caller.js\";\nimport { RootListenersTracer } from \"../tracers/root_listener.js\";\nimport { _RootEventFilter, isRunnableInterface } from \"./utils.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../singletons/index.js\";\nimport { Graph } from \"./graph.js\";\nimport { convertToHttpEventStream } from \"./wrappers.js\";\nimport { consumeAsyncIterableInContext, consumeIteratorInContext, isAsyncIterable, isIterableIterator, isIterator, } from \"./iter.js\";\nimport { _isToolCall, ToolInputParsingException } from \"../tools/utils.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value, defaultKey) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n/**\n * A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or\n * transformed.\n */\nexport class Runnable extends Serializable {\n constructor() {\n super(...arguments);\n Object.defineProperty(this, \"lc_runnable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n getName(suffix) {\n const name = \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.name ?? this.constructor.lc_name() ?? this.constructor.name;\n return suffix ? `${name}${suffix}` : name;\n }\n /**\n * Bind arguments to a Runnable, returning a new Runnable.\n * @param kwargs\n * @returns A new RunnableBinding that, when invoked, will apply the bound args.\n */\n bind(kwargs) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({ bound: this, kwargs, config: {} });\n }\n /**\n * Return a new Runnable that maps a list of inputs to a list of outputs,\n * by calling invoke() with each input.\n */\n map() {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableEach({ bound: this });\n }\n /**\n * Add retry logic to an existing runnable.\n * @param kwargs\n * @returns A new RunnableRetry that, when invoked, will retry according to the parameters.\n */\n withRetry(fields) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableRetry({\n bound: this,\n kwargs: {},\n config: {},\n maxAttemptNumber: fields?.stopAfterAttempt,\n ...fields,\n });\n }\n /**\n * Bind config to a Runnable, returning a new Runnable.\n * @param config New configuration parameters to attach to the new runnable.\n * @returns A new RunnableBinding with a config matching what's passed.\n */\n withConfig(config) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({\n bound: this,\n config,\n kwargs: {},\n });\n }\n /**\n * Create a new runnable from the current one that will try invoking\n * other passed fallback runnables if the initial invocation fails.\n * @param fields.fallbacks Other runnables to call if the runnable errors.\n * @returns A new RunnableWithFallbacks.\n */\n withFallbacks(fields) {\n const fallbacks = Array.isArray(fields) ? fields : fields.fallbacks;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableWithFallbacks({\n runnable: this,\n fallbacks,\n });\n }\n _getOptionsList(options, length = 0) {\n if (Array.isArray(options) && options.length !== length) {\n throw new Error(`Passed \"options\" must be an array with the same length as the inputs, but got ${options.length} options for ${length} inputs`);\n }\n if (Array.isArray(options)) {\n return options.map(ensureConfig);\n }\n if (length > 1 && !Array.isArray(options) && options.runId) {\n console.warn(\"Provided runId will be used only for the first element of the batch.\");\n const subsequent = Object.fromEntries(Object.entries(options).filter(([key]) => key !== \"runId\"));\n return Array.from({ length }, (_, i) => ensureConfig(i === 0 ? options : subsequent));\n }\n return Array.from({ length }, () => ensureConfig(options));\n }\n async batch(inputs, options, batchOptions) {\n const configList = this._getOptionsList(options ?? {}, inputs.length);\n const maxConcurrency = configList[0]?.maxConcurrency ?? batchOptions?.maxConcurrency;\n const caller = new AsyncCaller({\n maxConcurrency,\n onFailedAttempt: (e) => {\n throw e;\n },\n });\n const batchCalls = inputs.map((input, i) => caller.call(async () => {\n try {\n const result = await this.invoke(input, configList[i]);\n return result;\n }\n catch (e) {\n if (batchOptions?.returnExceptions) {\n return e;\n }\n throw e;\n }\n }));\n return Promise.all(batchCalls);\n }\n /**\n * Default streaming implementation.\n * Subclasses should override this method if they support streaming output.\n * @param input\n * @param options\n */\n async *_streamIterator(input, options) {\n yield this.invoke(input, options);\n }\n /**\n * Stream output in chunks.\n * @param input\n * @param options\n * @returns A readable stream that is also an iterable.\n */\n async stream(input, options) {\n // Buffer the first streamed chunk to allow for initial errors\n // to surface immediately.\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: this._streamIterator(input, config),\n config,\n });\n await wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n }\n _separateRunnableConfigFromCallOptions(options) {\n let runnableConfig;\n if (options === undefined) {\n runnableConfig = ensureConfig(options);\n }\n else {\n runnableConfig = ensureConfig({\n callbacks: options.callbacks,\n tags: options.tags,\n metadata: options.metadata,\n runName: options.runName,\n configurable: options.configurable,\n recursionLimit: options.recursionLimit,\n maxConcurrency: options.maxConcurrency,\n runId: options.runId,\n timeout: options.timeout,\n signal: options.signal,\n });\n }\n const callOptions = { ...options };\n delete callOptions.callbacks;\n delete callOptions.tags;\n delete callOptions.metadata;\n delete callOptions.runName;\n delete callOptions.configurable;\n delete callOptions.recursionLimit;\n delete callOptions.maxConcurrency;\n delete callOptions.runId;\n delete callOptions.timeout;\n delete callOptions.signal;\n return [runnableConfig, callOptions];\n }\n async _callWithConfig(func, input, options) {\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(config);\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, \"input\"), config.runId, config?.runType, undefined, undefined, config?.runName ?? this.getName());\n delete config.runId;\n let output;\n try {\n const promise = func.call(this, input, config, runManager);\n output = await raceWithSignal(promise, options?.signal);\n }\n catch (e) {\n await runManager?.handleChainError(e);\n throw e;\n }\n await runManager?.handleChainEnd(_coerceToDict(output, \"output\"));\n return output;\n }\n /**\n * Internal method that handles batching and configuration for a runnable\n * It takes a function, input values, and optional configuration, and\n * returns a promise that resolves to the output values.\n * @param func The function to be executed for each input value.\n * @param input The input values to be processed.\n * @param config Optional configuration for the function execution.\n * @returns A promise that resolves to the output values.\n */\n async _batchWithConfig(func, inputs, options, batchOptions) {\n const optionsList = this._getOptionsList(options ?? {}, inputs.length);\n const callbackManagers = await Promise.all(optionsList.map(getCallbackManagerForConfig));\n const runManagers = await Promise.all(callbackManagers.map(async (callbackManager, i) => {\n const handleStartRes = await callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(inputs[i], \"input\"), optionsList[i].runId, optionsList[i].runType, undefined, undefined, optionsList[i].runName ?? this.getName());\n delete optionsList[i].runId;\n return handleStartRes;\n }));\n let outputs;\n try {\n const promise = func.call(this, inputs, optionsList, runManagers, batchOptions);\n outputs = await raceWithSignal(promise, optionsList?.[0]?.signal);\n }\n catch (e) {\n await Promise.all(runManagers.map((runManager) => runManager?.handleChainError(e)));\n throw e;\n }\n await Promise.all(runManagers.map((runManager) => runManager?.handleChainEnd(_coerceToDict(outputs, \"output\"))));\n return outputs;\n }\n /**\n * Helper method to transform an Iterator of Input values into an Iterator of\n * Output values, with callbacks.\n * Use this to implement `stream()` or `transform()` in Runnable subclasses.\n */\n async *_transformStreamWithConfig(inputGenerator, transformer, options) {\n let finalInput;\n let finalInputSupported = true;\n let finalOutput;\n let finalOutputSupported = true;\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(config);\n async function* wrapInputForTracing() {\n for await (const chunk of inputGenerator) {\n if (finalInputSupported) {\n if (finalInput === undefined) {\n finalInput = chunk;\n }\n else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalInput = concat(finalInput, chunk);\n }\n catch {\n finalInput = undefined;\n finalInputSupported = false;\n }\n }\n }\n yield chunk;\n }\n }\n let runManager;\n try {\n const pipe = await pipeGeneratorWithSetup(transformer.bind(this), wrapInputForTracing(), async () => callbackManager_?.handleChainStart(this.toJSON(), { input: \"\" }, config.runId, config.runType, undefined, undefined, config.runName ?? this.getName()), options?.signal, config);\n delete config.runId;\n runManager = pipe.setup;\n const streamEventsHandler = runManager?.handlers.find(isStreamEventsHandler);\n let iterator = pipe.output;\n if (streamEventsHandler !== undefined && runManager !== undefined) {\n iterator = streamEventsHandler.tapOutputIterable(runManager.runId, iterator);\n }\n const streamLogHandler = runManager?.handlers.find(isLogStreamHandler);\n if (streamLogHandler !== undefined && runManager !== undefined) {\n iterator = streamLogHandler.tapOutputIterable(runManager.runId, iterator);\n }\n for await (const chunk of iterator) {\n yield chunk;\n if (finalOutputSupported) {\n if (finalOutput === undefined) {\n finalOutput = chunk;\n }\n else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n }\n catch {\n finalOutput = undefined;\n finalOutputSupported = false;\n }\n }\n }\n }\n }\n catch (e) {\n await runManager?.handleChainError(e, undefined, undefined, undefined, {\n inputs: _coerceToDict(finalInput, \"input\"),\n });\n throw e;\n }\n await runManager?.handleChainEnd(finalOutput ?? {}, undefined, undefined, undefined, { inputs: _coerceToDict(finalInput, \"input\") });\n }\n getGraph(_) {\n const graph = new Graph();\n // TODO: Add input schema for runnables\n const inputNode = graph.addNode({\n name: `${this.getName()}Input`,\n schema: z.any(),\n });\n const runnableNode = graph.addNode(this);\n // TODO: Add output schemas for runnables\n const outputNode = graph.addNode({\n name: `${this.getName()}Output`,\n schema: z.any(),\n });\n graph.addEdge(inputNode, runnableNode);\n graph.addEdge(runnableNode, outputNode);\n return graph;\n }\n /**\n * Create a new runnable sequence that runs each individual runnable in series,\n * piping the output of one runnable into another runnable or runnable-like.\n * @param coerceable A runnable, function, or object whose values are functions or runnables.\n * @returns A new runnable sequence.\n */\n pipe(coerceable) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableSequence({\n first: this,\n last: _coerceToRunnable(coerceable),\n });\n }\n /**\n * Pick keys from the dict output of this runnable. Returns a new runnable.\n */\n pick(keys) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return this.pipe(new RunnablePick(keys));\n }\n /**\n * Assigns new fields to the dict output of this runnable. Returns a new runnable.\n */\n assign(mapping) {\n return this.pipe(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new RunnableAssign(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new RunnableMap({ steps: mapping })));\n }\n /**\n * Default implementation of transform, which buffers input and then calls stream.\n * Subclasses should override this method if they can start producing output while\n * input is still being generated.\n * @param generator\n * @param options\n */\n async *transform(generator, options) {\n let finalChunk;\n for await (const chunk of generator) {\n if (finalChunk === undefined) {\n finalChunk = chunk;\n }\n else {\n // Make a best effort to gather, for any type that supports concat.\n // This method should throw an error if gathering fails.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalChunk = concat(finalChunk, chunk);\n }\n }\n yield* this._streamIterator(finalChunk, ensureConfig(options));\n }\n /**\n * Stream all output from a runnable, as reported to the callback system.\n * This includes all inner runs of LLMs, Retrievers, Tools, etc.\n * Output is streamed as Log objects, which include a list of\n * jsonpatch ops that describe how the state of the run has changed in each\n * step, and the final state of the run.\n * The jsonpatch ops can be applied in order to construct state.\n * @param input\n * @param options\n * @param streamOptions\n */\n async *streamLog(input, options, streamOptions) {\n const logStreamCallbackHandler = new LogStreamCallbackHandler({\n ...streamOptions,\n autoClose: false,\n _schemaFormat: \"original\",\n });\n const config = ensureConfig(options);\n yield* this._streamLog(input, logStreamCallbackHandler, config);\n }\n async *_streamLog(input, logStreamCallbackHandler, config) {\n const { callbacks } = config;\n if (callbacks === undefined) {\n // eslint-disable-next-line no-param-reassign\n config.callbacks = [logStreamCallbackHandler];\n }\n else if (Array.isArray(callbacks)) {\n // eslint-disable-next-line no-param-reassign\n config.callbacks = callbacks.concat([logStreamCallbackHandler]);\n }\n else {\n const copiedCallbacks = callbacks.copy();\n copiedCallbacks.addHandler(logStreamCallbackHandler, true);\n // eslint-disable-next-line no-param-reassign\n config.callbacks = copiedCallbacks;\n }\n const runnableStreamPromise = this.stream(input, config);\n async function consumeRunnableStream() {\n try {\n const runnableStream = await runnableStreamPromise;\n for await (const chunk of runnableStream) {\n const patch = new RunLogPatch({\n ops: [\n {\n op: \"add\",\n path: \"/streamed_output/-\",\n value: chunk,\n },\n ],\n });\n await logStreamCallbackHandler.writer.write(patch);\n }\n }\n finally {\n await logStreamCallbackHandler.writer.close();\n }\n }\n const runnableStreamConsumePromise = consumeRunnableStream();\n try {\n for await (const log of logStreamCallbackHandler) {\n yield log;\n }\n }\n finally {\n await runnableStreamConsumePromise;\n }\n }\n streamEvents(input, options, streamOptions) {\n let stream;\n if (options.version === \"v1\") {\n stream = this._streamEventsV1(input, options, streamOptions);\n }\n else if (options.version === \"v2\") {\n stream = this._streamEventsV2(input, options, streamOptions);\n }\n else {\n throw new Error(`Only versions \"v1\" and \"v2\" of the schema are currently supported.`);\n }\n if (options.encoding === \"text/event-stream\") {\n return convertToHttpEventStream(stream);\n }\n else {\n return IterableReadableStream.fromAsyncGenerator(stream);\n }\n }\n async *_streamEventsV2(input, options, streamOptions) {\n const eventStreamer = new EventStreamCallbackHandler({\n ...streamOptions,\n autoClose: false,\n });\n const config = ensureConfig(options);\n const runId = config.runId ?? uuidv4();\n config.runId = runId;\n const callbacks = config.callbacks;\n if (callbacks === undefined) {\n config.callbacks = [eventStreamer];\n }\n else if (Array.isArray(callbacks)) {\n config.callbacks = callbacks.concat(eventStreamer);\n }\n else {\n const copiedCallbacks = callbacks.copy();\n copiedCallbacks.addHandler(eventStreamer, true);\n // eslint-disable-next-line no-param-reassign\n config.callbacks = copiedCallbacks;\n }\n // Call the runnable in streaming mode,\n // add each chunk to the output stream\n const outerThis = this;\n async function consumeRunnableStream() {\n try {\n const runnableStream = await outerThis.stream(input, config);\n const tappedStream = eventStreamer.tapOutputIterable(runId, runnableStream);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for await (const _ of tappedStream) {\n // Just iterate so that the callback handler picks up events\n }\n }\n finally {\n await eventStreamer.finish();\n }\n }\n const runnableStreamConsumePromise = consumeRunnableStream();\n let firstEventSent = false;\n let firstEventRunId;\n try {\n for await (const event of eventStreamer) {\n // This is a work-around an issue where the inputs into the\n // chain are not available until the entire input is consumed.\n // As a temporary solution, we'll modify the input to be the input\n // that was passed into the chain.\n if (!firstEventSent) {\n event.data.input = input;\n firstEventSent = true;\n firstEventRunId = event.run_id;\n yield event;\n continue;\n }\n if (event.run_id === firstEventRunId && event.event.endsWith(\"_end\")) {\n // If it's the end event corresponding to the root runnable\n // we dont include the input in the event since it's guaranteed\n // to be included in the first event.\n if (event.data?.input) {\n delete event.data.input;\n }\n }\n yield event;\n }\n }\n finally {\n await runnableStreamConsumePromise;\n }\n }\n async *_streamEventsV1(input, options, streamOptions) {\n let runLog;\n let hasEncounteredStartEvent = false;\n const config = ensureConfig(options);\n const rootTags = config.tags ?? [];\n const rootMetadata = config.metadata ?? {};\n const rootName = config.runName ?? this.getName();\n const logStreamCallbackHandler = new LogStreamCallbackHandler({\n ...streamOptions,\n autoClose: false,\n _schemaFormat: \"streaming_events\",\n });\n const rootEventFilter = new _RootEventFilter({\n ...streamOptions,\n });\n const logStream = this._streamLog(input, logStreamCallbackHandler, config);\n for await (const log of logStream) {\n if (!runLog) {\n runLog = RunLog.fromRunLogPatch(log);\n }\n else {\n runLog = runLog.concat(log);\n }\n if (runLog.state === undefined) {\n throw new Error(`Internal error: \"streamEvents\" state is missing. Please open a bug report.`);\n }\n // Yield the start event for the root runnable if it hasn't been seen.\n // The root run is never filtered out\n if (!hasEncounteredStartEvent) {\n hasEncounteredStartEvent = true;\n const state = { ...runLog.state };\n const event = {\n run_id: state.id,\n event: `on_${state.type}_start`,\n name: rootName,\n tags: rootTags,\n metadata: rootMetadata,\n data: {\n input,\n },\n };\n if (rootEventFilter.includeEvent(event, state.type)) {\n yield event;\n }\n }\n const paths = log.ops\n .filter((op) => op.path.startsWith(\"/logs/\"))\n .map((op) => op.path.split(\"/\")[2]);\n const dedupedPaths = [...new Set(paths)];\n for (const path of dedupedPaths) {\n let eventType;\n let data = {};\n const logEntry = runLog.state.logs[path];\n if (logEntry.end_time === undefined) {\n if (logEntry.streamed_output.length > 0) {\n eventType = \"stream\";\n }\n else {\n eventType = \"start\";\n }\n }\n else {\n eventType = \"end\";\n }\n if (eventType === \"start\") {\n // Include the inputs with the start event if they are available.\n // Usually they will NOT be available for components that operate\n // on streams, since those components stream the input and\n // don't know its final value until the end of the stream.\n if (logEntry.inputs !== undefined) {\n data.input = logEntry.inputs;\n }\n }\n else if (eventType === \"end\") {\n if (logEntry.inputs !== undefined) {\n data.input = logEntry.inputs;\n }\n data.output = logEntry.final_output;\n }\n else if (eventType === \"stream\") {\n const chunkCount = logEntry.streamed_output.length;\n if (chunkCount !== 1) {\n throw new Error(`Expected exactly one chunk of streamed output, got ${chunkCount} instead. Encountered in: \"${logEntry.name}\"`);\n }\n data = { chunk: logEntry.streamed_output[0] };\n // Clean up the stream, we don't need it anymore.\n // And this avoids duplicates as well!\n logEntry.streamed_output = [];\n }\n yield {\n event: `on_${logEntry.type}_${eventType}`,\n name: logEntry.name,\n run_id: logEntry.id,\n tags: logEntry.tags,\n metadata: logEntry.metadata,\n data,\n };\n }\n // Finally, we take care of the streaming output from the root chain\n // if there is any.\n const { state } = runLog;\n if (state.streamed_output.length > 0) {\n const chunkCount = state.streamed_output.length;\n if (chunkCount !== 1) {\n throw new Error(`Expected exactly one chunk of streamed output, got ${chunkCount} instead. Encountered in: \"${state.name}\"`);\n }\n const data = { chunk: state.streamed_output[0] };\n // Clean up the stream, we don't need it anymore.\n state.streamed_output = [];\n const event = {\n event: `on_${state.type}_stream`,\n run_id: state.id,\n tags: rootTags,\n metadata: rootMetadata,\n name: rootName,\n data,\n };\n if (rootEventFilter.includeEvent(event, state.type)) {\n yield event;\n }\n }\n }\n const state = runLog?.state;\n if (state !== undefined) {\n // Finally, yield the end event for the root runnable.\n const event = {\n event: `on_${state.type}_end`,\n name: rootName,\n run_id: state.id,\n tags: rootTags,\n metadata: rootMetadata,\n data: {\n output: state.final_output,\n },\n };\n if (rootEventFilter.includeEvent(event, state.type))\n yield event;\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static isRunnable(thing) {\n return isRunnableInterface(thing);\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({ onStart, onEnd, onError, }) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new RunnableBinding({\n bound: this,\n config: {},\n configFactories: [\n (config) => ({\n callbacks: [\n new RootListenersTracer({\n config,\n onStart,\n onEnd,\n onError,\n }),\n ],\n }),\n ],\n });\n }\n /**\n * Convert a runnable to a tool. Return a new instance of `RunnableToolLike`\n * which contains the runnable, name, description and schema.\n *\n * @template {T extends RunInput = RunInput} RunInput - The input type of the runnable. Should be the same as the `RunInput` type of the runnable.\n *\n * @param fields\n * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable.\n * @param {string | undefined} [fields.description] The description of the tool. Falls back to the description on the Zod schema if not provided, or undefined if neither are provided.\n * @param {z.ZodType<T>} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable.\n * @returns {RunnableToolLike<z.ZodType<T>, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool.\n */\n asTool(fields) {\n return convertRunnableToTool(this, fields);\n }\n}\n/**\n * A runnable that delegates calls to another runnable with a set of kwargs.\n * @example\n * ```typescript\n * import {\n * type RunnableConfig,\n * RunnableLambda,\n * } from \"@langchain/core/runnables\";\n *\n * const enhanceProfile = (\n * profile: Record<string, any>,\n * config?: RunnableConfig\n * ) => {\n * if (config?.configurable?.role) {\n * return { ...profile, role: config.configurable.role };\n * }\n * return profile;\n * };\n *\n * const runnable = RunnableLambda.from(enhanceProfile);\n *\n * // Bind configuration to the runnable to set the user's role dynamically\n * const adminRunnable = runnable.bind({ configurable: { role: \"Admin\" } });\n * const userRunnable = runnable.bind({ configurable: { role: \"User\" } });\n *\n * const result1 = await adminRunnable.invoke({\n * name: \"Alice\",\n * email: \"alice@example.com\"\n * });\n *\n * // { name: \"Alice\", email: \"alice@example.com\", role: \"Admin\" }\n *\n * const result2 = await userRunnable.invoke({\n * name: \"Bob\",\n * email: \"bob@example.com\"\n * });\n *\n * // { name: \"Bob\", email: \"bob@example.com\", role: \"User\" }\n * ```\n */\nexport class RunnableBinding extends Runnable {\n static lc_name() {\n return \"RunnableBinding\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"bound\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"config\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"kwargs\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"configFactories\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.bound = fields.bound;\n this.kwargs = fields.kwargs;\n this.config = fields.config;\n this.configFactories = fields.configFactories;\n }\n getName(suffix) {\n return this.bound.getName(suffix);\n }\n async _mergeConfig(...options) {\n const config = mergeConfigs(this.config, ...options);\n return mergeConfigs(config, ...(this.configFactories\n ? await Promise.all(this.configFactories.map(async (configFactory) => await configFactory(config)))\n : []));\n }\n bind(kwargs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound,\n kwargs: { ...this.kwargs, ...kwargs },\n config: this.config,\n });\n }\n withConfig(config) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound,\n kwargs: this.kwargs,\n config: { ...this.config, ...config },\n });\n }\n withRetry(fields) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new this.constructor({\n bound: this.bound.withRetry(fields),\n kwargs: this.kwargs,\n config: this.config,\n });\n }\n async invoke(input, options) {\n return this.bound.invoke(input, await this._mergeConfig(ensureConfig(options), this.kwargs));\n }\n async batch(inputs, options, batchOptions) {\n const mergedOptions = Array.isArray(options)\n ? await Promise.all(options.map(async (individualOption) => this._mergeConfig(ensureConfig(individualOption), this.kwargs)))\n : await this._mergeConfig(ensureConfig(options), this.kwargs);\n return this.bound.batch(inputs, mergedOptions, batchOptions);\n }\n async *_streamIterator(input, options) {\n yield* this.bound._streamIterator(input, await this._mergeConfig(ensureConfig(options), this.kwargs));\n }\n async stream(input, options) {\n return this.bound.stream(input, await this._mergeConfig(ensureConfig(options), this.kwargs));\n }\n async *transform(generator, options) {\n yield* this.bound.transform(generator, await this._mergeConfig(ensureConfig(options), this.kwargs));\n }\n streamEvents(input, options, streamOptions) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const outerThis = this;\n const generator = async function* () {\n yield* outerThis.bound.streamEvents(input, {\n ...(await outerThis._mergeConfig(ensureConfig(options), outerThis.kwargs)),\n version: options.version,\n }, streamOptions);\n };\n return IterableReadableStream.fromAsyncGenerator(generator());\n }\n static isRunnableBinding(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) {\n return thing.bound && Runnable.isRunnable(thing.bound);\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({ onStart, onEnd, onError, }) {\n return new RunnableBinding({\n bound: this.bound,\n kwargs: this.kwargs,\n config: this.config,\n configFactories: [\n (config) => ({\n callbacks: [\n new RootListenersTracer({\n config,\n onStart,\n onEnd,\n onError,\n }),\n ],\n }),\n ],\n });\n }\n}\n/**\n * A runnable that delegates calls to another runnable\n * with each element of the input sequence.\n * @example\n * ```typescript\n * import { RunnableEach, RunnableLambda } from \"@langchain/core/runnables\";\n *\n * const toUpperCase = (input: string): string => input.toUpperCase();\n * const addGreeting = (input: string): string => `Hello, ${input}!`;\n *\n * const upperCaseLambda = RunnableLambda.from(toUpperCase);\n * const greetingLambda = RunnableLambda.from(addGreeting);\n *\n * const chain = new RunnableEach({\n * bound: upperCaseLambda.pipe(greetingLambda),\n * });\n *\n * const result = await chain.invoke([\"alice\", \"bob\", \"carol\"])\n *\n * // [\"Hello, ALICE!\", \"Hello, BOB!\", \"Hello, CAROL!\"]\n * ```\n */\nexport class RunnableEach extends Runnable {\n static lc_name() {\n return \"RunnableEach\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"bound\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.bound = fields.bound;\n }\n /**\n * Binds the runnable with the specified arguments.\n * @param kwargs The arguments to bind the runnable with.\n * @returns A new instance of the `RunnableEach` class that is bound with the specified arguments.\n */\n bind(kwargs) {\n return new RunnableEach({\n bound: this.bound.bind(kwargs),\n });\n }\n /**\n * Invokes the runnable with the specified input and configuration.\n * @param input The input to invoke the runnable with.\n * @param config The configuration to invoke the runnable with.\n * @returns A promise that resolves to the output of the runnable.\n */\n async invoke(inputs, config) {\n return this._callWithConfig(this._invoke.bind(this), inputs, config);\n }\n /**\n * A helper method that is used to invoke the runnable with the specified input and configuration.\n * @param input The input to invoke the runnable with.\n * @param config The configuration to invoke the runnable with.\n * @returns A promise that resolves to the output of the runnable.\n */\n async _invoke(inputs, config, runManager) {\n return this.bound.batch(inputs, patchConfig(config, { callbacks: runManager?.getChild() }));\n }\n /**\n * Bind lifecycle listeners to a Runnable, returning a new Runnable.\n * The Run object contains information about the run, including its id,\n * type, input, output, error, startTime, endTime, and any tags or metadata\n * added to the run.\n *\n * @param {Object} params - The object containing the callback functions.\n * @param {(run: Run) => void} params.onStart - Called before the runnable starts running, with the Run object.\n * @param {(run: Run) => void} params.onEnd - Called after the runnable finishes running, with the Run object.\n * @param {(run: Run) => void} params.onError - Called if the runnable throws an error, with the Run object.\n */\n withListeners({ onStart, onEnd, onError, }) {\n return new RunnableEach({\n bound: this.bound.withListeners({ onStart, onEnd, onError }),\n });\n }\n}\n/**\n * Base class for runnables that can be retried a\n * specified number of times.\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableRetry,\n * } from \"@langchain/core/runnables\";\n *\n * // Simulate an API call that fails\n * const simulateApiCall = (input: string): string => {\n * console.log(`Attempting API call with input: ${input}`);\n * throw new Error(\"API call failed due to network issue\");\n * };\n *\n * const apiCallLambda = RunnableLambda.from(simulateApiCall);\n *\n * // Apply retry logic using the .withRetry() method\n * const apiCallWithRetry = apiCallLambda.withRetry({ stopAfterAttempt: 3 });\n *\n * // Alternatively, create a RunnableRetry instance manually\n * const manualRetry = new RunnableRetry({\n * bound: apiCallLambda,\n * maxAttemptNumber: 3,\n * config: {},\n * });\n *\n * // Example invocation using the .withRetry() method\n * const res = await apiCallWithRetry\n * .invoke(\"Request 1\")\n * .catch((error) => {\n * console.error(\"Failed after multiple retries:\", error.message);\n * });\n *\n * // Example invocation using the manual retry instance\n * const res2 = await manualRetry\n * .invoke(\"Request 2\")\n * .catch((error) => {\n * console.error(\"Failed after multiple retries:\", error.message);\n * });\n * ```\n */\nexport class RunnableRetry extends RunnableBinding {\n static lc_name() {\n return \"RunnableRetry\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"maxAttemptNumber\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 3\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"onFailedAttempt\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: () => { }\n });\n this.maxAttemptNumber = fields.maxAttemptNumber ?? this.maxAttemptNumber;\n this.onFailedAttempt = fields.onFailedAttempt ?? this.onFailedAttempt;\n }\n _patchConfigForRetry(attempt, config, runManager) {\n const tag = attempt > 1 ? `retry:attempt:${attempt}` : undefined;\n return patchConfig(config, { callbacks: runManager?.getChild(tag) });\n }\n async _invoke(input, config, runManager) {\n return pRetry((attemptNumber) => super.invoke(input, this._patchConfigForRetry(attemptNumber, config, runManager)), {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onFailedAttempt: (error) => this.onFailedAttempt(error, input),\n retries: Math.max(this.maxAttemptNumber - 1, 0),\n randomize: true,\n });\n }\n /**\n * Method that invokes the runnable with the specified input, run manager,\n * and config. It handles the retry logic by catching any errors and\n * recursively invoking itself with the updated config for the next retry\n * attempt.\n * @param input The input for the runnable.\n * @param runManager The run manager for the runnable.\n * @param config The config for the runnable.\n * @returns A promise that resolves to the output of the runnable.\n */\n async invoke(input, config) {\n return this._callWithConfig(this._invoke.bind(this), input, config);\n }\n async _batch(inputs, configs, runManagers, batchOptions) {\n const resultsMap = {};\n try {\n await pRetry(async (attemptNumber) => {\n const remainingIndexes = inputs\n .map((_, i) => i)\n .filter((i) => resultsMap[i.toString()] === undefined ||\n // eslint-disable-next-line no-instanceof/no-instanceof\n resultsMap[i.toString()] instanceof Error);\n const remainingInputs = remainingIndexes.map((i) => inputs[i]);\n const patchedConfigs = remainingIndexes.map((i) => this._patchConfigForRetry(attemptNumber, configs?.[i], runManagers?.[i]));\n const results = await super.batch(remainingInputs, patchedConfigs, {\n ...batchOptions,\n returnExceptions: true,\n });\n let firstException;\n for (let i = 0; i < results.length; i += 1) {\n const result = results[i];\n const resultMapIndex = remainingIndexes[i];\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (result instanceof Error) {\n if (firstException === undefined) {\n firstException = result;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstException.input = remainingInputs[i];\n }\n }\n resultsMap[resultMapIndex.toString()] = result;\n }\n if (firstException) {\n throw firstException;\n }\n return results;\n }, {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onFailedAttempt: (error) => this.onFailedAttempt(error, error.input),\n retries: Math.max(this.maxAttemptNumber - 1, 0),\n randomize: true,\n });\n }\n catch (e) {\n if (batchOptions?.returnExceptions !== true) {\n throw e;\n }\n }\n return Object.keys(resultsMap)\n .sort((a, b) => parseInt(a, 10) - parseInt(b, 10))\n .map((key) => resultsMap[parseInt(key, 10)]);\n }\n async batch(inputs, options, batchOptions) {\n return this._batchWithConfig(this._batch.bind(this), inputs, options, batchOptions);\n }\n}\n/**\n * A sequence of runnables, where the output of each is the input of the next.\n * @example\n * ```typescript\n * const promptTemplate = PromptTemplate.fromTemplate(\n * \"Tell me a joke about {topic}\",\n * );\n * const chain = RunnableSequence.from([promptTemplate, new ChatOpenAI({})]);\n * const result = await chain.invoke({ topic: \"bears\" });\n * ```\n */\nexport class RunnableSequence extends Runnable {\n static lc_name() {\n return \"RunnableSequence\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"first\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"middle\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: []\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"last\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"omitSequenceTags\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n this.first = fields.first;\n this.middle = fields.middle ?? this.middle;\n this.last = fields.last;\n this.name = fields.name;\n this.omitSequenceTags = fields.omitSequenceTags ?? this.omitSequenceTags;\n }\n get steps() {\n return [this.first, ...this.middle, this.last];\n }\n async invoke(input, options) {\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(config);\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, \"input\"), config.runId, undefined, undefined, undefined, config?.runName);\n delete config.runId;\n let nextStepInput = input;\n let finalOutput;\n try {\n const initialSteps = [this.first, ...this.middle];\n for (let i = 0; i < initialSteps.length; i += 1) {\n const step = initialSteps[i];\n const promise = step.invoke(nextStepInput, patchConfig(config, {\n callbacks: runManager?.getChild(this.omitSequenceTags ? undefined : `seq:step:${i + 1}`),\n }));\n nextStepInput = await raceWithSignal(promise, options?.signal);\n }\n // TypeScript can't detect that the last output of the sequence returns RunOutput, so call it out of the loop here\n if (options?.signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n finalOutput = await this.last.invoke(nextStepInput, patchConfig(config, {\n callbacks: runManager?.getChild(this.omitSequenceTags ? undefined : `seq:step:${this.steps.length}`),\n }));\n }\n catch (e) {\n await runManager?.handleChainError(e);\n throw e;\n }\n await runManager?.handleChainEnd(_coerceToDict(finalOutput, \"output\"));\n return finalOutput;\n }\n async batch(inputs, options, batchOptions) {\n const configList = this._getOptionsList(options ?? {}, inputs.length);\n const callbackManagers = await Promise.all(configList.map(getCallbackManagerForConfig));\n const runManagers = await Promise.all(callbackManagers.map(async (callbackManager, i) => {\n const handleStartRes = await callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(inputs[i], \"input\"), configList[i].runId, undefined, undefined, undefined, configList[i].runName);\n delete configList[i].runId;\n return handleStartRes;\n }));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let nextStepInputs = inputs;\n try {\n for (let i = 0; i < this.steps.length; i += 1) {\n const step = this.steps[i];\n const promise = step.batch(nextStepInputs, runManagers.map((runManager, j) => {\n const childRunManager = runManager?.getChild(this.omitSequenceTags ? undefined : `seq:step:${i + 1}`);\n return patchConfig(configList[j], { callbacks: childRunManager });\n }), batchOptions);\n nextStepInputs = await raceWithSignal(promise, configList[0]?.signal);\n }\n }\n catch (e) {\n await Promise.all(runManagers.map((runManager) => runManager?.handleChainError(e)));\n throw e;\n }\n await Promise.all(runManagers.map((runManager) => runManager?.handleChainEnd(_coerceToDict(nextStepInputs, \"output\"))));\n return nextStepInputs;\n }\n async *_streamIterator(input, options) {\n const callbackManager_ = await getCallbackManagerForConfig(options);\n const { runId, ...otherOptions } = options ?? {};\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherOptions?.runName);\n const steps = [this.first, ...this.middle, this.last];\n let concatSupported = true;\n let finalOutput;\n async function* inputGenerator() {\n yield input;\n }\n try {\n let finalGenerator = steps[0].transform(inputGenerator(), patchConfig(otherOptions, {\n callbacks: runManager?.getChild(this.omitSequenceTags ? undefined : `seq:step:1`),\n }));\n for (let i = 1; i < steps.length; i += 1) {\n const step = steps[i];\n finalGenerator = await step.transform(finalGenerator, patchConfig(otherOptions, {\n callbacks: runManager?.getChild(this.omitSequenceTags ? undefined : `seq:step:${i + 1}`),\n }));\n }\n for await (const chunk of finalGenerator) {\n options?.signal?.throwIfAborted();\n yield chunk;\n if (concatSupported) {\n if (finalOutput === undefined) {\n finalOutput = chunk;\n }\n else {\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n }\n catch (e) {\n finalOutput = undefined;\n concatSupported = false;\n }\n }\n }\n }\n }\n catch (e) {\n await runManager?.handleChainError(e);\n throw e;\n }\n await runManager?.handleChainEnd(_coerceToDict(finalOutput, \"output\"));\n }\n getGraph(config) {\n const graph = new Graph();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentLastNode = null;\n this.steps.forEach((step, index) => {\n const stepGraph = step.getGraph(config);\n if (index !== 0) {\n stepGraph.trimFirstNode();\n }\n if (index !== this.steps.length - 1) {\n stepGraph.trimLastNode();\n }\n graph.extend(stepGraph);\n const stepFirstNode = stepGraph.firstNode();\n if (!stepFirstNode) {\n throw new Error(`Runnable ${step} has no first node`);\n }\n if (currentLastNode) {\n graph.addEdge(currentLastNode, stepFirstNode);\n }\n currentLastNode = stepGraph.lastNode();\n });\n return graph;\n }\n pipe(coerceable) {\n if (RunnableSequence.isRunnableSequence(coerceable)) {\n return new RunnableSequence({\n first: this.first,\n middle: this.middle.concat([\n this.last,\n coerceable.first,\n ...coerceable.middle,\n ]),\n last: coerceable.last,\n name: this.name ?? coerceable.name,\n });\n }\n else {\n return new RunnableSequence({\n first: this.first,\n middle: [...this.middle, this.last],\n last: _coerceToRunnable(coerceable),\n name: this.name,\n });\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static isRunnableSequence(thing) {\n return Array.isArray(thing.middle) && Runnable.isRunnable(thing);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static from([first, ...runnables], nameOrFields) {\n let extra = {};\n if (typeof nameOrFields === \"string\") {\n extra.name = nameOrFields;\n }\n else if (nameOrFields !== undefined) {\n extra = nameOrFields;\n }\n return new RunnableSequence({\n ...extra,\n first: _coerceToRunnable(first),\n middle: runnables.slice(0, -1).map(_coerceToRunnable),\n last: _coerceToRunnable(runnables[runnables.length - 1]),\n });\n }\n}\n/**\n * A runnable that runs a mapping of runnables in parallel,\n * and returns a mapping of their outputs.\n * @example\n * ```typescript\n * const mapChain = RunnableMap.from({\n * joke: PromptTemplate.fromTemplate(\"Tell me a joke about {topic}\").pipe(\n * new ChatAnthropic({}),\n * ),\n * poem: PromptTemplate.fromTemplate(\"write a 2-line poem about {topic}\").pipe(\n * new ChatAnthropic({}),\n * ),\n * });\n * const result = await mapChain.invoke({ topic: \"bear\" });\n * ```\n */\nexport class RunnableMap extends Runnable {\n static lc_name() {\n return \"RunnableMap\";\n }\n getStepsKeys() {\n return Object.keys(this.steps);\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"steps\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.steps = {};\n for (const [key, value] of Object.entries(fields.steps)) {\n this.steps[key] = _coerceToRunnable(value);\n }\n }\n static from(steps) {\n return new RunnableMap({ steps });\n }\n async invoke(input, options) {\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(config);\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), {\n input,\n }, config.runId, undefined, undefined, undefined, config?.runName);\n delete config.runId;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const output = {};\n try {\n const promises = Object.entries(this.steps).map(async ([key, runnable]) => {\n output[key] = await runnable.invoke(input, patchConfig(config, {\n callbacks: runManager?.getChild(`map:key:${key}`),\n }));\n });\n await raceWithSignal(Promise.all(promises), options?.signal);\n }\n catch (e) {\n await runManager?.handleChainError(e);\n throw e;\n }\n await runManager?.handleChainEnd(output);\n return output;\n }\n async *_transform(generator, runManager, options) {\n // shallow copy steps to ignore changes while iterating\n const steps = { ...this.steps };\n // each step gets a copy of the input iterator\n const inputCopies = atee(generator, Object.keys(steps).length);\n // start the first iteration of each output iterator\n const tasks = new Map(Object.entries(steps).map(([key, runnable], i) => {\n const gen = runnable.transform(inputCopies[i], patchConfig(options, {\n callbacks: runManager?.getChild(`map:key:${key}`),\n }));\n return [key, gen.next().then((result) => ({ key, gen, result }))];\n }));\n // yield chunks as they become available,\n // starting new iterations as needed,\n // until all iterators are done\n while (tasks.size) {\n const promise = Promise.race(tasks.values());\n const { key, result, gen } = await raceWithSignal(promise, options?.signal);\n tasks.delete(key);\n if (!result.done) {\n yield { [key]: result.value };\n tasks.set(key, gen.next().then((result) => ({ key, gen, result })));\n }\n }\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n async stream(input, options) {\n async function* generator() {\n yield input;\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: this.transform(generator(), config),\n config,\n });\n await wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n }\n}\n/**\n * A runnable that wraps a traced LangSmith function.\n */\nexport class RunnableTraceable extends Runnable {\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: false\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"func\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n if (!isTraceableFunction(fields.func)) {\n throw new Error(\"RunnableTraceable requires a function that is wrapped in traceable higher-order function\");\n }\n this.func = fields.func;\n }\n async invoke(input, options) {\n const [config] = this._getOptionsList(options ?? {}, 1);\n const callbacks = await getCallbackManagerForConfig(config);\n const promise = this.func(patchConfig(config, { callbacks }), input);\n return raceWithSignal(promise, config?.signal);\n }\n async *_streamIterator(input, options) {\n const [config] = this._getOptionsList(options ?? {}, 1);\n const result = await this.invoke(input, options);\n if (isAsyncIterable(result)) {\n for await (const item of result) {\n config?.signal?.throwIfAborted();\n yield item;\n }\n return;\n }\n if (isIterator(result)) {\n while (true) {\n config?.signal?.throwIfAborted();\n const state = result.next();\n if (state.done)\n break;\n yield state.value;\n }\n return;\n }\n yield result;\n }\n static from(func) {\n return new RunnableTraceable({ func });\n }\n}\nfunction assertNonTraceableFunction(func) {\n if (isTraceableFunction(func)) {\n throw new Error(\"RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.\");\n }\n}\n/**\n * A runnable that wraps an arbitrary function that takes a single argument.\n * @example\n * ```typescript\n * import { RunnableLambda } from \"@langchain/core/runnables\";\n *\n * const add = (input: { x: number; y: number }) => input.x + input.y;\n *\n * const multiply = (input: { value: number; multiplier: number }) =>\n * input.value * input.multiplier;\n *\n * // Create runnables for the functions\n * const addLambda = RunnableLambda.from(add);\n * const multiplyLambda = RunnableLambda.from(multiply);\n *\n * // Chain the lambdas for a mathematical operation\n * const chainedLambda = addLambda.pipe((result) =>\n * multiplyLambda.invoke({ value: result, multiplier: 2 })\n * );\n *\n * // Example invocation of the chainedLambda\n * const result = await chainedLambda.invoke({ x: 2, y: 3 });\n *\n * // Will log \"10\" (since (2 + 3) * 2 = 10)\n * ```\n */\nexport class RunnableLambda extends Runnable {\n static lc_name() {\n return \"RunnableLambda\";\n }\n constructor(fields) {\n if (isTraceableFunction(fields.func)) {\n // eslint-disable-next-line no-constructor-return\n return RunnableTraceable.from(fields.func);\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"func\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n assertNonTraceableFunction(fields.func);\n this.func = fields.func;\n }\n static from(func) {\n return new RunnableLambda({\n func,\n });\n }\n async _invoke(input, config, runManager) {\n return new Promise((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n recursionLimit: (config?.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1,\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(childConfig, async () => {\n try {\n let output = await this.func(input, {\n ...childConfig,\n });\n if (output && Runnable.isRunnable(output)) {\n if (config?.recursionLimit === 0) {\n throw new Error(\"Recursion limit reached.\");\n }\n output = await output.invoke(input, {\n ...childConfig,\n recursionLimit: (childConfig.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1,\n });\n }\n else if (isAsyncIterable(output)) {\n let finalOutput;\n for await (const chunk of consumeAsyncIterableInContext(childConfig, output)) {\n config?.signal?.throwIfAborted();\n if (finalOutput === undefined) {\n finalOutput = chunk;\n }\n else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n }\n catch (e) {\n finalOutput = chunk;\n }\n }\n }\n output = finalOutput;\n }\n else if (isIterableIterator(output)) {\n let finalOutput;\n for (const chunk of consumeIteratorInContext(childConfig, output)) {\n config?.signal?.throwIfAborted();\n if (finalOutput === undefined) {\n finalOutput = chunk;\n }\n else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalOutput = concat(finalOutput, chunk);\n }\n catch (e) {\n finalOutput = chunk;\n }\n }\n }\n output = finalOutput;\n }\n resolve(output);\n }\n catch (e) {\n reject(e);\n }\n });\n });\n }\n async invoke(input, options) {\n return this._callWithConfig(this._invoke.bind(this), input, options);\n }\n async *_transform(generator, runManager, config) {\n let finalChunk;\n for await (const chunk of generator) {\n if (finalChunk === undefined) {\n finalChunk = chunk;\n }\n else {\n // Make a best effort to gather, for any type that supports concat.\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n finalChunk = concat(finalChunk, chunk);\n }\n catch (e) {\n finalChunk = chunk;\n }\n }\n }\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n recursionLimit: (config?.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1,\n });\n const output = await new Promise((resolve, reject) => {\n void AsyncLocalStorageProviderSingleton.runWithConfig(childConfig, async () => {\n try {\n const res = await this.func(finalChunk, {\n ...childConfig,\n config: childConfig,\n });\n resolve(res);\n }\n catch (e) {\n reject(e);\n }\n });\n });\n if (output && Runnable.isRunnable(output)) {\n if (config?.recursionLimit === 0) {\n throw new Error(\"Recursion limit reached.\");\n }\n const stream = await output.stream(finalChunk, childConfig);\n for await (const chunk of stream) {\n yield chunk;\n }\n }\n else if (isAsyncIterable(output)) {\n for await (const chunk of consumeAsyncIterableInContext(childConfig, output)) {\n config?.signal?.throwIfAborted();\n yield chunk;\n }\n }\n else if (isIterableIterator(output)) {\n for (const chunk of consumeIteratorInContext(childConfig, output)) {\n config?.signal?.throwIfAborted();\n yield chunk;\n }\n }\n else {\n yield output;\n }\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n async stream(input, options) {\n async function* generator() {\n yield input;\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: this.transform(generator(), config),\n config,\n });\n await wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n }\n}\n/**\n * A runnable that runs a mapping of runnables in parallel,\n * and returns a mapping of their outputs.\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableParallel,\n * } from \"@langchain/core/runnables\";\n *\n * const addYears = (age: number): number => age + 5;\n * const yearsToFifty = (age: number): number => 50 - age;\n * const yearsToHundred = (age: number): number => 100 - age;\n *\n * const addYearsLambda = RunnableLambda.from(addYears);\n * const milestoneFiftyLambda = RunnableLambda.from(yearsToFifty);\n * const milestoneHundredLambda = RunnableLambda.from(yearsToHundred);\n *\n * // Pipe will coerce objects into RunnableParallel by default, but we\n * // explicitly instantiate one here to demonstrate\n * const sequence = addYearsLambda.pipe(\n * RunnableParallel.from({\n * years_to_fifty: milestoneFiftyLambda,\n * years_to_hundred: milestoneHundredLambda,\n * })\n * );\n *\n * // Invoke the sequence with a single age input\n * const res = sequence.invoke(25);\n *\n * // { years_to_fifty: 25, years_to_hundred: 75 }\n * ```\n */\nexport class RunnableParallel extends RunnableMap {\n}\n/**\n * A Runnable that can fallback to other Runnables if it fails.\n * External APIs (e.g., APIs for a language model) may at times experience\n * degraded performance or even downtime.\n *\n * In these cases, it can be useful to have a fallback Runnable that can be\n * used in place of the original Runnable (e.g., fallback to another LLM provider).\n *\n * Fallbacks can be defined at the level of a single Runnable, or at the level\n * of a chain of Runnables. Fallbacks are tried in order until one succeeds or\n * all fail.\n *\n * While you can instantiate a `RunnableWithFallbacks` directly, it is usually\n * more convenient to use the `withFallbacks` method on an existing Runnable.\n *\n * When streaming, fallbacks will only be called on failures during the initial\n * stream creation. Errors that occur after a stream starts will not fallback\n * to the next Runnable.\n *\n * @example\n * ```typescript\n * import {\n * RunnableLambda,\n * RunnableWithFallbacks,\n * } from \"@langchain/core/runnables\";\n *\n * const primaryOperation = (input: string): string => {\n * if (input !== \"safe\") {\n * throw new Error(\"Primary operation failed due to unsafe input\");\n * }\n * return `Processed: ${input}`;\n * };\n *\n * // Define a fallback operation that processes the input differently\n * const fallbackOperation = (input: string): string =>\n * `Fallback processed: ${input}`;\n *\n * const primaryRunnable = RunnableLambda.from(primaryOperation);\n * const fallbackRunnable = RunnableLambda.from(fallbackOperation);\n *\n * // Apply the fallback logic using the .withFallbacks() method\n * const runnableWithFallback = primaryRunnable.withFallbacks([fallbackRunnable]);\n *\n * // Alternatively, create a RunnableWithFallbacks instance manually\n * const manualFallbackChain = new RunnableWithFallbacks({\n * runnable: primaryRunnable,\n * fallbacks: [fallbackRunnable],\n * });\n *\n * // Example invocation using .withFallbacks()\n * const res = await runnableWithFallback\n * .invoke(\"unsafe input\")\n * .catch((error) => {\n * console.error(\"Failed after all attempts:\", error.message);\n * });\n *\n * // \"Fallback processed: unsafe input\"\n *\n * // Example invocation using manual instantiation\n * const res = await manualFallbackChain\n * .invoke(\"safe\")\n * .catch((error) => {\n * console.error(\"Failed after all attempts:\", error.message);\n * });\n *\n * // \"Processed: safe\"\n * ```\n */\nexport class RunnableWithFallbacks extends Runnable {\n static lc_name() {\n return \"RunnableWithFallbacks\";\n }\n constructor(fields) {\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"runnable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"fallbacks\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.runnable = fields.runnable;\n this.fallbacks = fields.fallbacks;\n }\n *runnables() {\n yield this.runnable;\n for (const fallback of this.fallbacks) {\n yield fallback;\n }\n }\n async invoke(input, options) {\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(options);\n const { runId, ...otherConfigFields } = config;\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherConfigFields?.runName);\n let firstError;\n for (const runnable of this.runnables()) {\n config?.signal?.throwIfAborted();\n try {\n const output = await runnable.invoke(input, patchConfig(otherConfigFields, { callbacks: runManager?.getChild() }));\n await runManager?.handleChainEnd(_coerceToDict(output, \"output\"));\n return output;\n }\n catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (firstError === undefined) {\n throw new Error(\"No error stored at end of fallback.\");\n }\n await runManager?.handleChainError(firstError);\n throw firstError;\n }\n async *_streamIterator(input, options) {\n const config = ensureConfig(options);\n const callbackManager_ = await getCallbackManagerForConfig(options);\n const { runId, ...otherConfigFields } = config;\n const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, \"input\"), runId, undefined, undefined, undefined, otherConfigFields?.runName);\n let firstError;\n let stream;\n for (const runnable of this.runnables()) {\n config?.signal?.throwIfAborted();\n const childConfig = patchConfig(otherConfigFields, {\n callbacks: runManager?.getChild(),\n });\n try {\n stream = await runnable.stream(input, childConfig);\n break;\n }\n catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (stream === undefined) {\n const error = firstError ?? new Error(\"No error stored at end of fallback.\");\n await runManager?.handleChainError(error);\n throw error;\n }\n let output;\n try {\n for await (const chunk of stream) {\n yield chunk;\n try {\n output = output === undefined ? output : concat(output, chunk);\n }\n catch (e) {\n output = undefined;\n }\n }\n }\n catch (e) {\n await runManager?.handleChainError(e);\n throw e;\n }\n await runManager?.handleChainEnd(_coerceToDict(output, \"output\"));\n }\n async batch(inputs, options, batchOptions) {\n if (batchOptions?.returnExceptions) {\n throw new Error(\"Not implemented.\");\n }\n const configList = this._getOptionsList(options ?? {}, inputs.length);\n const callbackManagers = await Promise.all(configList.map((config) => getCallbackManagerForConfig(config)));\n const runManagers = await Promise.all(callbackManagers.map(async (callbackManager, i) => {\n const handleStartRes = await callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(inputs[i], \"input\"), configList[i].runId, undefined, undefined, undefined, configList[i].runName);\n delete configList[i].runId;\n return handleStartRes;\n }));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let firstError;\n for (const runnable of this.runnables()) {\n configList[0].signal?.throwIfAborted();\n try {\n const outputs = await runnable.batch(inputs, runManagers.map((runManager, j) => patchConfig(configList[j], {\n callbacks: runManager?.getChild(),\n })), batchOptions);\n await Promise.all(runManagers.map((runManager, i) => runManager?.handleChainEnd(_coerceToDict(outputs[i], \"output\"))));\n return outputs;\n }\n catch (e) {\n if (firstError === undefined) {\n firstError = e;\n }\n }\n }\n if (!firstError) {\n throw new Error(\"No error stored at end of fallbacks.\");\n }\n await Promise.all(runManagers.map((runManager) => runManager?.handleChainError(firstError)));\n throw firstError;\n }\n}\n// TODO: Figure out why the compiler needs help eliminating Error as a RunOutput type\nexport function _coerceToRunnable(coerceable) {\n if (typeof coerceable === \"function\") {\n return new RunnableLambda({ func: coerceable });\n }\n else if (Runnable.isRunnable(coerceable)) {\n return coerceable;\n }\n else if (!Array.isArray(coerceable) && typeof coerceable === \"object\") {\n const runnables = {};\n for (const [key, value] of Object.entries(coerceable)) {\n runnables[key] = _coerceToRunnable(value);\n }\n return new RunnableMap({\n steps: runnables,\n });\n }\n else {\n throw new Error(`Expected a Runnable, function or object.\\nInstead got an unsupported type.`);\n }\n}\n/**\n * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.\n * @example\n * ```typescript\n * import {\n * RunnableAssign,\n * RunnableLambda,\n * RunnableParallel,\n * } from \"@langchain/core/runnables\";\n *\n * const calculateAge = (x: { birthYear: number }): { age: number } => {\n * const currentYear = new Date().getFullYear();\n * return { age: currentYear - x.birthYear };\n * };\n *\n * const createGreeting = (x: { name: string }): { greeting: string } => {\n * return { greeting: `Hello, ${x.name}!` };\n * };\n *\n * const mapper = RunnableParallel.from({\n * age_step: RunnableLambda.from(calculateAge),\n * greeting_step: RunnableLambda.from(createGreeting),\n * });\n *\n * const runnableAssign = new RunnableAssign({ mapper });\n *\n * const res = await runnableAssign.invoke({ name: \"Alice\", birthYear: 1990 });\n *\n * // { name: \"Alice\", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: \"Hello, Alice!\" } }\n * ```\n */\nexport class RunnableAssign extends Runnable {\n static lc_name() {\n return \"RunnableAssign\";\n }\n constructor(fields) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (fields instanceof RunnableMap) {\n // eslint-disable-next-line no-param-reassign\n fields = { mapper: fields };\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"mapper\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.mapper = fields.mapper;\n }\n async invoke(input, options) {\n const mapperResult = await this.mapper.invoke(input, options);\n return {\n ...input,\n ...mapperResult,\n };\n }\n async *_transform(generator, runManager, options) {\n // collect mapper keys\n const mapperKeys = this.mapper.getStepsKeys();\n // create two input gens, one for the mapper, one for the input\n const [forPassthrough, forMapper] = atee(generator);\n // create mapper output gen\n const mapperOutput = this.mapper.transform(forMapper, patchConfig(options, { callbacks: runManager?.getChild() }));\n // start the mapper\n const firstMapperChunkPromise = mapperOutput.next();\n // yield the passthrough\n for await (const chunk of forPassthrough) {\n if (typeof chunk !== \"object\" || Array.isArray(chunk)) {\n throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof chunk}`);\n }\n const filtered = Object.fromEntries(Object.entries(chunk).filter(([key]) => !mapperKeys.includes(key)));\n if (Object.keys(filtered).length > 0) {\n yield filtered;\n }\n }\n // yield the mapper output\n yield (await firstMapperChunkPromise).value;\n for await (const chunk of mapperOutput) {\n yield chunk;\n }\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n async stream(input, options) {\n async function* generator() {\n yield input;\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: this.transform(generator(), config),\n config,\n });\n await wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n }\n}\n/**\n * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.\n * Useful for streaming, can be automatically created and chained by calling `runnable.pick();`.\n * @example\n * ```typescript\n * import { RunnablePick } from \"@langchain/core/runnables\";\n *\n * const inputData = {\n * name: \"John\",\n * age: 30,\n * city: \"New York\",\n * country: \"USA\",\n * email: \"john.doe@example.com\",\n * phone: \"+1234567890\",\n * };\n *\n * const basicInfoRunnable = new RunnablePick([\"name\", \"city\"]);\n *\n * // Example invocation\n * const res = await basicInfoRunnable.invoke(inputData);\n *\n * // { name: 'John', city: 'New York' }\n * ```\n */\nexport class RunnablePick extends Runnable {\n static lc_name() {\n return \"RunnablePick\";\n }\n constructor(fields) {\n if (typeof fields === \"string\" || Array.isArray(fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = { keys: fields };\n }\n super(fields);\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"runnables\"]\n });\n Object.defineProperty(this, \"lc_serializable\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: true\n });\n Object.defineProperty(this, \"keys\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.keys = fields.keys;\n }\n async _pick(input) {\n if (typeof this.keys === \"string\") {\n return input[this.keys];\n }\n else {\n const picked = this.keys\n .map((key) => [key, input[key]])\n .filter((v) => v[1] !== undefined);\n return picked.length === 0 ? undefined : Object.fromEntries(picked);\n }\n }\n async invoke(input, options) {\n return this._callWithConfig(this._pick.bind(this), input, options);\n }\n async *_transform(generator) {\n for await (const chunk of generator) {\n const picked = await this._pick(chunk);\n if (picked !== undefined) {\n yield picked;\n }\n }\n }\n transform(generator, options) {\n return this._transformStreamWithConfig(generator, this._transform.bind(this), options);\n }\n async stream(input, options) {\n async function* generator() {\n yield input;\n }\n const config = ensureConfig(options);\n const wrappedGenerator = new AsyncGeneratorWithSetup({\n generator: this.transform(generator(), config),\n config,\n });\n await wrappedGenerator.setup;\n return IterableReadableStream.fromAsyncGenerator(wrappedGenerator);\n }\n}\nexport class RunnableToolLike extends RunnableBinding {\n constructor(fields) {\n const sequence = RunnableSequence.from([\n RunnableLambda.from(async (input) => {\n let toolInput;\n if (_isToolCall(input)) {\n try {\n toolInput = await this.schema.parseAsync(input.args);\n }\n catch (e) {\n throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(input.args));\n }\n }\n else {\n toolInput = input;\n }\n return toolInput;\n }).withConfig({ runName: `${fields.name}:parse_input` }),\n fields.bound,\n ]).withConfig({ runName: fields.name });\n super({\n bound: sequence,\n config: fields.config ?? {},\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"description\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"schema\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = fields.name;\n this.description = fields.description;\n this.schema = fields.schema;\n }\n static lc_name() {\n return \"RunnableToolLike\";\n }\n}\n/**\n * Given a runnable and a Zod schema, convert the runnable to a tool.\n *\n * @template RunInput The input type for the runnable.\n * @template RunOutput The output type for the runnable.\n *\n * @param {Runnable<RunInput, RunOutput>} runnable The runnable to convert to a tool.\n * @param fields\n * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable.\n * @param {string | undefined} [fields.description] The description of the tool. Falls back to the description on the Zod schema if not provided, or undefined if neither are provided.\n * @param {z.ZodType<RunInput>} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable.\n * @returns {RunnableToolLike<z.ZodType<RunInput>, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool.\n */\nexport function convertRunnableToTool(runnable, fields) {\n const name = fields.name ?? runnable.getName();\n const description = fields.description ?? fields.schema?.description;\n if (fields.schema.constructor === z.ZodString) {\n return new RunnableToolLike({\n name,\n description,\n schema: z\n .object({\n input: z.string(),\n })\n .transform((input) => input.input),\n bound: runnable,\n });\n }\n return new RunnableToolLike({\n name,\n description,\n schema: fields.schema,\n bound: runnable,\n });\n}\n"],"mappings":";;;;;AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,OAAOC,MAAM,MAAM,SAAS;AAC5B,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,mBAAmB,QAAS,gCAAgC;AACrE,SAASC,wBAAwB,EAAEC,MAAM,EAAEC,WAAW,EAAEC,kBAAkB,QAAS,0BA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