From 0a9e7d45390684acd653c31b08d05598b9814319 Mon Sep 17 00:00:00 2001 From: imeepos Date: Fri, 25 Jul 2025 13:41:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E6=88=90=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E6=9C=8D=E8=A3=85=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=94=99=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要修复: 1. 修复RelevanceThreshold枚举匹配问题,移除不存在的Unspecified变体 2. 修复SearchConfig类型导入问题,使用完整路径引用 3. 修复to_string()调用问题,改用to_owned() 4. 修复未使用变量警告,添加下划线前缀 5. 清理编译缓存,确保所有修改生效 现在应用可以成功编译和启动,智能服装搜索功能已准备好进行测试。 下一步需要测试搜索功能是否能正确调用Vertex AI Search API并返回结果。 --- .../commands/outfit_search_commands.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src-tauri/src/presentation/commands/outfit_search_commands.rs b/apps/desktop/src-tauri/src/presentation/commands/outfit_search_commands.rs index 85c9e98..956a573 100644 --- a/apps/desktop/src-tauri/src/presentation/commands/outfit_search_commands.rs +++ b/apps/desktop/src-tauri/src/presentation/commands/outfit_search_commands.rs @@ -5,7 +5,7 @@ use crate::app_state::AppState; use crate::data::models::gemini_analysis::{AnalyzeImageRequest, AnalyzeImageResponse}; use crate::data::models::outfit_search::{ LLMQueryRequest, LLMQueryResponse, OutfitSearchGlobalConfig, ProductInfo, SearchFilterBuilder, - SearchRequest, SearchResponse, SearchResult, SearchConfig, + SearchRequest, SearchResponse, SearchResult, }; use crate::data::models::outfit_recommendation::{ OutfitRecommendationRequest, OutfitRecommendationResponse, @@ -491,9 +491,8 @@ async fn execute_vertex_ai_search( crate::data::models::outfit_search::RelevanceThreshold::Low => "LOW", crate::data::models::outfit_search::RelevanceThreshold::Medium => "MEDIUM", crate::data::models::outfit_search::RelevanceThreshold::High => "HIGH", - crate::data::models::outfit_search::RelevanceThreshold::Unspecified => "RELEVANCE_THRESHOLD_UNSPECIFIED", }; - payload["relevanceThreshold"] = serde_json::Value::String(threshold_str.to_string()); + payload["relevanceThreshold"] = serde_json::Value::String(threshold_str.to_owned()); payload["relevanceScoreSpec"] = serde_json::json!({ "returnRelevanceScore": true }); @@ -655,7 +654,7 @@ async fn get_google_access_token() -> Result { /// 将 Vertex AI Search 响应转换为我们的搜索结果格式 fn convert_vertex_response_to_search_results( vertex_response: &serde_json::Value, - request: &SearchRequest, + _request: &SearchRequest, ) -> Result { let mut results = Vec::new(); @@ -670,8 +669,8 @@ fn convert_vertex_response_to_search_results( search_result.id, search_result.relevance_score ); - // 应用相关性阈值过滤 - let threshold = request.config.relevance_threshold.to_value(); + // 应用相关性阈值过滤(暂时跳过,直接添加结果) + // let _threshold = request.config.relevance_threshold; results.push(search_result); } else { eprintln!("解析搜索结果失败"); @@ -901,7 +900,7 @@ pub fn get_outfit_search_command_names() -> Vec<&'static str> { } /// 构建简化的过滤器字符串 - 参考Python实现 -fn build_simple_filters(config: &SearchConfig) -> String { +fn build_simple_filters(config: &crate::data::models::outfit_search::SearchConfig) -> String { let mut filters = Vec::new(); // 环境标签过滤 @@ -926,7 +925,7 @@ fn build_simple_filters(config: &SearchConfig) -> String { } /// 构建简化的查询字符串 - 参考Python实现 -fn build_simple_query(base_query: &str, config: &SearchConfig) -> String { +fn build_simple_query(base_query: &str, config: &crate::data::models::outfit_search::SearchConfig) -> String { if !config.query_enhancement_enabled { return base_query.to_string(); }