Catch remote protocol error from ollama

This commit is contained in:
Nicolas Mowen 2025-12-24 06:35:04 -07:00
parent 6dfc9cbf0f
commit a59515a74b

View File

@ -3,7 +3,7 @@
import logging import logging
from typing import Any, Optional from typing import Any, Optional
from httpx import TimeoutException from httpx import RemoteProtocolError, TimeoutException
from ollama import Client as ApiClient from ollama import Client as ApiClient
from ollama import ResponseError from ollama import ResponseError
@ -68,7 +68,12 @@ class OllamaClient(GenAIClient):
f"Ollama tokens used: eval_count={result.get('eval_count')}, prompt_eval_count={result.get('prompt_eval_count')}" f"Ollama tokens used: eval_count={result.get('eval_count')}, prompt_eval_count={result.get('prompt_eval_count')}"
) )
return result["response"].strip() return result["response"].strip()
except (TimeoutException, ResponseError, ConnectionError) as e: except (
TimeoutException,
ResponseError,
RemoteProtocolError,
ConnectionError,
) as e:
logger.warning("Ollama returned an error: %s", str(e)) logger.warning("Ollama returned an error: %s", str(e))
return None return None