From ea2c72ea050cdb31ce5b6cda180781ffe858357c Mon Sep 17 00:00:00 2001 From: imeepos Date: Mon, 14 Jul 2025 13:22:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3Gemini=20API=E7=AB=AF?= =?UTF-8?q?=E7=82=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API端点修复: - 修正为正确的格式: base_url/model_name:generateContent - 修改前: base_url/google/vertex-ai:generateContent - 修改后: base_url/gemini-2.5-flash:generateContent 具体变更: - 简化gateway_url为base_url - 在生成URL时添加model_name - 符合Python参考代码的端点格式 预期效果: - 正确的API调用地址 - 与Cloudflare Gateway兼容 - 支持不同模型的动态切换 现在API端点应该是正确的格式了。 --- apps/desktop/src-tauri/src/infrastructure/gemini_service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs b/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs index e4d0a6d..f2d2264 100644 --- a/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs +++ b/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs @@ -210,7 +210,7 @@ impl GeminiService { headers.insert("Content-Type".to_string(), "application/json".to_string()); ClientConfig { - gateway_url: format!("{}/google/vertex-ai", self.config.base_url), + gateway_url: self.config.base_url.clone(), headers, } } @@ -332,7 +332,7 @@ impl GeminiService { println!("📦 请求数据: {}", serde_json::to_string_pretty(&request_data).unwrap_or_default()); // 发送请求到Cloudflare Gateway,参考demo.py - let generate_url = format!("{}:generateContent", client_config.gateway_url); + let generate_url = format!("{}/{}:generateContent", client_config.gateway_url, self.config.model_name); println!("📡 生成URL: {}", generate_url); // 重试机制