增强聊天API错误处理: 国内网关异常时自动降级到通用引擎

Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/5a0f8fc3-ded6-4e1f-8c98-b1e59f82aad6

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-11 11:16:42 +00:00 committed by GitHub
parent a5ccbadbd6
commit 6582b5dc1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -272,8 +272,13 @@ app.post('/api/chat', async (req, res) => {
// 优先用国内模型智能网关(读取 ZY_DEEPSEEK_API_KEY 等独立密钥)
if (domesticGateway) {
const result = await domesticGateway.chat(sessionId, message);
return res.json({ ...result, sessionId });
try {
const result = await domesticGateway.chat(sessionId, message);
return res.json({ ...result, sessionId });
} catch (gwErr) {
console.error(`[聊天网关] 国内模型网关异常: ${gwErr.message}`);
// 降级到通用聊天引擎
}
}
// 降级到通用聊天引擎