diff --git a/AGENTS.md b/AGENTS.md index 083bc0ae54..2008cddb1a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ This document provides coding guidelines and best practices for contributing to Frigate NVR is a realtime object detection system for IP cameras that uses: -- **Backend**: Python 3.13+ with FastAPI, OpenCV, TensorFlow/ONNX +- **Backend**: Python 3.11 with FastAPI, OpenCV, TensorFlow/ONNX - **Frontend**: React with TypeScript, Vite, TailwindCSS - **Architecture**: Multiprocessing design with ZMQ and MQTT communication - **Focus**: Minimal resource usage with maximum performance @@ -23,7 +23,7 @@ When reviewing code, do NOT comment on: ### Python Requirements -- **Compatibility**: Python 3.13+ +- **Compatibility**: Python 3.11 (the version in the Docker image) - **Language Features**: Use modern Python features: - Pattern matching - Type hints (comprehensive typing preferred) @@ -97,11 +97,12 @@ When reviewing code, do NOT comment on: ### Async Programming -- **External I/O**: All external I/O operations must be async -- **Best Practices**: - - Avoid sleeping in loops - use `asyncio.sleep()` not `time.sleep()` +- **Scope**: Frigate is mostly synchronous multiprocess code, and most API handlers are plain `def` running in FastAPI's threadpool. These rules apply to code that is already `async def`. +- **Blocking I/O**: A handler that does blocking work (peewee queries, `requests`, subprocess) should be a plain `def`, not an `async def` that blocks the event loop +- **Best Practices** (inside `async def`): + - Use `asyncio.sleep()`, not `time.sleep()` - Avoid awaiting in loops - use `asyncio.gather()` instead - - No blocking calls in async functions + - No blocking calls - Use `asyncio.create_task()` for background operations - **Thread Safety**: Use proper synchronization for shared state diff --git a/frigate/embeddings/genai_embedding.py b/frigate/embeddings/genai_embedding.py index d3637bb73b..88d7cd8b54 100644 --- a/frigate/embeddings/genai_embedding.py +++ b/frigate/embeddings/genai_embedding.py @@ -68,6 +68,10 @@ class GenAIEmbedding: f"Invalid embedding_type '{embedding_type}'. Must be 'text' or 'vision'." ) + # Callers index the result, so an empty provider response must raise + if not embeddings: + raise ValueError(f"Empty {embedding_type} embedding response from provider") + result = [] for emb in embeddings: arr = np.asarray(emb, dtype=np.float32) diff --git a/web/public/locales/en/common.json b/web/public/locales/en/common.json index 85204bddec..2ae848ee81 100644 --- a/web/public/locales/en/common.json +++ b/web/public/locales/en/common.json @@ -216,6 +216,7 @@ "hr": "Hrvatski (Croatian)", "bs": "Bosanski (Bosnian)", "sr": "Српски (Serbian)", + "srLatn": "Srpski (Serbian, Latin)", "sl": "Slovenščina (Slovenian)", "lt": "Lietuvių (Lithuanian)", "bg": "Български (Bulgarian)", diff --git a/web/public/locales/sr_Latn/audio.json b/web/public/locales/sr-Latn/audio.json similarity index 100% rename from web/public/locales/sr_Latn/audio.json rename to web/public/locales/sr-Latn/audio.json diff --git a/web/public/locales/sr_Latn/components/auth.json b/web/public/locales/sr-Latn/components/auth.json similarity index 100% rename from web/public/locales/sr_Latn/components/auth.json rename to web/public/locales/sr-Latn/components/auth.json diff --git a/web/public/locales/sr_Latn/components/icons.json b/web/public/locales/sr-Latn/components/icons.json similarity index 100% rename from web/public/locales/sr_Latn/components/icons.json rename to web/public/locales/sr-Latn/components/icons.json diff --git a/web/public/locales/sr_Latn/components/input.json b/web/public/locales/sr-Latn/components/input.json similarity index 100% rename from web/public/locales/sr_Latn/components/input.json rename to web/public/locales/sr-Latn/components/input.json diff --git a/web/public/locales/sr_Latn/config/cameras.json b/web/public/locales/sr-Latn/config/cameras.json similarity index 100% rename from web/public/locales/sr_Latn/config/cameras.json rename to web/public/locales/sr-Latn/config/cameras.json diff --git a/web/public/locales/sr_Latn/config/global.json b/web/public/locales/sr-Latn/config/global.json similarity index 100% rename from web/public/locales/sr_Latn/config/global.json rename to web/public/locales/sr-Latn/config/global.json diff --git a/web/public/locales/sr_Latn/config/groups.json b/web/public/locales/sr-Latn/config/groups.json similarity index 100% rename from web/public/locales/sr_Latn/config/groups.json rename to web/public/locales/sr-Latn/config/groups.json diff --git a/web/public/locales/sr_Latn/objects.json b/web/public/locales/sr-Latn/objects.json similarity index 100% rename from web/public/locales/sr_Latn/objects.json rename to web/public/locales/sr-Latn/objects.json diff --git a/web/public/locales/sr_Latn/views/chat.json b/web/public/locales/sr-Latn/views/chat.json similarity index 100% rename from web/public/locales/sr_Latn/views/chat.json rename to web/public/locales/sr-Latn/views/chat.json diff --git a/web/public/locales/sr_Latn/views/configEditor.json b/web/public/locales/sr-Latn/views/configEditor.json similarity index 100% rename from web/public/locales/sr_Latn/views/configEditor.json rename to web/public/locales/sr-Latn/views/configEditor.json diff --git a/web/public/locales/sr_Latn/views/events.json b/web/public/locales/sr-Latn/views/events.json similarity index 100% rename from web/public/locales/sr_Latn/views/events.json rename to web/public/locales/sr-Latn/views/events.json diff --git a/web/public/locales/sr_Latn/views/recording.json b/web/public/locales/sr-Latn/views/recording.json similarity index 100% rename from web/public/locales/sr_Latn/views/recording.json rename to web/public/locales/sr-Latn/views/recording.json diff --git a/web/src/components/menu/GeneralSettings.tsx b/web/src/components/menu/GeneralSettings.tsx index 6ae862f092..d316d50432 100644 --- a/web/src/components/menu/GeneralSettings.tsx +++ b/web/src/components/menu/GeneralSettings.tsx @@ -115,6 +115,7 @@ export default function GeneralSettings({ "zh-CN": "zhCN", "zh-Hant": "zhHant", "pt-BR": "ptBR", + "sr-Latn": "srLatn", }; return supportedLanguageKeys.map((key) => { diff --git a/web/src/hooks/use-date-locale.ts b/web/src/hooks/use-date-locale.ts index b8f1bd9cdd..5d137b293a 100644 --- a/web/src/hooks/use-date-locale.ts +++ b/web/src/hooks/use-date-locale.ts @@ -42,6 +42,8 @@ const localeMap: Record Promise> = { ca: () => import("date-fns/locale/ca").then((module) => module.ca), hr: () => import("date-fns/locale/hr").then((module) => module.hr), bs: () => import("date-fns/locale/bs").then((module) => module.bs), + "sr-Latn": () => + import("date-fns/locale/sr-Latn").then((module) => module.srLatn), sl: () => import("date-fns/locale/sl").then((module) => module.sl), }; diff --git a/web/src/lib/const.ts b/web/src/lib/const.ts index c15bdadc96..ad5c4acc6e 100644 --- a/web/src/lib/const.ts +++ b/web/src/lib/const.ts @@ -42,6 +42,7 @@ export const supportedLanguageKeys = [ "pl", "hr", "bs", + "sr-Latn", "sk", "sl", "lt",