Просмотр исходного кода

fix: correct proxy response parsing from data.content to choices[0].message.content

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nonvioce 6 месяцев назад
Родитель
Сommit
dcc6b93351

+ 1 - 1
src/app/features/novel-writer/components/pipeline/Step0ControlCard.tsx

@@ -118,7 +118,7 @@ export default function Step0ControlCard({
       if (!res.ok) throw new Error(`API 请求失败: HTTP ${res.status}`);
       const data = await res.json();
       if (data.error) throw new Error(data.error.detail || data.error.message || 'API 返回错误');
-      const content = data.content || '';
+      const content = data.choices?.[0]?.message?.content || '';
       if (!content) throw new Error('AI 返回了空内容,请检查 API 配置或重试');
 
       setRawResponse(content);

+ 2 - 3
src/app/features/novel-writer/components/pipeline/Step4ContentEditor.tsx

@@ -359,9 +359,8 @@ ${antiText}
       });
       if (!res.ok) throw new Error(`API error: ${res.status}`);
       const data = await res.json();
-      if (data.content) {
-        setContent(data.content);
-      }
+      const deAIContent = data.choices?.[0]?.message?.content;
+      if (deAIContent) { setContent(deAIContent); }
     } catch (err) {
       setDeAIError(err instanceof Error ? err.message : '修订失败');
     } finally {

+ 1 - 1
src/app/features/novel-writer/components/pipeline/Step6ContinuityCheck.tsx

@@ -114,7 +114,7 @@ export default function Step6ContinuityCheck({
       if (!res.ok) throw new Error(`API 请求失败: HTTP ${res.status}`);
       const data = await res.json();
       if (data.error) throw new Error(data.error.detail || data.error.message || 'API 返回错误');
-      const content = data.content || '';
+      const content = data.choices?.[0]?.message?.content || '';
       if (!content) throw new Error('AI 返回了空内容,请检查 API 配置或重试');
 
       // Parse results