Skip to content

Commit

Permalink
_stream in async client raises RuntimeError processing HTTP errors (#266
Browse files Browse the repository at this point in the history
)

Fixes a bug processing errors in async client. When response in _stream has an HTTP error, the process raises a RuntimeError("Attempted to call a sync iterator on an async stream.") due to use of e.response.read() instead of await e.response.aread()
  • Loading branch information
Oneirag authored Aug 29, 2024
1 parent d98f646 commit 81edab1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async def inner():
try:
r.raise_for_status()
except httpx.HTTPStatusError as e:
e.response.read()
await e.response.aread()
raise ResponseError(e.response.text, e.response.status_code) from None

async for line in r.aiter_lines():
Expand Down

0 comments on commit 81edab1

Please sign in to comment.