From 0ecefa349655369d2722c692d037b5d998c322bb Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 19 Feb 2026 08:13:39 -0700 Subject: [PATCH] Support GenAI for embeddings --- frigate/config/classification.py | 8 ++++---- frigate/config/config.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/frigate/config/classification.py b/frigate/config/classification.py index a1e7b89a5..e507a7817 100644 --- a/frigate/config/classification.py +++ b/frigate/config/classification.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Union from pydantic import ConfigDict, Field @@ -173,10 +173,10 @@ class SemanticSearchConfig(FrigateBaseModel): title="Reindex on startup", description="Trigger a full reindex of historical tracked objects into the embeddings database.", ) - model: Optional[SemanticSearchModelEnum] = Field( + model: Optional[Union[SemanticSearchModelEnum, str]] = Field( default=SemanticSearchModelEnum.jinav1, - title="Semantic search model", - description="The embeddings model to use for semantic search (for example 'jinav1').", + title="Semantic search model or GenAI provider name", + description="The embeddings model to use for semantic search (for example 'jinav1'), or the name of a GenAI provider with the embeddings role.", ) model_size: str = Field( default="small", diff --git a/frigate/config/config.py b/frigate/config/config.py index 7e2d0eddc..0464e8633 100644 --- a/frigate/config/config.py +++ b/frigate/config/config.py @@ -592,6 +592,22 @@ 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 + ): + 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):