From 34895c2d5575ae32bb7380205b750879b13faf39 Mon Sep 17 00:00:00 2001 From: imeepos Date: Tue, 22 Jul 2025 18:36:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96markdown=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src-tauri/src/infrastructure/gemini_service.rs | 8 ++++++-- apps/desktop/src/components/ChatInterface.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs b/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs index 3931d20..a8a5830 100644 --- a/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs +++ b/apps/desktop/src-tauri/src/infrastructure/gemini_service.rs @@ -1059,6 +1059,9 @@ impl GeminiService { let start_time = std::time::Instant::now(); println!("🔍 开始多轮RAG Grounding查询: {}", request.user_input); + // 先提取 system_prompt,避免 request 被消费后无法访问 + let request_system_prompt = request.system_prompt.clone(); + // 获取配置,确保 system_prompt 不会被覆盖 let mut rag_config = request.config.unwrap_or_default(); @@ -1145,7 +1148,7 @@ impl GeminiService { // 4. 执行RAG查询 println!("🚀 准备执行RAG查询,contents数量: {}", contents.len()); - let response = self.execute_rag_grounding_with_contents(contents, rag_config).await?; + let response = self.execute_rag_grounding_with_contents(contents, rag_config, request_system_prompt).await?; println!("📥 RAG查询响应已收到"); // 5. 保存消息到会话历史(如果有会话仓库) @@ -1250,6 +1253,7 @@ impl GeminiService { &mut self, contents: Vec, rag_config: RagGroundingConfig, + request_system_prompt: Option, ) -> Result { println!("🔑 开始获取访问令牌..."); // 获取访问令牌 @@ -1285,7 +1289,7 @@ impl GeminiService { }; // 获取系统提示 - let system_prompt = if let Some(system_prompt) = &request.system_prompt { + let system_prompt = if let Some(system_prompt) = &request_system_prompt { Some(system_prompt.clone()) } else { rag_config.system_prompt.clone() diff --git a/apps/desktop/src/components/ChatInterface.tsx b/apps/desktop/src/components/ChatInterface.tsx index 7ad0322..f06df62 100644 --- a/apps/desktop/src/components/ChatInterface.tsx +++ b/apps/desktop/src/components/ChatInterface.tsx @@ -338,20 +338,20 @@ export const ChatInterface: React.FC = ({ } }); - let searchText = '我想要'; + let searchText = ''; if (tagGroups.style.length > 0) { - searchText += `${tagGroups.style.join('、')}风格的`; + searchText += `${tagGroups.style.join('、')}`; } if (tagGroups.color.length > 0) { searchText += `${tagGroups.color.join('、')}`; } if (tagGroups.occasion.length > 0) { - searchText += `适合${tagGroups.occasion.join('、')}的`; + searchText += `${tagGroups.occasion.join('、')}`; } if (tagGroups.other.length > 0) { searchText += `${tagGroups.other.join('、')}`; } - searchText += '穿搭推荐'; + searchText += ''; return searchText; }, [selectedTags]);