ollama / ollama-python

Ollama Python library
https://ollama.com
MIT License
2.67k stars 220 forks source link

http 104 error #173

Open zwshan opened 3 weeks ago

zwshan commented 3 weeks ago
(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

zwshan commented 3 weeks ago

but the ollama GO language version runs ok on my machine