KenyonY/openai-forward

流式日志保存失败

CGRgiser opened this issue · 11 comments

较长的流式回答会出现错误

` File "\openai-forward1\openai_forward\content\chat.py", line 27, in parse_chat_completions
line0 = txt_lines[0]
└ []

IndexError: list index out of range

可能是网络原因,请问结果可以复现吗?

感谢你的回复
这个问题一直存在,尤其是长度较长的回答,会一直出现这个错误,日志记录问题时正常,记录回答时会报错。
我是直接拉的代码启动的。
2023-08-02 13:21:14.696 | DEBUG | openai_forward.base:aiter_bytes:69 - log chat (not) error:
e=IndexError('list index out of range')

我测试了几条较长的回复,暂时没有发现日志记录出错。你的出错用例可以提供到这里吗?
以及确认一下:当日志解析出错时,流式回复是正常吗

curl 'http://localhost:8000/v1/chat/completions' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Origin: https://chat-gpt-next-web-sand-seven-39.vercel.app' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: cross-site' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' \ -H 'accept: text/event-stream' \ -H 'x-requested-with: XMLHttpRequest' \ --data-raw '{"messages":[{"role":"user","content":"可以介绍一下常见的网络错误原因吗"}],"stream":true,"model":"gpt-3.5-turbo","temperature":0.5,"presence_penalty":0,"frequency_penalty":0,"top_p":1}' \ --compressed

上面这个是发的请求,流式回复是正常的,

2023-08-02 15:13:06.740 | DEBUG | openai_forward.content.chat:add_chat:87 - {'messages': [{'user': '可以介绍一下常见的网络错误原因吗,给出20条原因'}], 'model': 'gpt-3.5-turbo', 'forwarded-for': '', 'uid': 'f5eddc76-675c-4910-9b
5a-4447303a11f7', 'datetime': '2023-08-02 15:13:06'}
2023-08-02 15:13:14.596 | INFO | starlette.responses:stream_response:255 - 127.0.0.1:52006 - "POST /v1/chat/completions HTTP/1.1" 200
2023-08-02 15:13:43.389 | DEBUG | openai_forward.base:aiter_bytes:69 - log chat (not) error:
e=JSONDecodeError('unexpected content after document: line 1 column 294 (char 293)')

这个是报错原因

使用你的问句: “可以介绍一下常见的网络错误原因吗,给出20条原因”
我这里还是没有复现出这个错误。 如果其他人也有碰到类似的问题,同样可以反馈到这里。

@CGRgiser 可以尝试升级到v0.4.0以上版本,看问题是否已被修复

Bot detected the issue body's language is not English, translate it automatically.


@CGRgiser can try to upgrade to 0.4.0 version to see if the problem has been fixed

这个issue已过时,如果还有类似的问题请新开issue,现将其关闭

Bot detected the issue body's language is not English, translate it automatically.


This issue is outdated, if there are similar issues, please open a new issue, it will be closed now

感谢!,升级版本后问题得到解决

Bot detected the issue body's language is not English, translate it automatically.


grateful! , the problem is solved after upgrading the version