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