用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/vercel-labs/seal --skill ai-python-ui-adapter命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when building custom agent loops. Modify tool dispatch, history management, hooks, control flow.
Use for implementing custom providers in AI SDK for Python.
Use when adding durable execution to AI SDK for Python, building durable agent loops, or serializing messages across workflow steps.
基于 SOC 职业分类
正在显示 SKILL.md
| name | ai-python-ui-adapter |
| description | Use when connecting AI SDK for Python streams to AI SDK UI useChat clients. |
| metadata | {"sdk-version":"0.2.1"} |
Frontend:
const chat = useChat({
transport: new DefaultChatTransport({ api: "/api/chat" }),
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses,
});
Use chat.sendMessage(...) to send user input. Use
chat.addToolApprovalResponse(...) from approval buttons.
Backend request:
class ChatRequest(pydantic.BaseModel):
messages: list[ai.agents.ui.ai_sdk.UIMessage]
messages, approvals = ai.agents.ui.ai_sdk.to_messages(request.messages)
ai.agents.ui.ai_sdk.apply_approvals(approvals)
Backend stream:
async def body():
async with agent.run(model, messages) as stream:
async def events():
async for event in stream:
if (
isinstance(event, ai.events.HookEvent)
and event.hook.status == "pending"
):
ai.defer_hook(event.hook)
yield event
async for chunk in ai.agents.ui.ai_sdk.to_sse(events()):
yield chunk
return StreamingResponse(
body(),
headers=ai.agents.ui.ai_sdk.UI_MESSAGE_STREAM_HEADERS,
)
The adapter handles UIMessage parsing, message IDs, tool state, approvals,
subagent MessageBundle values, and AI SDK UI stream events.
You handle the HTTP route, auth, storage, session lookup, frontend rendering, and when to defer hooks.
For saved UI history, use:
ui_messages = ai.agents.ui.ai_sdk.to_ui_messages(messages)