Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: do not generate search summary if result is empty

Nathane6951012f0a9
diff --git a/frontend/rust-lib/flowy-search/src/document/handler.rs b/frontend/rust-lib/flowy-search/src/document/handler.rs
index d236f4b639..2127ef0d98 100644
--- a/frontend/rust-lib/flowy-search/src/document/handler.rs
+++ b/frontend/rust-lib/flowy-search/src/document/handler.rs
@@ -90,6 +90,7 @@ impl SearchHandler for DocumentSearchHandler {
return;
}
};
+ trace!("[Search] search result: {:?}", result_items);
// Prepare input for search summary generation.
let summary_input: Vec<SearchResult> = result_items
@@ -122,11 +123,15 @@ impl SearchHandler for DocumentSearchHandler {
CreateSearchResultPBArgs::default()
.searching(false)
.search_result(Some(search_result))
- .generating_ai_summary(true)
+ .generating_ai_summary(!result_items.is_empty())
.build()
.unwrap(),
);
+ if result_items.is_empty() {
+ return;
+ }
+
// Generate and yield search summary.
match cloud_service.generate_search_summary(&workspace_id, query.clone(), summary_input).await {
Ok(summary_result) => {