ai: keep slow-CPU chat streams alive

On the FX-8320 the first token took over a minute, and Sanic's default
60-second RESPONSE_TIMEOUT killed the stream before anything was sent.
Raise the timeout above the chat loop's own 600s hard ceiling, and emit
a status event before every model call so the stream is never silent —
for proxies and for the user staring at a slow machine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-27 16:28:04 -06:00
parent 3715c1a45a
commit 3d8ae44fed
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 9 additions and 2 deletions

View file

@ -152,6 +152,9 @@ async def post_chat(request: Request, body: ChatRequest):
return
service.record_llm_activity()
# Always send something before the model call: on slow CPUs the first token can be
# minutes away, and a silent stream looks dead to the UI and to proxies.
await _send_event(response, 'status', dict(message='Thinking…'))
tool_calls = []
final_answer = []
async for event in llama_chat_stream(messages, tools):