diff --git a/frigate/genai/ollama.py b/frigate/genai/ollama.py index 30247e31c..5e51de085 100644 --- a/frigate/genai/ollama.py +++ b/frigate/genai/ollama.py @@ -1,7 +1,7 @@ """Ollama Provider for Frigate AI.""" import logging -from typing import Optional +from typing import Any, Optional from httpx import TimeoutException from ollama import Client as ApiClient @@ -17,10 +17,24 @@ logger = logging.getLogger(__name__) class OllamaClient(GenAIClient): """Generative AI client for Frigate using Ollama.""" + LOCAL_OPTIMIZED_OPTIONS = { + "options": { + "temperature": 0.5, + "repeat_penalty": 1.15, + "presence_penalty": 0.1, + }, + } + provider: ApiClient + provider_options: dict[str, Any] def _init_provider(self): """Initialize the client.""" + self.provider_options = { + **self.LOCAL_OPTIMIZED_OPTIONS, + **self.genai_config.provider_options, + } + try: client = ApiClient(host=self.genai_config.base_url, timeout=self.timeout) # ensure the model is available locally @@ -48,7 +62,7 @@ class OllamaClient(GenAIClient): self.genai_config.model, prompt, images=images if images else None, - **self.genai_config.provider_options, + **self.provider_options, ) return result["response"].strip() except (TimeoutException, ResponseError) as e: