diff --git a/frigate/api/defs/events_body.py b/frigate/api/defs/events_body.py index 7aef87433..ca1256598 100644 --- a/frigate/api/defs/events_body.py +++ b/frigate/api/defs/events_body.py @@ -11,9 +11,7 @@ class EventsSubLabelBody(BaseModel): class EventsDescriptionBody(BaseModel): - description: Union[str, None] = Field( - title="The description of the event", min_length=1 - ) + description: Union[str, None] = Field(title="The description of the event") class EventsCreateBody(BaseModel): diff --git a/frigate/api/event.py b/frigate/api/event.py index 3be37539d..3a8d003ad 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -927,27 +927,19 @@ def set_description( new_description = body.description - if new_description is None or len(new_description) == 0: - return JSONResponse( - content=( - { - "success": False, - "message": "description cannot be empty", - } - ), - status_code=400, - ) - event.data["description"] = new_description event.save() # If semantic search is enabled, update the index if request.app.frigate_config.semantic_search.enabled: context: EmbeddingsContext = request.app.embeddings - context.update_description( - event_id, - new_description, - ) + if len(new_description) > 0: + context.update_description( + event_id, + new_description, + ) + else: + context.db.delete_embeddings_description(event_ids=[event_id]) response_message = ( f"Event {event_id} description is now blank" @@ -1033,8 +1025,8 @@ def delete_event(request: Request, event_id: str): # If semantic search is enabled, update the index if request.app.frigate_config.semantic_search.enabled: context: EmbeddingsContext = request.app.embeddings - context.db.delete_embeddings_thumbnail(id=[event_id]) - context.db.delete_embeddings_description(id=[event_id]) + context.db.delete_embeddings_thumbnail(event_ids=[event_id]) + context.db.delete_embeddings_description(event_ids=[event_id]) return JSONResponse( content=({"success": True, "message": "Event " + event_id + " deleted"}), status_code=200, diff --git a/frigate/events/cleanup.py b/frigate/events/cleanup.py index 8fabf2b21..9442eabe9 100644 --- a/frigate/events/cleanup.py +++ b/frigate/events/cleanup.py @@ -229,8 +229,8 @@ class EventCleanup(threading.Thread): Event.delete().where(Event.id << chunk).execute() if self.config.semantic_search.enabled: - self.db.delete_embeddings_description(chunk) - self.db.delete_embeddings_thumbnail(chunk) + self.db.delete_embeddings_description(event_ids=[chunk]) + self.db.delete_embeddings_thumbnail(event_ids=[chunk]) logger.debug(f"Deleted {len(events_to_delete)} embeddings") logger.info("Exiting event cleanup...")