feat: 支持插件异常反馈

This commit is contained in:
Hk-Gosuto
2023-08-09 12:14:40 +08:00
parent a7c4b1d6b2
commit b15e0b7c6d
4 changed files with 53 additions and 105 deletions

View File

@@ -287,14 +287,15 @@ export class ChatGPTApi implements LLMApi {
}
},
onmessage(msg) {
if (msg.data === "[DONE]" || finished) {
return finish();
}
let response = JSON.parse(msg.data);
if (!response.isSuccess) {
console.error("[Request]", response, msg);
console.error("[Request]", msg.data);
responseText = msg.data;
throw Error(response.message);
}
if (msg.data === "[DONE]" || finished) {
return finish();
}
try {
if (response && !response.isToolMessage) {
responseText += response.message;