module
chat.stream
Functions
M.content
Build a typed-chunk constructor of the right shape.
M.content(text)
textstring
→ table
M.thinking
M.thinking(text)
textstring
→ table
M.tool_call_delta
M.tool_call_delta(call_id, name, args_partial)
call_idstring
namestring?
args_partialstring
→ table
M.tool_call_done
M.tool_call_done(call_id, call)
call_idstring
calltable`{ id, name, arguments }`
→ table
M.stop
M.stop(reason)
reasonstring`"stop" | "length" | "stop_string" | "tool_use" | "error"`
→ table
M.collect
Materialise an entire chunk stream into a `Response`-shaped table. The caller passes the iterator returned by `engine:stream` and receives a synthesised `{ content, thinking, tool_calls, ... }` view, identical in shape to what `engine:chat` would return. Useful when a consumer wired itself to the typed stream and still needs the post-generation summary (logging, persistence).
M.collect(iter)
iterfunctionCoroutine iterator yielding chunks.
→ table`{ content, thinking, tool_calls, stop_reason }`