mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-02 22:01:05 +02:00
Merge pull request #886 from xr843/fix/async-embedding-search-dev
fix: use asyncio.to_thread for embedding calls in search endpoints
This commit is contained in:
commit
0751f18e5a
1 changed files with 4 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
@ -49,7 +50,7 @@ class ChucksHybridSearchRetriever:
|
||||||
# Get embedding for the query
|
# Get embedding for the query
|
||||||
embedding_model = config.embedding_model_instance
|
embedding_model = config.embedding_model_instance
|
||||||
t_embed = time.perf_counter()
|
t_embed = time.perf_counter()
|
||||||
query_embedding = embedding_model.embed(query_text)
|
query_embedding = await asyncio.to_thread(embedding_model.embed, query_text)
|
||||||
perf.debug(
|
perf.debug(
|
||||||
"[chunk_search] vector_search embedding in %.3fs",
|
"[chunk_search] vector_search embedding in %.3fs",
|
||||||
time.perf_counter() - t_embed,
|
time.perf_counter() - t_embed,
|
||||||
|
|
@ -195,7 +196,7 @@ class ChucksHybridSearchRetriever:
|
||||||
if query_embedding is None:
|
if query_embedding is None:
|
||||||
embedding_model = config.embedding_model_instance
|
embedding_model = config.embedding_model_instance
|
||||||
t_embed = time.perf_counter()
|
t_embed = time.perf_counter()
|
||||||
query_embedding = embedding_model.embed(query_text)
|
query_embedding = await asyncio.to_thread(embedding_model.embed, query_text)
|
||||||
perf.debug(
|
perf.debug(
|
||||||
"[chunk_search] hybrid_search embedding in %.3fs",
|
"[chunk_search] hybrid_search embedding in %.3fs",
|
||||||
time.perf_counter() - t_embed,
|
time.perf_counter() - t_embed,
|
||||||
|
|
@ -427,4 +428,4 @@ class ChucksHybridSearchRetriever:
|
||||||
search_space_id,
|
search_space_id,
|
||||||
document_type,
|
document_type,
|
||||||
)
|
)
|
||||||
return final_docs
|
return final_docs
|
||||||
Loading…
Add table
Add a link
Reference in a new issue