Open m358807551 opened 4 months ago
The only way to configure the timeout
seems to be passing the timeout param here.
A walkaround can be initialising a new Client
with a timeout param, and use the new client to call apis.
import traceback
import time
# from ollama import chat
from ollama import Client
t1 = time.time()
try:
chat = Client(timeout=1).chat # new client with timeout 1s
response = chat(model='gemma2:2b', 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)
httpx.ReadTimeout: timed out
cost 1.0301549434661865
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
Error Message