featherweight.adapters.agui¶
agui ¶
The AG-UI adapter. The events of a streaming run already are AG-UI's, so this is only the edge with HTTP: read a
request into a ChatInput, and encode the events of a run as server-sent events. No server and no web framework.
parse_request ¶
parse_request(
body: dict[str, Any] | bytes | str,
) -> ChatInput
The JSON body of an AG-UI request (a RunAgentInput) as a ChatInput.
threadId is kept. The client's tools, state, context and forwardedProps are ignored: the agent has its own
tools, and a warning is logged when tools are sent. Raises BadRequest (a ValueError) for a body that is not JSON,
is not a RunAgentInput, or is a conversation a ChatInput refuses (a system or developer message, a last
message that is not the user's).
encode
async
¶
encode(run: StreamingRun) -> AsyncGenerator[str, None]
The events of run as server-sent events, one string each (data: {...} and a blank line), for the body of a
streaming response. Leaving the loop early stops the run.