diff --git a/frigate/genai/gemini.py b/frigate/genai/gemini.py index f5b7bd2df..750454e25 100644 --- a/frigate/genai/gemini.py +++ b/frigate/genai/gemini.py @@ -1,5 +1,6 @@ """Gemini Provider for Frigate AI.""" +import logging from typing import Optional import google.generativeai as genai @@ -8,6 +9,8 @@ from google.api_core.exceptions import GoogleAPICallError from frigate.config import GenAIProviderEnum from frigate.genai import GenAIClient, register_genai_provider +logger = logging.getLogger(__name__) + @register_genai_provider(GenAIProviderEnum.gemini) class GeminiClient(GenAIClient): @@ -39,7 +42,8 @@ class GeminiClient(GenAIClient): timeout=self.timeout, ), ) - except GoogleAPICallError: + except GoogleAPICallError as e: + logger.warning("Gemini returned an error: %s", str(e)) return None try: description = response.text.strip() diff --git a/frigate/genai/ollama.py b/frigate/genai/ollama.py index 09bcad0c5..ae62208cb 100644 --- a/frigate/genai/ollama.py +++ b/frigate/genai/ollama.py @@ -37,5 +37,6 @@ class OllamaClient(GenAIClient): images=images, ) return result["response"].strip() - except (TimeoutException, ResponseError): + except (TimeoutException, ResponseError) as e: + logger.warning("Ollama returned an error: %s", str(e)) return None diff --git a/frigate/genai/openai.py b/frigate/genai/openai.py index d0178df8b..4568905a3 100644 --- a/frigate/genai/openai.py +++ b/frigate/genai/openai.py @@ -1,6 +1,7 @@ """OpenAI Provider for Frigate AI.""" import base64 +import logging from typing import Optional from httpx import TimeoutException @@ -9,6 +10,8 @@ from openai import OpenAI from frigate.config import GenAIProviderEnum from frigate.genai import GenAIClient, register_genai_provider +logger = logging.getLogger(__name__) + @register_genai_provider(GenAIProviderEnum.openai) class OpenAIClient(GenAIClient): @@ -44,7 +47,8 @@ class OpenAIClient(GenAIClient): ], timeout=self.timeout, ) - except TimeoutException: + except TimeoutException as e: + logger.warning("OpenAI returned an error: %s", str(e)) return None if len(result.choices) > 0: return result.choices[0].message.content.strip()