mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
add try/except around ollama initialization
This commit is contained in:
parent
8002e59031
commit
059475e6bb
@ -21,12 +21,20 @@ class OllamaClient(GenAIClient):
|
|||||||
|
|
||||||
def _init_provider(self):
|
def _init_provider(self):
|
||||||
"""Initialize the client."""
|
"""Initialize the client."""
|
||||||
|
try:
|
||||||
client = ApiClient(host=self.genai_config.base_url, timeout=self.timeout)
|
client = ApiClient(host=self.genai_config.base_url, timeout=self.timeout)
|
||||||
response = client.pull(self.genai_config.model)
|
# ensure the model is available locally
|
||||||
if response["status"] != "success":
|
response = client.show(self.genai_config.model)
|
||||||
logger.error("Failed to pull %s model from Ollama", self.genai_config.model)
|
if response.get("error"):
|
||||||
|
logger.error(
|
||||||
|
"Ollama error: %s",
|
||||||
|
response["error"],
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
return client
|
return client
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Error initializing Ollama: %s", str(e))
|
||||||
|
return None
|
||||||
|
|
||||||
def _send(self, prompt: str, images: list[bytes]) -> Optional[str]:
|
def _send(self, prompt: str, images: list[bytes]) -> Optional[str]:
|
||||||
"""Submit a request to Ollama"""
|
"""Submit a request to Ollama"""
|
||||||
|
Loading…
Reference in New Issue
Block a user