Yidadaa 1 년 전
부모
커밋
5979bdd48e
1개의 변경된 파일9개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 5
      app/client/platforms/openai.ts

+ 9 - 5
app/client/platforms/openai.ts

@@ -103,11 +103,15 @@ export class ChatGPTApi implements LLMApi {
               return finish();
             }
             if (text.length === 0) continue;
-            const json = JSON.parse(text);
-            const delta = json.choices[0].delta.content;
-            if (delta) {
-              responseText += delta;
-              options.onUpdate?.(responseText, delta);
+            try {
+              const json = JSON.parse(text);
+              const delta = json.choices[0].delta.content;
+              if (delta) {
+                responseText += delta;
+                options.onUpdate?.(responseText, delta);
+              }
+            } catch (e) {
+              console.error("[Request] parse error", text, chunk);
             }
           }
         }