forked from Github/frigate
Add ability to restrict genai to objects and zones at the camera level (#13958)
* Add ability to restrict genai to labels and zones at the camera level * fix comment * clarify docs * use objects instead of labels * docs * object list
This commit is contained in:
@@ -810,6 +810,22 @@ class GenAICameraConfig(BaseModel):
|
||||
title="Default caption prompt.",
|
||||
)
|
||||
object_prompts: Dict[str, str] = Field(default={}, title="Object specific prompts.")
|
||||
objects: Union[str, List[str]] = Field(
|
||||
default_factory=list,
|
||||
title="List of objects to run generative AI for.",
|
||||
)
|
||||
required_zones: Union[str, List[str]] = Field(
|
||||
default_factory=list,
|
||||
title="List of required zones to be entered in order to run generative AI.",
|
||||
)
|
||||
|
||||
@field_validator("required_zones", mode="before")
|
||||
@classmethod
|
||||
def validate_required_zones(cls, v):
|
||||
if isinstance(v, str) and "," not in v:
|
||||
return [v]
|
||||
|
||||
return v
|
||||
|
||||
|
||||
class AudioConfig(FrigateBaseModel):
|
||||
|
||||
@@ -127,6 +127,14 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
camera_config.genai.enabled
|
||||
and self.genai_client is not None
|
||||
and event.data.get("description") is None
|
||||
and (
|
||||
camera_config.genai.objects is None
|
||||
or event.label in camera_config.genai.objects
|
||||
)
|
||||
and (
|
||||
camera_config.genai.required_zones is None
|
||||
or set(event.zones) & set(camera_config.genai.required_zones)
|
||||
)
|
||||
):
|
||||
# Generate the description. Call happens in a thread since it is network bound.
|
||||
threading.Thread(
|
||||
|
||||
Reference in New Issue
Block a user