Open Stadly opened 2 weeks ago
The issue you're experiencing with the on_chain_end
event containing concatenated intermediary tokens instead of the final assembled output seems to be related to how the streaming and event handling are implemented in LangChain.js. The on_chain_end
event is supposed to capture only the final output after all intermediary processing steps are completed [1][2].
To address this, you might want to ensure that the event handling logic correctly accumulates and processes the streamed tokens before emitting the on_chain_end
event. This involves using a mechanism to buffer the tokens and assemble them into the final output before triggering the end event. The current behavior suggests that the tokens are being concatenated without proper handling of the final assembly.
If this is indeed a bug in the library, it might require a fix in the event handling logic to ensure that only the final, correctly assembled output is included in the on_chain_end
event.
To continue talking to Dosu, mention @dosu.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
The
end
event is a concatenation of all the intermediary messages, and not just the final result. If, for example, these are the streamed tokens:Why
was
the
, theend
event containsWhyWhy wasWhy was the
instead ofWhy was the
.System Info