From 13411eb5959c3e03c2c39495b859ce5b742c47cc Mon Sep 17 00:00:00 2001 From: Linghong Date: Wed, 8 Jul 2026 14:25:17 +0000 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=89=B2=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E5=86=B3=E7=AD=96=E6=94=B9=E7=94=A8=20gpt-5-mini=EF=BC=88Respo?= =?UTF-8?q?nses=20+=20low=20=E6=8E=A8=E7=90=86=E6=A1=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 视觉模型 gpt-4o-mini → gpt-5-mini。 - gpt-5-mini 是推理模型:视觉决策走 Responses 协议并设 reasoning_effort=low, 否则默认档会把 token 预算全烧在推理上、返回空答案;纯文本路径仍走 ChatCompletions。 - max_tokens 96 → 768,给 low 档推理(实测 320~384 token)留足余量。 已真机验证:/responses 端点网关可用,暖肤色主体正确选中冷色背景。 Co-Authored-By: Claude Opus 4.8 --- .../src/editor_screen_background_decision.rs | 13 ++++++++++--- .../crates/api-server/src/llm_model_routing.rs | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/api-server/src/editor_screen_background_decision.rs b/server-rs/crates/api-server/src/editor_screen_background_decision.rs index d2f59a7bd..1762e3e92 100644 --- a/server-rs/crates/api-server/src/editor_screen_background_decision.rs +++ b/server-rs/crates/api-server/src/editor_screen_background_decision.rs @@ -1,4 +1,4 @@ -use platform_llm::{LlmClient, LlmMessage, LlmTextRequest}; +use platform_llm::{LlmClient, LlmMessage, LlmResponseReasoningEffort, LlmTextRequest}; use serde_json::json; use tracing::{info, warn}; @@ -151,11 +151,18 @@ pub(crate) async fn resolve_editor_screen_background_color( } None => LlmMessage::user(user_prompt.as_str()), }; + // 预算要够推理模型(如 gpt-5-mini)先花几百 token 推理、再吐 JSON 答案; + // 实测 low 档推理约 320~384 token,取 768 留足余量。非推理模型遇 stop 提前结束,不会多花。 let mut request = LlmTextRequest::new(vec![LlmMessage::system(system_prompt), user_message]) - .with_max_tokens(96) + .with_max_tokens(768) .with_request_timeout_ms(EDITOR_SCREEN_BACKGROUND_DECISION_TIMEOUT_MS); if let Some(vision_model) = vision_model { - request = request.with_model(vision_model); + // 视觉模型 gpt-5-mini 是推理模型:走 Responses 协议并压到 low 推理档, + // 否则默认档会把预算全烧在推理上、返回空答案。 + request = request + .with_model(vision_model) + .with_responses_api() + .with_response_reasoning_effort(LlmResponseReasoningEffort::Low); } match llm_client.request_text(request).await { Ok(response) => { diff --git a/server-rs/crates/api-server/src/llm_model_routing.rs b/server-rs/crates/api-server/src/llm_model_routing.rs index 16cd06539..49f8e6740 100644 --- a/server-rs/crates/api-server/src/llm_model_routing.rs +++ b/server-rs/crates/api-server/src/llm_model_routing.rs @@ -1,5 +1,6 @@ pub(crate) const RPG_STORY_LLM_MODEL: &str = "doubao-seed-character-251128"; pub(crate) const CREATION_TEMPLATE_LLM_MODEL: &str = "deepseek-v3-2-251201"; pub(crate) const PUZZLE_LEVEL_NAME_VISION_LLM_MODEL: &str = "gpt-4o-mini"; -// 抠图背景色决策的视觉模型:只需看图选色,用低成本视觉模型即可。 -pub(crate) const EDITOR_SCREEN_BACKGROUND_VISION_LLM_MODEL: &str = "gpt-4o-mini"; +// 抠图背景色决策的视觉模型。gpt-5-mini 是推理模型,会先花若干 token 做推理, +// 故决策请求的 max_tokens 需留足推理开销(见 editor_screen_background_decision)。 +pub(crate) const EDITOR_SCREEN_BACKGROUND_VISION_LLM_MODEL: &str = "gpt-5-mini";