From b60540679170713ca91b3d04c6f6bb1a524b81dd Mon Sep 17 00:00:00 2001 From: Noah Cristino Date: Sat, 30 Nov 2024 10:48:09 -0500 Subject: [PATCH] Move concatSupported to RunnableConfig and handle when it is false --- langchain-core/src/runnables/base.ts | 4 +++- langchain-core/src/runnables/types.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 1cab402513ec..f6c6a387585d 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -1989,7 +1989,7 @@ export class RunnableSequence< otherOptions?.runName ); const steps = [this.first, ...this.middle, this.last]; - let concatSupported = true; + let concatSupported = options?.concatSupported ?? true; let finalOutput; async function* inputGenerator() { yield input; @@ -2029,6 +2029,8 @@ export class RunnableSequence< concatSupported = false; } } + } else { + finalOutput = chunk; } } } catch (e) { diff --git a/langchain-core/src/runnables/types.ts b/langchain-core/src/runnables/types.ts index f40d80ee3831..499c5d046f28 100644 --- a/langchain-core/src/runnables/types.ts +++ b/langchain-core/src/runnables/types.ts @@ -107,4 +107,9 @@ export interface RunnableConfig< * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal */ signal?: AbortSignal; + + /** + * Whether to concatenate the stream of outputs into a single output or not. + */ + concatSupported?: boolean; }