async stream chat *just don't work* (tm) #113

Closed
opened 2026-02-15 16:28:03 -05:00 by yindo · 0 comments
Owner

Originally created by @lmaddox on GitHub (Jul 20, 2024).

Steps to reproduce:
1 copy and paste the code from the tutorial/example
2 then run the file without modifications
source

Traceback (most recent call last):
  File "/home/miller/.local/lib/python3.11/site-packages/ollama/_client.py", line 364, in inner
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/httpx/_models.py", line 761, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://kali.innovanon.com:11434/api/chat'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lmaddox/innovanon.git/./fuck.py", line 59, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/lmaddox/innovanon.git/./fuck.py", line 39, in main
    async for response in await client.chat(model='mistral', messages=messages, stream=True):
  File "/home/miller/.local/lib/python3.11/site-packages/ollama/_client.py", line 366, in inner
    e.response.read()
  File "/usr/lib/python3/dist-packages/httpx/_models.py", line 813, in read
    self._content = b"".join(self.iter_bytes())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/httpx/_models.py", line 829, in iter_bytes
    for raw_bytes in self.iter_raw():
  File "/usr/lib/python3/dist-packages/httpx/_models.py", line 876, in iter_raw
    raise RuntimeError("Attempted to call a sync iterator on an async stream.")
RuntimeError: Attempted to call a sync iterator on an async stream.

update:

curl http://kali.innovanon.com:11434                   
Ollama is running

curl http://kali.innovanon.com:11434/api/chat          
404 page not found

update (the you.com llm told me to pull the model server-side; it works now):

pull mistral

source

Originally created by @lmaddox on GitHub (Jul 20, 2024). Steps to reproduce: 1 copy and paste the code from the tutorial/example 2 then run the file without modifications [source](https://github.com/ollama/ollama-python/blob/main/examples/async-chat-stream/main.py) ``` Traceback (most recent call last): File "/home/miller/.local/lib/python3.11/site-packages/ollama/_client.py", line 364, in inner r.raise_for_status() File "/usr/lib/python3/dist-packages/httpx/_models.py", line 761, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://kali.innovanon.com:11434/api/chat' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/lmaddox/innovanon.git/./fuck.py", line 59, in <module> asyncio.run(main()) File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/lmaddox/innovanon.git/./fuck.py", line 39, in main async for response in await client.chat(model='mistral', messages=messages, stream=True): File "/home/miller/.local/lib/python3.11/site-packages/ollama/_client.py", line 366, in inner e.response.read() File "/usr/lib/python3/dist-packages/httpx/_models.py", line 813, in read self._content = b"".join(self.iter_bytes()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/httpx/_models.py", line 829, in iter_bytes for raw_bytes in self.iter_raw(): File "/usr/lib/python3/dist-packages/httpx/_models.py", line 876, in iter_raw raise RuntimeError("Attempted to call a sync iterator on an async stream.") RuntimeError: Attempted to call a sync iterator on an async stream. ``` update: ``` curl http://kali.innovanon.com:11434 Ollama is running curl http://kali.innovanon.com:11434/api/chat 404 page not found ``` update (the you.com llm told me to pull the model server-side; it works now): ``` pull mistral ``` [source](https://github.com/ollama/ollama-python?tab=readme-ov-file#errors)
yindo closed this issue 2026-02-15 16:28:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#113