reindex with api endpoint and zmq

This commit is contained in:
Josh Hawkins 2025-03-27 09:29:05 -05:00
parent 1233bc3a42
commit 265b9fa698
4 changed files with 33 additions and 0 deletions

View File

@ -298,3 +298,29 @@ def reprocess_license_plate(request: Request, event_id: str):
content=response,
status_code=200,
)
@router.put("/reindex")
def reindex_embeddings(request: Request):
if not request.app.frigate_config.semantic_search.enabled:
message = (
"Cannot reindex tracked object embeddings, Semantic Search is not enabled."
)
logger.error(message)
return JSONResponse(
content=(
{
"success": False,
"message": message,
}
),
status_code=400,
)
context: EmbeddingsContext = request.app.embeddings
response = context.reindex_embeddings()
return JSONResponse(
content=response,
status_code=200,
)

View File

@ -17,6 +17,7 @@ class EmbeddingsRequestEnum(Enum):
register_face = "register_face"
reprocess_face = "reprocess_face"
reprocess_plate = "reprocess_plate"
reindex = "reindex"
class EmbeddingsResponder:

View File

@ -250,3 +250,6 @@ class EmbeddingsContext:
return self.requestor.send_data(
EmbeddingsRequestEnum.reprocess_plate.value, {"event": event}
)
def reindex_embeddings(self) -> dict[str, any]:
return self.requestor.send_data(EmbeddingsRequestEnum.reindex.value, {})

View File

@ -206,6 +206,9 @@ class EmbeddingMaintainer(threading.Thread):
self.embeddings.embed_description("", data, upsert=False),
pack=False,
)
elif topic == EmbeddingsRequestEnum.reindex.value:
self.embeddings.reindex()
return "Embeddings reindex in progress"
processors = [self.realtime_processors, self.post_processors]
for processor_list in processors: