From d0eafe203cec1af2f5e64f0701dceab97ba2cf7d Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Tue, 1 Sep 2026 17:58:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20AI=5FMAX=5FTOKENS/AI=5FTEMPERATURE=20?= =?UTF-8?q?=E6=9C=AA=E9=85=8D=E7=BD=AE=E6=97=B6=E4=BD=BF=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E6=88=AA=E6=96=AD=E5=88=86=E6=9E=90=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/ai_config.py | 4 ++-- backend/services/ai_service.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/services/ai_config.py b/backend/services/ai_config.py index 93a1afb..6d3a912 100644 --- a/backend/services/ai_config.py +++ b/backend/services/ai_config.py @@ -8,5 +8,5 @@ load_dotenv() AI_API_BASE = os.getenv("AI_API_BASE", "https://openteam.oneisall.xyz/v1") AI_API_KEY = os.getenv("AI_API_KEY", "") AI_MODEL = os.getenv("AI_MODEL", "deepseek-v4-flash") -AI_MAX_TOKENS = int(os.getenv("AI_MAX_TOKENS", "4096")) -AI_TEMPERATURE = float(os.getenv("AI_TEMPERATURE", "0.7")) +AI_MAX_TOKENS = int(os.getenv("AI_MAX_TOKENS")) if os.getenv("AI_MAX_TOKENS") else None +AI_TEMPERATURE = float(os.getenv("AI_TEMPERATURE")) if os.getenv("AI_TEMPERATURE") else None diff --git a/backend/services/ai_service.py b/backend/services/ai_service.py index d93eeda..dcfc81a 100644 --- a/backend/services/ai_service.py +++ b/backend/services/ai_service.py @@ -80,9 +80,11 @@ async def call_llm(messages: list, tools: list = None) -> dict: payload = { "model": AI_MODEL, "messages": messages, - "max_tokens": AI_MAX_TOKENS, - "temperature": AI_TEMPERATURE, } + if AI_MAX_TOKENS is not None: + payload["max_tokens"] = AI_MAX_TOKENS + if AI_TEMPERATURE is not None: + payload["temperature"] = AI_TEMPERATURE if tools: payload["tools"] = tools payload["tool_choice"] = "auto"