embed no longer async

This commit is contained in:
Louis Dureuil 2024-03-19 15:42:53 +01:00
parent ac52c857e8
commit f649f58013
No known key found for this signature in database
2 changed files with 5 additions and 7 deletions

View File

@ -202,7 +202,7 @@ pub async fn search_with_url_query(
let index = index_scheduler.index(&index_uid)?; let index = index_scheduler.index(&index_uid)?;
let features = index_scheduler.features(); let features = index_scheduler.features();
let distribution = embed(&mut query, index_scheduler.get_ref(), &index).await?; let distribution = embed(&mut query, index_scheduler.get_ref(), &index)?;
let search_result = let search_result =
tokio::task::spawn_blocking(move || perform_search(&index, query, features, distribution)) tokio::task::spawn_blocking(move || perform_search(&index, query, features, distribution))
@ -241,7 +241,7 @@ pub async fn search_with_post(
let features = index_scheduler.features(); let features = index_scheduler.features();
let distribution = embed(&mut query, index_scheduler.get_ref(), &index).await?; let distribution = embed(&mut query, index_scheduler.get_ref(), &index)?;
let search_result = let search_result =
tokio::task::spawn_blocking(move || perform_search(&index, query, features, distribution)) tokio::task::spawn_blocking(move || perform_search(&index, query, features, distribution))
@ -260,7 +260,7 @@ pub async fn search_with_post(
Ok(HttpResponse::Ok().json(search_result)) Ok(HttpResponse::Ok().json(search_result))
} }
pub async fn embed( pub fn embed(
query: &mut SearchQuery, query: &mut SearchQuery,
index_scheduler: &IndexScheduler, index_scheduler: &IndexScheduler,
index: &milli::Index, index: &milli::Index,
@ -287,7 +287,6 @@ pub async fn embed(
let embeddings = embedder let embeddings = embedder
.embed(vec![q.to_owned()]) .embed(vec![q.to_owned()])
.await
.map_err(milli::vector::Error::from) .map_err(milli::vector::Error::from)
.map_err(milli::Error::from)? .map_err(milli::Error::from)?
.pop() .pop()

View File

@ -75,9 +75,8 @@ pub async fn multi_search_with_post(
}) })
.with_index(query_index)?; .with_index(query_index)?;
let distribution = embed(&mut query, index_scheduler.get_ref(), &index) let distribution =
.await embed(&mut query, index_scheduler.get_ref(), &index).with_index(query_index)?;
.with_index(query_index)?;
let search_result = tokio::task::spawn_blocking(move || { let search_result = tokio::task::spawn_blocking(move || {
perform_search(&index, query, features, distribution) perform_search(&index, query, features, distribution)