mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 14:47:40 +03:00
Enable genai mypy and fix type issues
This commit is contained in:
parent
3f6d5bcf22
commit
0f3b351cf9
@ -5,7 +5,7 @@ import importlib
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
import numpy as np
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
@ -31,10 +31,10 @@ __all__ = [
|
||||
PROVIDERS = {}
|
||||
|
||||
|
||||
def register_genai_provider(key: GenAIProviderEnum):
|
||||
def register_genai_provider(key: GenAIProviderEnum) -> Callable:
|
||||
"""Register a GenAI provider."""
|
||||
|
||||
def decorator(cls):
|
||||
def decorator(cls: type) -> type:
|
||||
PROVIDERS[key] = cls
|
||||
return cls
|
||||
|
||||
@ -297,7 +297,7 @@ Guidelines:
|
||||
"""Generate a description for the frame."""
|
||||
try:
|
||||
prompt = camera_config.objects.genai.object_prompts.get(
|
||||
event.label,
|
||||
str(event.label),
|
||||
camera_config.objects.genai.prompt,
|
||||
).format(**model_to_dict(event))
|
||||
except KeyError as e:
|
||||
@ -307,7 +307,7 @@ Guidelines:
|
||||
logger.debug(f"Sending images to genai provider with prompt: {prompt}")
|
||||
return self._send(prompt, thumbnails)
|
||||
|
||||
def _init_provider(self):
|
||||
def _init_provider(self) -> Any:
|
||||
"""Initialize the client."""
|
||||
return None
|
||||
|
||||
@ -402,7 +402,7 @@ Guidelines:
|
||||
}
|
||||
|
||||
|
||||
def load_providers():
|
||||
def load_providers() -> None:
|
||||
package_dir = os.path.dirname(__file__)
|
||||
for filename in os.listdir(package_dir):
|
||||
if filename.endswith(".py") and filename != "__init__.py":
|
||||
|
||||
@ -41,6 +41,9 @@ ignore_errors = false
|
||||
[mypy-frigate.events]
|
||||
ignore_errors = false
|
||||
|
||||
[mypy-frigate.genai]
|
||||
ignore_errors = false
|
||||
|
||||
[mypy-frigate.log]
|
||||
ignore_errors = false
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user