一键导入
streaming
Guide for assistant-stream package and streaming protocols. Use when implementing streaming backends, custom protocols, or debugging stream issues.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide for assistant-stream package and streaming protocols. Use when implementing streaming backends, custom protocols, or debugging stream issues.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Computer-use capability for Liv AI agents — click, type, screenshot, key, scroll on the LivOS desktop via the Luse MCP server. Use when the task requires direct interaction with a graphical application on the host.
Guide for assistant-cloud persistence and authorization. Use when setting up thread persistence, file uploads, or authentication.
Build generative UI apps with OpenUI and OpenUI Lang — the token-efficient open standard for LLM-generated interfaces. Use when mentioning OpenUI, @openuidev, generative UI, streaming UI from LLMs, component libraries for AI, or replacing json-render/A2UI. Covers scaffolding, defineComponent, system prompts, the Renderer, and debugging OpenUI Lang output.
Guide for assistant-ui UI primitives - ThreadPrimitive, ComposerPrimitive, MessagePrimitive. Use when customizing chat UI components.
Guide for assistant-ui runtime system and state management. Use when working with runtimes, accessing state, or managing thread/message data.
Setup and configure assistant-ui in a project. Use when installing packages, configuring runtimes, setting up chat UI, or troubleshooting setup issues.
| name | streaming |
| description | Guide for assistant-stream package and streaming protocols. Use when implementing streaming backends, custom protocols, or debugging stream issues. |
| version | 0.0.1 |
| license | MIT |
Always consult assistant-ui.com/llms.txt for latest API.
The assistant-stream package handles streaming from AI backends.
Using Vercel AI SDK?
├─ Yes → toUIMessageStreamResponse() (no assistant-stream needed)
└─ No → assistant-stream for custom backends
npm install assistant-stream
import { createAssistantStreamResponse } from "assistant-stream";
export async function POST(req: Request) {
return createAssistantStreamResponse(async (stream) => {
stream.appendText("Hello ");
stream.appendText("world!");
// Tool call example
const tool = stream.addToolCallPart({ toolCallId: "1", toolName: "get_weather" });
tool.argsText.append('{"city":"NYC"}');
tool.argsText.close();
tool.setResponse({ result: { temperature: 22 } });
stream.close();
});
}
useLocalRuntime expects ChatModelRunResult chunks. Yield content parts for streaming:
import { useLocalRuntime } from "@assistant-ui/react";
const runtime = useLocalRuntime({
model: {
async *run({ messages, abortSignal }) {
const response = await fetch("/api/chat", {
method: "POST",
body: JSON.stringify({ messages }),
signal: abortSignal,
});
const reader = response.body?.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (reader) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const parts = buffer.split("\n");
buffer = parts.pop() ?? "";
for (const chunk of parts.filter(Boolean)) {
yield { content: [{ type: "text", text: chunk }] };
}
}
},
},
});
import { AssistantStream, DataStreamDecoder } from "assistant-stream";
const stream = AssistantStream.fromResponse(response, new DataStreamDecoder());
for await (const event of stream) {
console.log("Event:", JSON.stringify(event, null, 2));
}
part-start with part.type = "text" | "reasoning" | "tool-call" | "source" | "file"text-delta with streamed textresult with tool resultsstep-start, step-finish, message-finisherror stringsStream not updating UI
text/event-streamTool calls not rendering
addToolCallPart needs both toolCallId and toolNamemakeAssistantToolUIPartial text not showing
text-delta events for streaming