ollama / ollama/ollama-python

http 104 error

Open
#173 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.5k
Forks
1.2k
Avg merge
4m
Merged PRs (30d)
1

Description

(ragenv) [root@1477dc078bac local-LLM-with-RAG]# python
Python 3.9.19 (main, May  6 2024, 19:43:03) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ollama
>>> response = ollama.chat(model='llama3', messages=[
...   {
...     'role': 'user',
...     'content': 'Why is the sky blue?',
...   },
... ])

Traceback (most recent call last):
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_transports/default.py", line 113, in iter
for part in self._httpcore_stream:
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py", line 367, in iter
raise exc from None
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py", line 363, in iter
for part in self._stream:
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/http11.py", line 349, in iter
raise exc
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/http11.py", line 341, in iter
for chunk in self._connection._receive_response_body(**kwargs):
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/http11.py", line 210, in _receive_response_body
event = self._receive_event(timeout=timeout)
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_sync/http11.py", line 224, in _receive_event
data = self._network_stream.read(
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_backends/sync.py", line 126, in read
return self._sock.recv(max_bytes)
File "/root/anaconda3/envs/ragenv/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 1, in
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/ollama/_client.py", line 177, in chat
return self._request_stream(
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/ollama/_client.py", line 97, in _request_stream
return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/ollama/_client.py", line 68, in _request
response = self._client.request(method, url, **kwargs)
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_client.py", line 827, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_client.py", line 928, in send
raise exc
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_client.py", line 922, in send
response.read()
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_models.py", line 813, in read
self._content = b"".join(self.iter_bytes())
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_models.py", line 829, in iter_bytes
for raw_bytes in self.iter_raw():
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_models.py", line 883, in iter_raw
for raw_stream_bytes in self.stream:
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_client.py", line 126, in iter
for chunk in self._stream:
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_transports/default.py", line 114, in iter
yield part
File "/root/anaconda3/envs/ragenv/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/root/anaconda3/envs/ragenv/lib/python3.9/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadError: [Errno 104] Connection reset by peer

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported ollama.chat call and trace the failure through the client entry points shown in ollama/_client.py, especially _request_stream and _request. Determine whether the connection reset can be consistently attributed to this library, then add a regression test and document the resulting fix or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.