mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-07 02:18:07 +01:00
Add config for users to define additional concerns that GenAI should make note of in review summary (#19463)
* Don't default to openai * Improve UI * Allow configuring additional concerns that users may want the AI to note * Formatting * Add preferred language config * Remove unused
This commit is contained in:
committed by
Blake Blackshear
parent
3cf86767f1
commit
cc18d7f786
@@ -46,8 +46,9 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
return
|
||||
|
||||
camera = data["after"]["camera"]
|
||||
camera_config = self.config.cameras[camera]
|
||||
|
||||
if not self.config.cameras[camera].review.genai.enabled:
|
||||
if not camera_config.review.genai.enabled:
|
||||
return
|
||||
|
||||
id = data["after"]["id"]
|
||||
@@ -59,12 +60,12 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
|
||||
if (
|
||||
final_data["severity"] == "alert"
|
||||
and not self.config.cameras[camera].review.genai.alerts
|
||||
and not camera_config.review.genai.alerts
|
||||
):
|
||||
return
|
||||
elif (
|
||||
final_data["severity"] == "detection"
|
||||
and not self.config.cameras[camera].review.genai.detections
|
||||
and not camera_config.review.genai.detections
|
||||
):
|
||||
return
|
||||
|
||||
@@ -86,9 +87,7 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
if ret:
|
||||
thumbs.append(jpg.tobytes())
|
||||
|
||||
if self.config.cameras[
|
||||
data["after"]["camera"]
|
||||
].review.genai.debug_save_thumbnails:
|
||||
if camera_config.review.genai.debug_save_thumbnails:
|
||||
id = data["after"]["id"]
|
||||
Path(os.path.join(CLIPS_DIR, f"genai-requests/{id}")).mkdir(
|
||||
parents=True, exist_ok=True
|
||||
@@ -112,6 +111,8 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
camera,
|
||||
final_data,
|
||||
thumbs,
|
||||
camera_config.review.genai.additional_concerns,
|
||||
camera_config.review.genai.preferred_language,
|
||||
),
|
||||
).start()
|
||||
|
||||
@@ -161,6 +162,8 @@ def run_analysis(
|
||||
camera: str,
|
||||
final_data: dict[str, str],
|
||||
thumbs: list[bytes],
|
||||
concerns: list[str],
|
||||
preferred_language: str | None,
|
||||
) -> None:
|
||||
start = datetime.datetime.now().timestamp()
|
||||
metadata = genai_client.generate_review_description(
|
||||
@@ -172,6 +175,8 @@ def run_analysis(
|
||||
"timestamp": datetime.datetime.fromtimestamp(final_data["end_time"]),
|
||||
},
|
||||
thumbs,
|
||||
concerns,
|
||||
preferred_language,
|
||||
)
|
||||
review_inference_speed.update(datetime.datetime.now().timestamp() - start)
|
||||
|
||||
|
||||
@@ -13,3 +13,7 @@ class ReviewMetadata(BaseModel):
|
||||
le=3,
|
||||
description="An integer representing the potential threat level (1-3). 1: Minor anomaly. 2: Moderate concern. 3: High threat. Only include this field if a clear security concern is observable; otherwise, omit it.",
|
||||
)
|
||||
other_concerns: list[str] | None = Field(
|
||||
default=None,
|
||||
description="Other concerns highlighted by the user that are observed.",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user