From 0e17abd65346fc74a4b7b654514445e6cb474d61 Mon Sep 17 00:00:00 2001 From: kicer Date: Wed, 29 Jul 2026 08:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=97=B6=E5=80=99=E4=B8=A5?= =?UTF-8?q?=E6=A0=BC=E8=A6=81=E6=B1=82json=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/ai/client.js | 3 ++- server/handlers.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/ai/client.js b/server/ai/client.js index 85601ed..62220c7 100644 --- a/server/ai/client.js +++ b/server/ai/client.js @@ -19,9 +19,10 @@ function getErrorMsg(status, data) { } } -async function callDeepSeek(messages, userId, temperature = 0.1) { +async function callDeepSeek(messages, userId, temperature = 0.1, jsonMode = true) { console.log('调用 DeepSeek...'); var body = { model: 'deepseek-v4-flash', messages: messages, temperature: temperature, stream: false, thinking: { type: 'disabled' } }; + if (jsonMode) body.response_format = { type: 'json_object' }; if (userId) body.user_id = sanitizeUserId(userId); var res = await fetch('https://api.deepseek.com/chat/completions', { method: 'POST', diff --git a/server/handlers.js b/server/handlers.js index 62d0881..6c51851 100644 --- a/server/handlers.js +++ b/server/handlers.js @@ -187,7 +187,7 @@ async function callDeepSeekForSummary(prompt, userId) { { role: 'system', content: '你是一个财务助手,请根据采购记录生成简洁回复。' }, { role: 'user', content: prompt } ]; - return callDeepSeek(messages, userId); + return callDeepSeek(messages, userId, 0.3, false); } module.exports = {