Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

我发现一个bug,我使用的是azure-api运行,我向知识库提问一个简单问题,使用的是stream流式请求,知识库的knowledge_base_chat.py文件的callback.aiter()有时只输出了一个字或者两个字然后又开始重新请求了,但是langchain-chatchat0.2.10中的azure.py文件每次请求都有全部答案输出,这个是什么原因导致的,如何修改knowledge_base_chat.py文件使其保证能够请求一次就能获取到azure-api全部输出的内容?

Open liaoqingjian opened this issue 10 months ago • 2 comments

liaoqingjian avatar Apr 15 '24 09:04 liaoqingjian

To address the issue where callback.aiter() in knowledge_base_chat.py sometimes only outputs a few characters before restarting, consider the following steps:

  1. Check Asynchronous Handling: Ensure the asynchronous iteration over callback.aiter() waits for the full output. This might involve verifying the implementation of AsyncIteratorCallbackHandler and how it emits data.

  2. Model Configuration: Investigate if there's a way to adjust the model or langchain-chatchat configuration to change the response behavior from character-by-character to full output.

  3. Implement Buffering Strategy: You might need to buffer the output until a certain condition is met (like a specific output size or delimiter) before yielding it as a response.

  4. Debugging: Add logging around the async for token in callback.aiter(): loop to understand the pattern of the received chunks. This can help identify if the issue is with data generation or iteration.

These steps are based on the assumption that the issue lies in how asynchronous iteration is handled or how the model is configured to generate output. If these approaches do not resolve the issue, further investigation into the AsyncIteratorCallbackHandler and the langchain-chatchat library might be necessary to find a more specific solution.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

dosubot[bot] avatar Apr 15 '24 09:04 dosubot[bot]

底层请求的post加了"stream":true参数,本身就是会每个token去请求一次的,这个不是bug,是流式的调用方式

Vincent-ch99 avatar Apr 26 '24 09:04 Vincent-ch99

我也遇到了,API流式输出,接口只显示几个字

chelun86 avatar May 06 '24 05:05 chelun86