fix: 移除 mock fallback,完全使用 DeepSeek AI 解析
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d862203140
commit
dc98407edc
2
.env
2
.env
@ -14,7 +14,7 @@ DATABASE_URL=file:./prisma/dev.db
|
|||||||
# DATABASE_URL=postgresql://qia_admin:your-password@postgres.ap-shanghai.myqcloud.com:5432/qia
|
# DATABASE_URL=postgresql://qia_admin:your-password@postgres.ap-shanghai.myqcloud.com:5432/qia
|
||||||
|
|
||||||
# DeepSeek AI
|
# DeepSeek AI
|
||||||
DEEPSEEK_API_KEY=sk-7e34702637f74020b62cdd62d3f48559
|
DEEPSEEK_API_KEY=sk-3e2019e98c6f406b86ba31c7b820fb51
|
||||||
DEEPSEEK_API_URL=https://api.deepseek.com/chat/completions
|
DEEPSEEK_API_URL=https://api.deepseek.com/chat/completions
|
||||||
|
|
||||||
# CORS (支持多个开发端口)
|
# CORS (支持多个开发端口)
|
||||||
|
|||||||
@ -163,8 +163,7 @@ async function callDeepSeek(message: string): Promise<{
|
|||||||
const apiUrl = process.env.DEEPSEEK_API_URL || 'https://api.deepseek.com/chat/completions';
|
const apiUrl = process.env.DEEPSEEK_API_URL || 'https://api.deepseek.com/chat/completions';
|
||||||
|
|
||||||
if (!apiKey || apiKey === 'sk-xxx') {
|
if (!apiKey || apiKey === 'sk-xxx') {
|
||||||
// Mock response for development
|
throw new Error('DeepSeek API Key 未配置');
|
||||||
return mockParseResponse(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -232,16 +231,15 @@ async function callDeepSeek(message: string): Promise<{
|
|||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[AI] Parse error:', e);
|
console.error('[AI] Parse error:', e);
|
||||||
// Schema validation failed, use mock response
|
throw new Error(`AI 解析失败: ${e instanceof Error ? e.message : '未知错误'}`);
|
||||||
return mockParseResponse(message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn('[AI] No JSON found in response, using mock');
|
console.warn('[AI] No JSON found in response');
|
||||||
return mockParseResponse(message);
|
throw new Error('AI 响应格式错误,未能解析出 JSON');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('DeepSeek API error:', error);
|
console.error('DeepSeek API error:', error);
|
||||||
return mockParseResponse(message);
|
throw new Error(`DeepSeek API 调用失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user