Skip to content

Commit 5ba7cc4

Browse files
committed
Fix nested __run properties, the outer one should override the inner one
1 parent 7e21a62 commit 5ba7cc4

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

langchain/src/chains/base.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ export abstract class BaseChain extends BaseLangChain implements ChainInputs {
5858
input: any,
5959
callbacks?: Callbacks
6060
): Promise<string> {
61-
const isKeylessInput = this.inputKeys.length === 1;
61+
const isKeylessInput = this.inputKeys.length <= 1;
6262
if (!isKeylessInput) {
6363
throw new Error(
6464
`Chain ${this._chainType()} expects multiple inputs, cannot use 'run' `
6565
);
6666
}
67-
const values = { [this.inputKeys[0]]: input };
67+
const values = this.inputKeys.length ? { [this.inputKeys[0]]: input } : {};
6868
const returnValues = await this.call(values, callbacks);
6969
const keys = Object.keys(returnValues);
7070

@@ -112,6 +112,7 @@ export abstract class BaseChain extends BaseLangChain implements ChainInputs {
112112
// add the runManager's currentRunId to the outputValues
113113
Object.defineProperty(outputValues, RUN_KEY, {
114114
value: runManager ? { runId: runManager?.runId } : undefined,
115+
configurable: true,
115116
});
116117
return outputValues;
117118
}

langchain/src/chat_models/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export abstract class BaseChatModel extends BaseLanguageModel {
8383
await runManager?.handleLLMEnd(output);
8484
Object.defineProperty(output, RUN_KEY, {
8585
value: runManager ? { runId: runManager?.runId } : undefined,
86+
configurable: true,
8687
});
8788
return output;
8889
}

langchain/src/llms/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export abstract class BaseLLM extends BaseLanguageModel {
101101
// it isnt included when listing the keys of the output object.
102102
Object.defineProperty(output, RUN_KEY, {
103103
value: runManager ? { runId: runManager?.runId } : undefined,
104+
configurable: true,
104105
});
105106
return output;
106107
}

0 commit comments

Comments
 (0)