Skip to content

Commit

Permalink
gracefully handle missing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
avoonix committed Jun 23, 2024
1 parent c16ba73 commit 5a2ad5b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion fuzzle/src/database/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ impl Database {
fn run_migrations(&self) -> Result<(), DatabaseError> {
let conn = &mut self.pool.get()?;
conn.run_pending_migrations(MIGRATIONS).map_err(|err| {
dbg!(&err);
anyhow::anyhow!(err.to_string())
})?;

Expand Down
7 changes: 4 additions & 3 deletions fuzzle/src/qdrant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl VectorDatabase {
// TODO: use a different embedding model that was optimized just for text
&self,
tags: &[String],
) -> Result<Vec<String>, VectorDatabaseError> {
) -> Result<Option<Vec<String>>, VectorDatabaseError> {
let tags = tags
.into_iter()
.map(|tag| tag_to_uuid(&tag).into())
Expand All @@ -250,8 +250,9 @@ impl VectorDatabase {
// with_payload: Some(vec!["file_hash"].into()),
..Default::default()
})
.await?;
Ok(convert_tag_recommend_response(search_result.result))
.await
.convert_to_sensible_error()?;
Ok(search_result.map(|search_result| convert_tag_recommend_response(search_result.result)))
}

#[tracing::instrument(skip(self), err(Debug))]
Expand Down
1 change: 0 additions & 1 deletion fuzzle/src/tags/tag_suggestions/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ impl TagSuggestionRules {
}
}
}
dbg!(&emoji_rules, &string_rules);
Ok(Self {
emoji_rules,
string_rules,
Expand Down
6 changes: 3 additions & 3 deletions fuzzle/src/tags/tag_suggestions/similar_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub async fn suggest_similar_tags(
return Ok(vec![]);
}
let result = vector_db.recommend_tags_from_existing_tags(tags).await?;
Ok(convert_vectordb_recommended_tags_to_suggestions(
result,
tag_manager,
Ok(result.map_or_else(
|| vec![],
|result| convert_vectordb_recommended_tags_to_suggestions(result, tag_manager),
))
}

0 comments on commit 5a2ad5b

Please sign in to comment.