From 939c35a9b96f70c03b55b23371daed87ef1f60ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 19 Sep 2026 13:48:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=BC=BA=E7=9C=81=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=A8=A1=E5=9E=8B=E7=9A=84=E5=BD=92=E4=B8=80=E5=8C=96?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit normalize_image_model 的空白模型回退改为 GPT_IMAGE_2_5_GENERATION_MODEL,与 build_image_request_body 默认值一致 补充单测断言空白模型与默认生成模型产出同一请求体 --- .../src/image_provider/protocol/request.rs | 7 ++++++- server-rs/crates/platform-image/tests/image_provider.rs | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server-rs/crates/platform-image/src/image_provider/protocol/request.rs b/server-rs/crates/platform-image/src/image_provider/protocol/request.rs index b60a93f2b..0210b149b 100644 --- a/server-rs/crates/platform-image/src/image_provider/protocol/request.rs +++ b/server-rs/crates/platform-image/src/image_provider/protocol/request.rs @@ -87,9 +87,14 @@ pub fn build_nanobanana_generate_content_request_body( }) } +/// 归一化调用方传入的模型字符串。 +/// +/// 只处理缺省场景:空/空白输入落到当前默认生成模型 `GPT_IMAGE_2_5_GENERATION_MODEL`, +/// 与 `build_image_request_body` 的默认值保持一致;显式传入的模型(含历史 +/// `gpt-image-2` 等旧值)原样保留,交给 `resolve_image_provider` 做路由。 pub fn normalize_image_model(model: &str) -> &str { match model.trim() { - "" => GPT_IMAGE_2_MODEL, + "" => GPT_IMAGE_2_5_GENERATION_MODEL, value => value, } } diff --git a/server-rs/crates/platform-image/tests/image_provider.rs b/server-rs/crates/platform-image/tests/image_provider.rs index 884c9359c..a8239df71 100644 --- a/server-rs/crates/platform-image/tests/image_provider.rs +++ b/server-rs/crates/platform-image/tests/image_provider.rs @@ -59,6 +59,15 @@ fn image_provider_clamps_gpt_image_2_explicit_pixel_sizes_to_its_supported_pixel assert_eq!(poster["size"], "1280x720"); } +#[test] +fn image_provider_blank_model_falls_back_to_default_generation_model() { + let blank = build_image_request_body_with_model(" ", "空模型", None, "1024x1024", 1, &[]); + let default = build_image_request_body("空模型", None, "1024x1024", 1, &[]); + + assert_eq!(blank["model"], GPT_IMAGE_2_5_GENERATION_MODEL); + assert_eq!(blank["model"], default["model"]); +} + #[test] fn image_provider_normalizes_2k_landscape_spec_size() { let body = build_image_request_body("生成规范图", None, "2048x1152", 1, &[]);