Langchain-Chatchat
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全部输出的内容?
To address the issue where callback.aiter()
in knowledge_base_chat.py
sometimes only outputs a few characters before restarting, consider the following steps:
-
Check Asynchronous Handling: Ensure the asynchronous iteration over
callback.aiter()
waits for the full output. This might involve verifying the implementation ofAsyncIteratorCallbackHandler
and how it emits data. -
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. -
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.
-
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
- 我发现一个bug,我使用的是azure-api运行,我向知识库提问一个简单问题,使用的是stream流式请求,知识库的knowledge_base_chat.py文件的callback.aiter()有时只输出了一个字或者两个字然后又开始重新请求了,但是langchain-chatchat0.2.10中的azure.py文件每次请求都有全部答案输出,这个是什么原因导致的,如何修改knowledge_base_chat.py文件使其保证能够请求一次就能获取到azure-api全部输出的内容?
- 我发现一个问题,我使用的是azure-api,运行后没问题,就是我向知识库提问一个简单问题,langchain-chatchat0.2.10中的azure.py文件都有正确输出并且全部答案输出,但是知识库的knowledge_base_chat.py有时只输出了一个字或者两个字然后又开始重新请求了,导致知识库的api总是接受不到文字过来,这个怎么调呢,我个人觉得有可能是azure-api返回太快了,导致knowledge_base_chat.py中的callback.aiter()没得到完整的句子,想问一下是什么原因呢,该如何解决?
- 调用azure-api时使用llm对话正常没问题,但是使用知识库问答时会报错,请问有什么原因以及如何修改
- server/chat/knowledge_base_chat.py
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.
底层请求的post加了"stream":true参数,本身就是会每个token去请求一次的,这个不是bug,是流式的调用方式
我也遇到了,API流式输出,接口只显示几个字