瀏覽代碼

Fix: Handle empty server response in API call

kidv 1 年之前
父節點
當前提交
29e03b88c7
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      app/client/platforms/openai.ts

+ 3 - 0
app/client/platforms/openai.ts

@@ -151,6 +151,9 @@ export class ChatGPTApi implements LLMApi {
           if (finished || controller.signal.aborted) {
             responseText += remainText;
             console.log("[Response Animation] finished");
+            if (responseText?.length === 0) {
+              options.onError?.(new Error("empty response from server"));
+            }
             return;
           }