Assistant streams its answer token by token

ai/client.py streams the completion and puts the chunks back together
(Assembler), covering OpenAI's piecewise tool-call arguments, Ollama's whole
calls, OpenRouter's comment lines, unnumbered calls and in-stream errors.
The turn emits a delta event per piece and a message per round as before,
and the chat grows the last answer as deltas arrive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
2026-10-15 17:37:56 +02:00
co-authored by Claude Opus 5.5
parent 429100a0c7
commit 58b92da8b0
8 changed files with 243 additions and 32 deletions
+3 -2
View File
@@ -259,8 +259,9 @@ def chat(
) -> StreamingResponse:
"""One turn, streamed as server-sent events.
``message``, ``tool_call`` and ``tool_result`` events as the model works,
``error`` when something stops it, and ``done`` last either way.
``delta`` as the model writes, ``message`` with a round's whole text,
``tool_call`` and ``tool_result`` as it works, ``error`` when something
stops it, and ``done`` last either way.
"""
config = ai_config.load()
if config is None or not config.ready: