From d9e9b035fa576d5b58738998eb7feed8f04bdfc4 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 26 Oct 2025 14:31:45 -0600 Subject: [PATCH] Use helper fuction --- frigate/genai/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frigate/genai/__init__.py b/frigate/genai/__init__.py index 2b7d74d53..0b33affdf 100644 --- a/frigate/genai/__init__.py +++ b/frigate/genai/__init__.py @@ -63,6 +63,12 @@ class GenAIClient: else: return "" + def get_objects_list() -> str: + if review_data["unified_objects"]: + return "\n- " + "\n- ".join(review_data["unified_objects"]) + else: + return "\n- (No objects detected)" + context_prompt = f""" Your task is to analyze the sequence of images ({len(thumbnails)} total) taken in chronological order from the perspective of the {review_data["camera"].replace("_", " ")} security camera. @@ -115,7 +121,7 @@ Your response MUST be a flat JSON object with: ## Objects in Scene Each line represents one object in the scene. Named objects are verified identities; "Unknown" indicates unverified objects of that type: -{"".join(f"\n- {obj}" for obj in review_data["unified_objects"])} +{get_objects_list()} ## Important Notes - Values must be plain strings, floats, or integers — no nested objects, no extra commentary.