Improve model status indicators and tune timeouts
Green/red emoji circles replace Unicode symbols for at-a-glance model readiness. Increase connect timeouts (10→30s) for cold model loading, warm timeout (120→300s) for large models, and pull timeout (600→1800s) to match route-level limit. Show error toast on SSE reconnection failure instead of silently recovering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -269,7 +269,7 @@ async def warm_model_route():
|
||||
|
||||
async def _warm():
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=120.0) as client:
|
||||
async with httpx.AsyncClient(timeout=300.0) as client:
|
||||
await client.post(
|
||||
f"{Config.OLLAMA_URL}/api/generate",
|
||||
json={"model": model, "prompt": "", "keep_alive": "30m"},
|
||||
|
||||
@@ -54,7 +54,7 @@ async def ensure_model(model: str) -> None:
|
||||
|
||||
logger.info("Pulling model '%s' from Ollama...", model)
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=600.0) as client:
|
||||
async with httpx.AsyncClient(timeout=1800.0) as client:
|
||||
async with client.stream(
|
||||
"POST",
|
||||
f"{Config.OLLAMA_URL}/api/pull",
|
||||
@@ -80,7 +80,7 @@ async def stream_chat(
|
||||
payload: dict = {"model": model, "messages": messages, "stream": True}
|
||||
if options:
|
||||
payload["options"] = options
|
||||
async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=10.0, read=300.0)) as client:
|
||||
async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=30.0, read=300.0)) as client:
|
||||
async with client.stream(
|
||||
"POST",
|
||||
f"{Config.OLLAMA_URL}/api/chat",
|
||||
@@ -100,7 +100,7 @@ async def stream_chat(
|
||||
|
||||
async def generate_completion(messages: list[dict], model: str) -> str:
|
||||
"""Non-streaming chat completion, returns full response text."""
|
||||
async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=10.0, read=300.0)) as client:
|
||||
async with httpx.AsyncClient(timeout=httpx.Timeout(1800.0, connect=30.0, read=300.0)) as client:
|
||||
resp = await client.post(
|
||||
f"{Config.OLLAMA_URL}/api/chat",
|
||||
json={"model": model, "messages": messages, "stream": False},
|
||||
|
||||
Reference in New Issue
Block a user