From a2e173d730802dd0097dc1610a3b5f9058e650d7 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:51:26 -0500 Subject: [PATCH] Allow tracked object description to be saved as an empty string --- frigate/api/defs/events_body.py | 4 +--- frigate/api/event.py | 22 +++++++--------------- 2 files changed, 8 insertions(+), 18 deletions(-) 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..ca531d098 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_id) response_message = ( f"Event {event_id} description is now blank"