From 9316f0ea80d7628eea1e3b183b0c5eefc8875154 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 7 Aug 2025 05:37:37 -0600 Subject: [PATCH] testing prompt changes --- frigate/embeddings/maintainer.py | 8 ++++---- frigate/genai/__init__.py | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index 16985a165..da31dbd5f 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -152,10 +152,6 @@ class EmbeddingMaintainer(threading.Thread): self.detected_license_plates: dict[str, dict[str, Any]] = {} - self.post_processors.append( - ReviewDescriptionProcessor(self.config, self.metrics) - ) - # model runners to share between realtime and post processors if self.config.lpr.enabled: lpr_model_runner = LicensePlateModelRunner( @@ -210,6 +206,10 @@ class EmbeddingMaintainer(threading.Thread): # post processors self.post_processors: list[PostProcessorApi] = [] + self.post_processors.append( + ReviewDescriptionProcessor(self.config, self.metrics) + ) + if self.config.lpr.enabled: self.post_processors.append( LicensePlatePostProcessor( diff --git a/frigate/genai/__init__.py b/frigate/genai/__init__.py index 2a9bcd151..45e8776e2 100644 --- a/frigate/genai/__init__.py +++ b/frigate/genai/__init__.py @@ -9,6 +9,7 @@ from typing import Any, Optional from playhouse.shortcuts import model_to_dict from frigate.config import CameraConfig, FrigateConfig, GenAIConfig, GenAIProviderEnum +from frigate.data_processing.post.types import ReviewMetadata from frigate.models import Event logger = logging.getLogger(__name__) @@ -40,19 +41,24 @@ class GenAIClient: """Generate a description for the review item activity.""" context_prompt = f""" Here is additional context about the scene from a security camera: - {json.dumps(review_data, indent=2)} + 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']} - Please analyze the image(s), which are in chronological order, strictly from the perspective of a security camera. + 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. - **Do not make assumptions about intent, emotions, or potential threats.** Focus solely on observable actions, visible entities, and the environment. - Describe: - - What is happening? - - Who or what is visible? - - What are the entities doing? - - What is the environmental context (e.g., time of day, weather, lighting)? - """ + Your response **MUST** be a flat JSON object with the following fields: + - `scene` (string): A single, comprehensive description of the entire visual scene. + - `action` (string): A single description of any key actions or movements. + - `potential_threat_level` (integer, optional): An integer from 0 to 3. Only include if a clear security concern is visible. Omit if no threat. + + **IMPORTANT:** The value for each field (e.g., "scene", "action") must be a plain string or integer, NOT another JSON object or a description of the field itself. + + Provide the response in the exact JSON format specified by this schema: + {ReviewMetadata.model_json_schema()} + """ logger.info(f"processing {review_data}") logger.info(f"Got GenAI review: {self._send(context_prompt, thumbnails)}")