diff --git a/src/fabledassistant/routes/chat.py b/src/fabledassistant/routes/chat.py index dfe8660..0e554b0 100644 --- a/src/fabledassistant/routes/chat.py +++ b/src/fabledassistant/routes/chat.py @@ -328,7 +328,7 @@ async def chat_status_route(): "default_model": default_model, } try: - async with httpx.AsyncClient(timeout=5.0) as client: + async with httpx.AsyncClient(timeout=10.0) as client: # Query installed models and loaded models in parallel tags_task = asyncio.create_task(client.get(f"{Config.OLLAMA_URL}/api/tags")) ps_task = asyncio.create_task(client.get(f"{Config.OLLAMA_URL}/api/ps")) diff --git a/src/fabledassistant/services/llm.py b/src/fabledassistant/services/llm.py index 5365700..8b41672 100644 --- a/src/fabledassistant/services/llm.py +++ b/src/fabledassistant/services/llm.py @@ -110,7 +110,9 @@ async def stream_chat( if options: merged_options.update(options) payload: dict = {"model": model, "messages": messages, "stream": True, "options": merged_options} - async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=30.0, read=300.0)) as client: + # read=None: no per-chunk timeout — Ollama may pause for any duration while + # processing a large input context before the first token arrives. + async with httpx.AsyncClient(timeout=httpx.Timeout(connect=30.0, read=None, write=None, pool=30.0)) as client: async with client.stream( "POST", f"{Config.OLLAMA_URL}/api/chat", @@ -164,7 +166,8 @@ async def stream_chat_with_tools( } if tools: payload["tools"] = tools - async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=30.0, read=300.0)) as client: + # read=None: no per-chunk timeout for the same reason as stream_chat. + async with httpx.AsyncClient(timeout=httpx.Timeout(connect=30.0, read=None, write=None, pool=30.0)) as client: async with client.stream( "POST", f"{Config.OLLAMA_URL}/api/chat",