We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
流式输出末尾不完整
2024-09-24 10:40:59,532 [DEBUG] [OpenAIVision.py:160] [{'role': 'user', 'content': 'hi'}] 2024-09-24 10:41:00,515 [INFO] [base_model.py:703] 回答为:Hello! ... . How can I assis
末尾 assis 被截断。
assis
我手动在OpenAIVisionClient._decode_chat_response() #L238 添加了 log: logging.warning(f"***** {chunk['choices'][0]}")
OpenAIVisionClient._decode_chat_response()
logging.warning(f"***** {chunk['choices'][0]}")
2024-09-24 10:41:00,432 [DEBUG] [OpenAIVision.py:246] ***** {'index': 0, 'delta': {'content': 'How '}, 'finish_reason': None} 2024-09-24 10:41:00,448 [DEBUG] [OpenAIVision.py:246] ***** {'index': 0, 'delta': {'content': 'can '}, 'finish_reason': None} 2024-09-24 10:41:00,469 [DEBUG] [OpenAIVision.py:246] ***** {'index': 0, 'delta': {'content': 'I assi'}, 'finish_reason': None} 2024-09-24 10:41:00,482 [DEBUG] [OpenAIVision.py:246] ***** {'index': 0, 'delta': {'content': 's'}, 'finish_reason': None} 2024-09-24 10:41:00,515 [DEBUG] [OpenAIVision.py:246] ***** {'index': 0, 'delta': {'content': 't you today?'}, 'finish_reason': 'stop'}
可见,最后一条(包含 'finish_reason': 'stop' 的一条)response 的 delta.content 丢失了。
虽然 OpenAI 官方API中可能不会遇到此问题,但是建议可以考虑此情况,加强对 API 的兼容性
我暂时的解决方法,在 OpenAIVision.py#L251 添加判断,如果有 content:
if finish_reason == "stop": if ("content" in chunk["choices"][0]["delta"] and chunk["choices"][0]["delta"]["content"] is not None): yield chunk["choices"][0]["delta"]["content"]
No response
The text was updated successfully, but these errors were encountered:
我也有类似的问题
Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response Oct 21 22:23:33 python[493862]: finish_reason = chunk["finish_details"] Oct 21 22:23:33 python[493862]: ~~~~~^^^^^^^^^^^^^^^^^^ Oct 21 22:23:33 python[493862]: KeyError: 'finish_details' Oct 21 22:23:33 python[493862]: Traceback (most recent call last): Oct 21 22:23:33 python[493862]: File "/media/mydata/ChuanhuChatGPT/modules/models/OpenAIVision.py", line 250, in _decode_chat_response
Sorry, something went wrong.
No branches or pull requests
这个bug是否已存在现有issue了?
错误表现
Bug现象
流式输出末尾不完整
控制台log
末尾
assis
被截断。流式 response 内容
我手动在
OpenAIVisionClient._decode_chat_response()
#L238 添加了 log:logging.warning(f"***** {chunk['choices'][0]}")
可见,最后一条(包含 'finish_reason': 'stop' 的一条)response 的 delta.content 丢失了。
虽然 OpenAI 官方API中可能不会遇到此问题,但是建议可以考虑此情况,加强对 API 的兼容性
解决办法
我暂时的解决方法,在 OpenAIVision.py#L251 添加判断,如果有 content:
复现操作
错误日志
No response
运行环境
帮助解决
补充说明
No response
The text was updated successfully, but these errors were encountered: