fix: AI Chat LLM 从已失效 api.qnaigc.com 切换到 OpenCode Zen 免费 API

- 数据库 AIModel 记录从 meituan/longcat-flash-lite → deepseek-v4-flash-free
- API 端点 https://api.qnaigc.comhttps://opencode.ai/zen/v1/chat/completions
- aiChat.js 支持免 Authorization 的免费 API(apiKey 为 sk-dummy 时跳过)
- .env 同步更新
This commit is contained in:
Yuzhiran Dev
2026-07-11 13:37:25 +08:00
parent e8bc3d076a
commit 1d522df07e
+11 -9
View File
@@ -91,22 +91,24 @@ router.post('/ask', userAuthMiddleware, async (req, res) => {
modelConfig = { temperature: 0.7, maxTokens: 800, topP: 1 }
}
// 检查API配置
if (!apiKey) {
logger.error('AI API Key未配置')
return ApiResponse.error(res, 'AI服务暂时不可用', 500)
}
// 检查API配置opencode.ai免费API无需key
const needsAuth = apiKey && apiKey !== 'sk-dummy' && apiKey !== '***'
// 构建系统提示词
const systemPrompt = getSystemPromptByDimension(dimension)
// 构建请求头
const headers = {
'Content-Type': 'application/json'
}
if (needsAuth) {
headers['Authorization'] = `Bearer ${apiKey}`
}
// 调用AI API
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
headers,
body: JSON.stringify({
model: modelId,
messages: [