Timeout error after approximately 10 seconds when running on macOS
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.5k
- Forks
- 1.2k
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
Description
I am encountering a timeout error when running the following code on macOS. The error occurs approximately 10 seconds after the request is made. I would like to know if there is a way to configure or extend the timeout setting to handle longer response times.
Code to Reproduce
import traceback
import time
from ollama import chat
t1 = time.time()
try:
# chat = Client(timeout=60).chat
response = chat(model='llama3', messages=[
{
'role': 'user',
'content': 'why the color of sky is blue?',
},
])
print(response['message']['content'])
except Exception as e:
print("error", e)
traceback.print_exc()
t2 = time.time()
print("cost ", t2-t1)
Error Message
error
cost 10.008436918258667
Traceback (most recent call last):
File "/var/folders/lz/9_t5yfyj6cg79jmhn26qrlcr0000gn/T/ipykernel_22684/1004213980.py", line 10, in <module>
response = chat(model='llama3', messages=[
File "/Users/myp/miniconda3/envs/py38/lib/python3.8/site-packages/ollama/_client.py", line 180, in chat
return self._request_stream(
File "/Users/myp/miniconda3/envs/py38/lib/python3.8/site-packages/ollama/_client.py", line 98, in _request_stream
return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
File "/Users/myp/miniconda3/envs/py38/lib/python3.8/site-packages/ollama/_client.py", line 74, in _request
raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in the issue and inspect ollama/_client.py, especially chat and the request path shown in the traceback. Verify how the timeout is selected and whether the documented Client(timeout=60) usage changes the approximately 10-second failure; done means a longer response can complete without that timeout error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100