diff --git a/frigate/api/chat.py b/frigate/api/chat.py index a813563c1b..3c3d647661 100644 --- a/frigate/api/chat.py +++ b/frigate/api/chat.py @@ -306,7 +306,7 @@ async def _execute_search_objects_semantic( visual_distances: dict[str, float] = {} description_distances: dict[str, float] = {} try: - rows = context.search_thumbnail(semantic_query) + rows = await asyncio.to_thread(context.search_thumbnail, semantic_query) visual_distances = {row[0]: row[1] for row in rows} except Exception: logger.exception( @@ -314,7 +314,7 @@ async def _execute_search_objects_semantic( ) try: - rows = context.search_description(semantic_query) + rows = await asyncio.to_thread(context.search_description, semantic_query) description_distances = {row[0]: row[1] for row in rows} except Exception: logger.exception( @@ -448,7 +448,7 @@ async def _execute_find_similar_objects( try: if similarity_mode in ("visual", "fused"): - rows = context.search_thumbnail(anchor) + rows = await asyncio.to_thread(context.search_thumbnail, anchor) visual_distances = {row[0]: row[1] for row in rows} if similarity_mode in ("semantic", "fused"): @@ -457,7 +457,7 @@ async def _execute_find_similar_objects( or anchor.sub_label or anchor.label ) - rows = context.search_description(query_text) + rows = await asyncio.to_thread(context.search_description, query_text) description_distances = {row[0]: row[1] for row in rows} except Exception: logger.exception("Similarity search failed") diff --git a/frigate/api/event.py b/frigate/api/event.py index 5f55f1c831..011c6b887b 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -1561,9 +1561,8 @@ async def set_description( if len(new_description) > 0: # If semantic search is enabled, update the index if request.app.frigate_config.semantic_search.enabled: - context.update_description( - event_id, - new_description, + await asyncio.to_thread( + context.update_description, event_id, new_description ) else: # embeddings are always cleaned up so they don't outlive their description diff --git a/frigate/api/review.py b/frigate/api/review.py index 25b9070a62..29d8dc5b19 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -1,5 +1,6 @@ """Review apis.""" +import asyncio import datetime import logging from functools import reduce @@ -797,7 +798,7 @@ async def regenerate_review_description(request: Request, review_id: str): ) context: EmbeddingsContext = request.app.embeddings - context.regenerate_review_description(review_id) + await asyncio.to_thread(context.regenerate_review_description, review_id) return JSONResponse( content={