mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
allow saving of empty description
This commit is contained in:
parent
df96c04c38
commit
8063ec38bb
@ -911,34 +911,32 @@ def set_description(id):
|
|||||||
json: dict[str, any] = request.get_json(silent=True) or {}
|
json: dict[str, any] = request.get_json(silent=True) or {}
|
||||||
new_description = json.get("description")
|
new_description = json.get("description")
|
||||||
|
|
||||||
if new_description is None or len(new_description) == 0:
|
event.data["description"] = new_description or None
|
||||||
return make_response(
|
|
||||||
jsonify(
|
|
||||||
{
|
|
||||||
"success": False,
|
|
||||||
"message": "description cannot be empty",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
400,
|
|
||||||
)
|
|
||||||
|
|
||||||
event.data["description"] = new_description
|
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
# If semantic search is enabled, update the index
|
# If semantic search is enabled, update the index
|
||||||
if current_app.frigate_config.semantic_search.enabled:
|
if current_app.frigate_config.semantic_search.enabled:
|
||||||
context: EmbeddingsContext = current_app.embeddings
|
context: EmbeddingsContext = current_app.embeddings
|
||||||
|
if new_description is None or len(new_description) == 0:
|
||||||
|
context.embeddings.description.delete(ids=[id])
|
||||||
|
else:
|
||||||
context.embeddings.description.upsert(
|
context.embeddings.description.upsert(
|
||||||
documents=[new_description],
|
documents=[new_description],
|
||||||
metadatas=[get_metadata(event)],
|
metadatas=[get_metadata(event)],
|
||||||
ids=[id],
|
ids=[id],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
response_message = (
|
||||||
|
f"Event {id} description is now blank"
|
||||||
|
if new_description is None or len(new_description) == 0
|
||||||
|
else f"Event {id} description set to {new_description}"
|
||||||
|
)
|
||||||
|
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify(
|
jsonify(
|
||||||
{
|
{
|
||||||
"success": True,
|
"success": True,
|
||||||
"message": "Event " + id + " description set to " + new_description,
|
"message": response_message,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
200,
|
200,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user