From 686fdef6653470debc2cbdd1738521ea090140c6 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 9 Aug 2025 13:38:41 -0600 Subject: [PATCH] Adjust prompt --- frigate/genai/__init__.py | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/frigate/genai/__init__.py b/frigate/genai/__init__.py index 3f4856971..af5444861 100644 --- a/frigate/genai/__init__.py +++ b/frigate/genai/__init__.py @@ -41,31 +41,34 @@ class GenAIClient: """Generate a description for the review item activity.""" context_prompt = f""" Please analyze the image(s), which are in chronological order, strictly from the perspective of the {review_data["camera"].replace("_", " ")} security camera. - Your task is to provide a **neutral, factual, and objective description** of the scene, while also including **reasonable, evidence-based inferences** about the likely context or activity — but do not make unfounded assumptions. + + Your task is to provide a **neutral, factual, and objective description** of the scene, while also: + - Clearly stating **what is happening** based on observable actions and movements. + - Including **reasonable, evidence-based inferences** about the likely activity or context, but only if directly supported by visible details. When forming your description: - - Base all statements on visible details in the images. - - You may deduce plausible intent or context only if supported by clear, observable evidence (e.g., someone carrying tools toward a car may indicate vehicle maintenance). - - Avoid implying hostility, criminal intent, or other strong judgments unless the visual evidence is unambiguous. - - Distinguish between what is certain (facts) and what appears likely (reasonable inference). + - **Facts first**: Describe the physical setting, people, and objects exactly as seen. + - **Then context**: Briefly note plausible purposes or activities (e.g., “appears to be delivering a package” if carrying a box to a door). + - Clearly separate certain facts (“A person is holding a ladder”) from reasonable inferences (“likely performing maintenance”). + - Do not speculate beyond what is visible, and do not imply hostility, criminal intent, or other strong judgments unless there is unambiguous visual evidence. - Here is some information we already know: - - The activity occurred at {review_data["timestamp"].strftime("%I:%M %p")} - - The following objects were detected: {review_data["objects"]} - - The following recognized objects were detected: {review_data["recognized_objects"]} - - The activity happened in the following zones: {review_data["zones"]} + Here is information already known: + - Activity occurred at {review_data["timestamp"].strftime("%I:%M %p")} + - Detected objects: {review_data["objects"]} + - Recognized objects: {review_data["recognized_objects"]} + - Zones involved: {review_data["zones"]} - Your response **MUST** be a flat JSON object with the following fields: - - `scene` (string): A comprehensive description of the setting and entities, including relevant context and plausible inferences if supported by visual evidence. - - `confidence` (float): A float between 0 and 1 representing your overall confidence in this analysis. - - `potential_threat_level` (integer, optional): 1–3 scale. Only include if a clear security concern is visible: - - 1 = Unusual but not overtly threatening - - 2 = Suspicious or potentially harmful - - 3 = Clear and immediate threat - Omit this field entirely if there is no observable security concern. + Your response **MUST** be a flat JSON object with: + - `scene` (string): A full description including setting, entities, actions, and any plausible supported inferences. + - `confidence` (float): A number 0–1 for overall confidence in the analysis. + - `potential_threat_level` (integer, optional): Include only if there is a clear, observable security concern: + - 1 = Unusual but not overtly threatening + - 2 = Suspicious or potentially harmful + - 3 = Clear and immediate threat + Omit this field if no concern is evident. **IMPORTANT:** - Values for each field must be plain strings or integers — no nested objects or explanatory text. + - Values must be plain strings, floats, or integers — no nested objects, no extra commentary. """ response = self._send(context_prompt, thumbnails)