Skip to content

Commit

Permalink
fix no param reassign
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Apr 5, 2024
1 parent cbae992 commit a5243e9
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions langchain-core/src/runnables/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1587,17 +1587,16 @@ export class RunnableSequence<
options?: RunnableConfig
): AsyncGenerator<RunOutput> {
const callbackManager_ = await getCallbackManagerForConfig(options);
const { runId, ...otherOptions } = options ?? {};
const runManager = await callbackManager_?.handleChainStart(
this.toJSON(),
_coerceToDict(input, "input"),
options?.runId,
runId,
undefined,
undefined,
undefined,
options?.runName
otherOptions?.runName
);
// eslint-disable-next-line no-param-reassign
delete options?.runId;
const steps = [this.first, ...this.middle, this.last];
let concatSupported = true;
let finalOutput;
Expand All @@ -1607,15 +1606,15 @@ export class RunnableSequence<
try {
let finalGenerator = steps[0].transform(
inputGenerator(),
patchConfig(options, {
patchConfig(otherOptions, {
callbacks: runManager?.getChild(`seq:step:1`),
})
);
for (let i = 1; i < steps.length; i += 1) {
const step = steps[i];
finalGenerator = await step.transform(
finalGenerator,
patchConfig(options, {
patchConfig(otherOptions, {
callbacks: runManager?.getChild(`seq:step:${i + 1}`),
})
);
Expand Down Expand Up @@ -2088,23 +2087,22 @@ export class RunnableWithFallbacks<RunInput, RunOutput> extends Runnable<
undefined,
options?.metadata
);
const { runId, ...otherOptions } = options ?? {};
const runManager = await callbackManager_?.handleChainStart(
this.toJSON(),
_coerceToDict(input, "input"),
options?.runId,
runId,
undefined,
undefined,
undefined,
options?.runName
otherOptions?.runName
);
// eslint-disable-next-line no-param-reassign
delete options?.runId;
let firstError;
for (const runnable of this.runnables()) {
try {
const output = await runnable.invoke(
input,
patchConfig(options, { callbacks: runManager?.getChild() })
patchConfig(otherOptions, { callbacks: runManager?.getChild() })
);
await runManager?.handleChainEnd(_coerceToDict(output, "output"));
return output;
Expand Down

0 comments on commit a5243e9

Please sign in to comment.