From 81edab1b64b3946c9140d292c728da2e03f77bda Mon Sep 17 00:00:00 2001 From: Oscar Neira Date: Fri, 30 Aug 2024 01:45:57 +0200 Subject: [PATCH] _stream in async client raises RuntimeError processing HTTP errors (#266) 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() --- ollama/_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ollama/_client.py b/ollama/_client.py index 3124a58..ec9acb9 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -495,7 +495,7 @@ class AsyncClient(BaseClient): 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():