chatbox
chatbox copied to clipboard
json错误
目前解析回答经常有json错误。
API Request Failed:
Error parsing item: {"id":"chatcmpl-6sPxZa. Error Details: SyntaxError: Unterminated string in JSON at position 22
哪个版本?
0.0.7 持续出现这个错误.
@gejian-iscas 可以提供更多的报错信息吗?这样我才能定位和修复问题
下面是报错信息:
API Request Failed:
Error parsing item: {"id":"chatcmpl-6sljQvTOaqFuB0nU5iIk9QTGonrpq","object":"chat.completion.chunk","created":1678511212,"model":"gpt-3.5-turb. Error Details: SyntaxError: Unterminated string in JSON at position 122
不定时出现,可能在生成了一段文本后报错.
版本0.0.8同样出现类似问题 Error parsing item: {"id":"chatcmpl-6tGQhcr1OLVIgXn8ZcwGN5FAh4eOI","object":"chat.completion.chunk","created":1678629215,"model":"gpt-3.5-turbo-0. Error Details: SyntaxError: Unterminated string in JSON at position 125
纯中文的回答或者纯英文的回答没有类似问题,中文英文混杂的答案会有类似问题,不知道是否和这个有关
纯中文的回答或者纯英文的回答没有类似问题,中文英文混杂的答案会有类似问题,不知道是否和这个有关
我还是无法复现。你是怎么复现的?
参考这篇文章https://github.com/noobnooc/noobnooc/discussions/9将API域名改为了自己的域名,此问题会复现。用这个域名api.openai.com没有问题,就是需要全局代理。不确定是不是这个问题,希望增加个功能可以自己设置代理。
那应该只是自己域名的问题。我自己也是这么使用的,没有任何异常。
https://github.com/Bin-Huang/chatbox/releases/tag/v0.1.2
最新版本已经修复了
我用最新版本也偶现了这个问题:

在这里例子中我使用了 Caddy 作为中转域名,当时可能网络不太好。
不知道 @valleyk 大佬有没有其他想法?
报错:
Error parsing item: {"id":"chatcmpl-6uyXmHhSnL8glLnD9coMedSt7oG4N","object":"chat.completion.chunk","cre.
Error Details: SyntaxError: Unterminated string in JSON at position 84
错误JSON (只有半截):
{"id":"chatcmpl-6uyXmHhSnL8glLnD9coMedSt7oG4N","object":"chat.completion.chunk","cre.
尝试下caddy 里 禁掉gzip @Bin-Huang
@valleyk
我的 Caddyfile 大致是这样的,没有显式开启 gzip。同时我查阅了 Caddy 2 的文档,也没看到 Caddy2 会默认开启 gzip。
:80 {
reverse_proxy https://api.openai.com {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
我使用 https://github.com/Ice-Hazymoon/openai-scf-proxy 项目的方法代理了openai的api,服务器位于美国西岸,prompt为hello,你好之类基本没问题,问其他问题,可能回答长点儿就会遇到以下三种类型的错误:
API Request Failed:
Error parsing item: {"id":"chatcmpl-6w",.
Error Details: SyntaxError: Expected double-quoted property name in JSON at position 47
API Request Failed:
Error parsing item: {"id":"chatcmpl-6wN",".
Error Details: SyntaxError: Unterminated string in JSON at position 48
API Request Failed:
Error parsing item: {"id":"chatcmpl-6w","object":"chat.completion.chunk","created":167.
Error Details: SyntaxError: Expected ',' or '}' after property value in JSON at position 93
我怀疑是网络速度慢导致的,我在android上使用 https://github.com/Waboodoo/HTTP-Shortcuts 来测试,一个问题大概需要10多秒才可以跑完。但不会报类似上面的语法错误。
我使用 https://github.com/Ice-Hazymoon/openai-scf-proxy 项目的方法代理了openai的api,服务器位于美国西岸,prompt为hello,你好之类基本没问题,问其他问题,可能回答长点儿就会遇到以下三种类型的错误:
API Request Failed: Error parsing item: {"id":"chatcmpl-6w",. Error Details: SyntaxError: Expected double-quoted property name in JSON at position 47API Request Failed: Error parsing item: {"id":"chatcmpl-6wN",". Error Details: SyntaxError: Unterminated string in JSON at position 48API Request Failed: Error parsing item: {"id":"chatcmpl-6w","object":"chat.completion.chunk","created":167. Error Details: SyntaxError: Expected ',' or '}' after property value in JSON at position 93我怀疑是网络速度慢导致的,我在android上使用 https://github.com/Waboodoo/HTTP-Shortcuts 来测试,一个问题大概需要10多秒才可以跑完。但不会报类似上面的语法错误。
什么版本呢?
我有测试0.2.1,0.2.0,0.1.15,表现都一样。 现在我这边问题已解决,我换了自己的VPS,使用nginx反代,还是有以上的报错,然后按照 https://crazystar.net/2023/03/05/how-to-use-nginx-proxy-openai-with-eventsource/ 给nginx配置增加了
proxy_buffering off;
proxy_cache off;
两个选项后,问题解决,也同时支持stream那种逐字出来的效果。
我有测试0.2.1,0.2.0,0.1.15,表现都一样。 现在我这边问题已解决,我换了自己的VPS,使用nginx反代,还是有以上的报错,然后按照 https://crazystar.net/2023/03/05/how-to-use-nginx-proxy-openai-with-eventsource/ 给nginx配置增加了
proxy_buffering off; proxy_cache off;两个选项后,问题解决,也同时支持stream那种逐字出来的效果。
亲测有效