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
Describe the bug / 描述问题 使用ChatGPT bot时有时候返回的错误数据不是json,而是html。导致JSON.parse(error.data)报错。
JSON.parse(error.data)
To Reproduce / 复现步骤 打开应用选择GPT-3.5或GPT(WEB浏览),切换到香港代理。发送prompt
Expected behavior / 期望行为 能够正确解析数据。比如这样(src/bots/openai/ChatGPTBot.js):
src/bots/openai/ChatGPTBot.js
if (error.data) { try { const data = JSON.parse(error.data); message = data.detail; } catch (e) { // 创建一个虚拟的 HTML 元素 const div = document.createElement("div"); // 将文档字符串赋值给虚拟元素的 innerHTML 属性 div.innerHTML = error.data; // 使用 DOM 操作获取目标标签的文本内容 const p = div.querySelector("p").textContent; const span=div.querySelector("span").textContent message = `${p}. ${span}`; } }
这时能够显示恰当的内容:
The text was updated successfully, but these errors were encountered:
嗯,这种情况是没处理,多谢发现了它。不过,最好别用 catch 来处理正常逻辑。可以先通过简单的格式判断来分辨是 JSON 还是 html
Sorry, something went wrong.
69a08d6
No branches or pull requests
Describe the bug / 描述问题
使用ChatGPT bot时有时候返回的错误数据不是json,而是html。导致
JSON.parse(error.data)
报错。To Reproduce / 复现步骤
打开应用选择GPT-3.5或GPT(WEB浏览),切换到香港代理。发送prompt
Expected behavior / 期望行为
能够正确解析数据。比如这样(
src/bots/openai/ChatGPTBot.js
):这时能够显示恰当的内容:
The text was updated successfully, but these errors were encountered: