Closed abdalrohman closed 3 months ago
Thanks @abdalrohman. Updated this to use data.response.text
for messages with tool calls (integration tests maintain len(content) > 0 for streaming tool calls).
It looks like this behavior was introduced in https://github.com/langchain-ai/langchain-cohere/pull/53. I don't have all the context on multi-hop tool calls but will merge this as the fix seems preferable to current streaming behavior.
Tagging @Anirudh31415926535 and @harry-cohere to take a look.
This patch addresses a critical issue where the
ChatCohere
stream method was generating duplicate outputs. When attempting to stream responses using theChatCohere
class, users experienced repeated segments in the output stream, as demonstrated below:The issue resulted in fragmented and repeated responses, such as:
This was particularly problematic in the line:
Resolution: The root cause was identified in the
chat_model.py
file within the_stream
and_astream
functions. Thecontent
field was incorrectly populated withdata.response.text
, leading to the duplication. The corrected code snippet is as follows:By removing
data.response.text
from thecontent
field, the stream now generates clean, non-repetitive outputs:This update ensures that the
ChatCohere
stream function operates as intended, providing users with a seamless and error-free experience.