From 5cba2dbeb74b85515394c3a07d50097db87f56fd 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:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20libcurl=20=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=E9=94=99=E8=AF=AF=E7=9A=84=20provider=20=E5=BD=92?= =?UTF-8?q?=E5=B1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit map_curl_error 接收实际 provider,审计、日志与 Request 错误不再写死 vector-engine executor 生成 / 编辑路径传入 settings.provider,nanobanana 路径传入 VectorEngine --- .../src/image_provider/runtime/executor.rs | 3 +++ .../src/image_provider/transport/curl.rs | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/platform-image/src/image_provider/runtime/executor.rs b/server-rs/crates/platform-image/src/image_provider/runtime/executor.rs index b4167f8ca..c6508dd7b 100644 --- a/server-rs/crates/platform-image/src/image_provider/runtime/executor.rs +++ b/server-rs/crates/platform-image/src/image_provider/runtime/executor.rs @@ -188,6 +188,7 @@ pub async fn create_image_generation_with_model( } return Err(finish_image_model_fallback_error( map_curl_error( + settings.provider, format!("{failure_context}:创建图片生成任务失败").as_str(), request_url.as_str(), "request_send", @@ -377,6 +378,7 @@ pub async fn create_nanobanana_generate_content( } } return Err(map_curl_error( + ImageProvider::VectorEngine, format!("{failure_context}:创建 nanobanana2 图片生成任务失败").as_str(), request_url.as_str(), "request_send", @@ -629,6 +631,7 @@ pub async fn create_image_edit_with_references_and_model( } return Err(finish_image_model_fallback_error( map_curl_error( + settings.provider, format!("{failure_context}:创建图片编辑任务失败").as_str(), request_url.as_str(), "request_send", diff --git a/server-rs/crates/platform-image/src/image_provider/transport/curl.rs b/server-rs/crates/platform-image/src/image_provider/transport/curl.rs index 416cc01ff..800c5bbee 100644 --- a/server-rs/crates/platform-image/src/image_provider/transport/curl.rs +++ b/server-rs/crates/platform-image/src/image_provider/transport/curl.rs @@ -7,8 +7,10 @@ use curl::{ use serde_json::Value; use crate::image_provider::{ - audit::build_failure_audit, constants::VECTOR_ENGINE_PROVIDER, error::PlatformImageError, - request::build_prompt_with_negative, types::ReferenceImage, + audit::build_failure_audit, + error::PlatformImageError, + request::build_prompt_with_negative, + types::{ImageProvider, ReferenceImage}, }; #[derive(Debug)] @@ -145,6 +147,7 @@ pub(crate) async fn send_image_multipart_edit_request_with_curl( } pub(crate) fn map_curl_error( + provider: ImageProvider, context: &str, request_url: &str, failure_stage: &'static str, @@ -155,12 +158,13 @@ pub(crate) fn map_curl_error( reference_image_count: Option, request_params: Option<&Value>, ) -> PlatformImageError { + let provider_label = provider.as_str(); let is_timeout = error.is_timeout(); let is_connect = error.is_connect() || error.is_transient_transport(); let source = error.to_string(); let message = format!("{context}:{source}"); let audit = build_failure_audit( - VECTOR_ENGINE_PROVIDER, + provider_label, request_url, context, failure_stage, @@ -177,7 +181,7 @@ pub(crate) fn map_curl_error( image_model, ); tracing::warn!( - provider = VECTOR_ENGINE_PROVIDER, + provider = provider_label, endpoint = %request_url, failure_stage, timeout = is_timeout, @@ -200,7 +204,7 @@ pub(crate) fn map_curl_error( ); PlatformImageError::Request { - provider: VECTOR_ENGINE_PROVIDER, + provider: provider_label, message, endpoint: Some(request_url.to_string()), timeout: is_timeout,