Skip to content

Commit d67b97c

Browse files
committed
Improve ollama error messaging (#37)
1 parent 84c2b38 commit d67b97c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/shelloracle/providers/ollama.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ async def generate(self, prompt: str) -> AsyncIterator[str]:
7878
async with httpx.AsyncClient() as client:
7979
async with client.stream("POST", self.endpoint, json=data, timeout=20.0) as stream:
8080
async for line in stream.aiter_lines():
81-
yield json.loads(line)["response"]
81+
response = json.loads(line)
82+
if "error" in response:
83+
raise ProviderError(response["error"])
84+
yield response["response"]
8285
except (httpx.HTTPError, httpx.StreamError) as e:
8386
raise ProviderError(f"Something went wrong while querying Ollama: {e}") from e

0 commit comments

Comments
 (0)