增强聊天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:
parent
a5ccbadbd6
commit
6582b5dc1a
|
|
@ -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}`);
|
||||
// 降级到通用聊天引擎
|
||||
}
|
||||
}
|
||||
|
||||
// 降级到通用聊天引擎
|
||||
|
|
|
|||
Loading…
Reference in New Issue