From 28694fefb0379d5171889f692d0902ec260a018d Mon Sep 17 00:00:00 2001 From: Timebomb2018 <18868801967@163.com> Date: Tue, 28 Apr 2026 16:10:44 +0800 Subject: [PATCH] fix(app): adjust thinking budget tokens default and validation range The default thinking budget tokens value was changed from 10000 to 1024 in base.py, and the minimum validation constraint was updated from 1024 to 1 in app_schema.py to allow smaller budgets while maintaining backward compatibility. --- api/app/core/models/base.py | 2 +- api/app/schemas/app_schema.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/app/core/models/base.py b/api/app/core/models/base.py index 86ac5fe0..6847a880 100644 --- a/api/app/core/models/base.py +++ b/api/app/core/models/base.py @@ -216,7 +216,7 @@ class RedBearModelFactory: # 深度思考模式:Claude 3.7 Sonnet 等支持思考的模型 # 通过 additional_model_request_fields 传递 thinking 块,关闭时不传(Bedrock 无 disabled 选项) if config.deep_thinking: - budget = config.thinking_budget_tokens or 10000 + budget = config.thinking_budget_tokens or 1024 params["additional_model_request_fields"] = { "thinking": {"type": "enabled", "budget_tokens": budget} } diff --git a/api/app/schemas/app_schema.py b/api/app/schemas/app_schema.py index 89603322..7facf381 100644 --- a/api/app/schemas/app_schema.py +++ b/api/app/schemas/app_schema.py @@ -250,7 +250,7 @@ class ModelParameters(BaseModel): n: int = Field(default=1, ge=1, le=10, description="生成的回复数量") stop: Optional[List[str]] = Field(default=None, description="停止序列") deep_thinking: bool = Field(default=False, description="是否启用深度思考模式(需模型支持,如 DeepSeek-R1、QwQ 等)") - thinking_budget_tokens: Optional[int] = Field(default=None, ge=1024, le=131072, description="深度思考 token 预算(仅部分模型支持)") + thinking_budget_tokens: Optional[int] = Field(default=None, ge=1, le=131072, description="深度思考 token 预算(仅部分模型支持)") json_output: bool = Field(default=False, description="是否强制 JSON 格式输出(需模型支持 json_output 能力)")