binary-husky / binary-husky/gpt_academic
[Bug]: [Local Message] 异常,Json解析异常
- Dominant language
- Python
- Stars
- 71.3k
- Forks
- 8.3k
- PR merge metrics
- No merged PRs in 30d
Description
### Installation Method | 安装方法与平台
Docker-Compose(Linux)
### Version | 版本
Latest | 最新版
### OS | 操作系统
Docker
### Describe the bug | 简述
使用“学术语料润色”时报错,显示“[Local Message] 异常”,具体表现应该为Json解析异常。如下:
[Local Message] 异常
Traceback (most recent call last):
File "./request_llms/bridge_chatgpt.py", line 339, in predict
if ('data: [DONE]' in chunk_decoded) or (len(chunkjson['choices'][0]["delta"]) == 0):
KeyError: 'delta'
data: {"choices":[{"content_filter_offsets":{"check_offset":3656,"start_offset":3656,"end_offset":4651},"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":null,"index":0}],"created":0,"id":"","model":"","object":""}data: {"choices":[{"delta":{"content":" solve"},"finish_reason":null,"index":0,"logprobs":null}],"created":1728877146,"id":"chatcmpl-AI6DCuO6n6kLm5NgOPcVUOTmce7XA","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_67802d9a6d"}data: {"choices":[{"delta":{"content":" it"},"finish_reason":null,"index":0,"logprobs":null}],"created":1728877146,"id":"chatcmpl-AI6DCuO6n6kLm5NgOPcVUOTmce7XA","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_67802d9a6d"}data: {"choices":[{"delta":{"content":" as"},"finish_reason":null,"index":0,"logprobs":null}],
...
"created":1728877146,"id":"chatcmpl-AI6DCuO6n6kLm5NgOPcVUOTmce7XA","model":"gpt-4o-2024-05-13","object":"chat.completion.chunk","system_fingerprint":"fp_67802d9a6d"}data: {"choices":[{"content_filter_offsets":{"check_offset":8258,"start_offset":8168,"end_offset":8588},"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":null,"index":0}],"created":0,"id":"","model":"","object":""}data: [DONE]
### Screen Shot | 有帮助的截图

### Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in request_llms/bridge_chatgpt.py around predict at line 339 and inspect the streamed chunks shown in the traceback, especially those whose choices entry has content_filter fields but no delta. Reproduce the academic-polishing request with Docker Compose and verify that these response chunks no longer raise a KeyError and that streaming completes normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100