mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 09:02:15 +03:00
Support using GenAI for embeddings / semantic search (#22323)
* Support GenAI for embeddings * Add embed API support * Add support for embedding via genai * Basic docs * undo * Fix sending images * Don't require download check * Set model * Handle emb correctly * Clarification * Cleanup * Cleanup
This commit is contained in:
@@ -61,6 +61,7 @@ from .classification import (
|
||||
FaceRecognitionConfig,
|
||||
LicensePlateRecognitionConfig,
|
||||
SemanticSearchConfig,
|
||||
SemanticSearchModelEnum,
|
||||
)
|
||||
from .database import DatabaseConfig
|
||||
from .env import EnvVars
|
||||
@@ -592,6 +593,24 @@ class FrigateConfig(FrigateBaseModel):
|
||||
)
|
||||
role_to_name[role] = name
|
||||
|
||||
# validate semantic_search.model when it is a GenAI provider name
|
||||
if (
|
||||
self.semantic_search.enabled
|
||||
and isinstance(self.semantic_search.model, str)
|
||||
and not isinstance(self.semantic_search.model, SemanticSearchModelEnum)
|
||||
):
|
||||
if self.semantic_search.model not in self.genai:
|
||||
raise ValueError(
|
||||
f"semantic_search.model '{self.semantic_search.model}' is not a "
|
||||
"valid GenAI config key. Must match a key in genai config."
|
||||
)
|
||||
genai_cfg = self.genai[self.semantic_search.model]
|
||||
if GenAIRoleEnum.embeddings not in genai_cfg.roles:
|
||||
raise ValueError(
|
||||
f"GenAI provider '{self.semantic_search.model}' must have "
|
||||
"'embeddings' in its roles for semantic search."
|
||||
)
|
||||
|
||||
# set default min_score for object attributes
|
||||
for attribute in self.model.all_attributes:
|
||||
if not self.objects.filters.get(attribute):
|
||||
|
||||
Reference in New Issue
Block a user