mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
Fix genai init when disabled at global level
This commit is contained in:
parent
3249ffb273
commit
6234121699
@ -62,7 +62,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
self.requestor = InterProcessRequestor()
|
self.requestor = InterProcessRequestor()
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.tracked_events = {}
|
self.tracked_events = {}
|
||||||
self.genai_client = get_genai_client(config.genai)
|
self.genai_client = get_genai_client(config)
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
"""Maintain a SQLite-vec database for semantic search."""
|
"""Maintain a SQLite-vec database for semantic search."""
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from playhouse.shortcuts import model_to_dict
|
from playhouse.shortcuts import model_to_dict
|
||||||
|
|
||||||
from frigate.config import CameraConfig, GenAIConfig, GenAIProviderEnum
|
from frigate.config import CameraConfig, FrigateConfig, GenAIProviderEnum
|
||||||
from frigate.models import Event
|
from frigate.models import Event
|
||||||
|
|
||||||
PROVIDERS = {}
|
PROVIDERS = {}
|
||||||
@ -25,8 +25,8 @@ def register_genai_provider(key: GenAIProviderEnum):
|
|||||||
class GenAIClient:
|
class GenAIClient:
|
||||||
"""Generative AI client for Frigate."""
|
"""Generative AI client for Frigate."""
|
||||||
|
|
||||||
def __init__(self, genai_config: GenAIConfig, timeout: int = 60) -> None:
|
def __init__(self, config: FrigateConfig, timeout: int = 60) -> None:
|
||||||
self.genai_config: GenAIConfig = genai_config
|
self.config: FrigateConfig = config
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.provider = self._init_provider()
|
self.provider = self._init_provider()
|
||||||
|
|
||||||
@ -52,12 +52,19 @@ class GenAIClient:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_genai_client(genai_config: GenAIConfig) -> Optional[GenAIClient]:
|
def get_genai_client(config: FrigateConfig) -> Optional[GenAIClient]:
|
||||||
"""Get the GenAI client."""
|
"""Get the GenAI client."""
|
||||||
|
genai_config = config.genai
|
||||||
|
genai_cameras = [
|
||||||
|
c for c in config.cameras.values() if c.enabled and c.genai.enabled
|
||||||
|
]
|
||||||
|
|
||||||
|
if genai_cameras:
|
||||||
load_providers()
|
load_providers()
|
||||||
provider = PROVIDERS.get(genai_config.provider)
|
provider = PROVIDERS.get(genai_config.provider)
|
||||||
if provider:
|
if provider:
|
||||||
return provider(genai_config)
|
return provider(genai_config)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user