agent-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent Component
Agent Component

Batteries-included agent component from ui.inference.sh.

来自ui.inference.sh的开箱即用Agent组件。
Quick Start
快速开始
bash
undefinedbash
undefinedInstall the agent component
安装Agent组件
npx shadcn@latest add https://ui.inference.sh/r/agent.json
npx shadcn@latest add https://ui.inference.sh/r/agent.json
Add the SDK for the proxy route
为代理路由添加SDK
npm install @inferencesh/sdk
undefinednpm install @inferencesh/sdk
undefinedSetup
设置
1. API Proxy Route (Next.js)
1. API代理路由(Next.js)
typescript
// app/api/inference/proxy/route.ts
import { route } from '@inferencesh/sdk/proxy/nextjs';
export const { GET, POST, PUT } = route;typescript
// app/api/inference/proxy/route.ts
import { route } from '@inferencesh/sdk/proxy/nextjs';
export const { GET, POST, PUT } = route;2. Environment Variable
2. 环境变量
bash
undefinedbash
undefined.env.local
.env.local
INFERENCE_API_KEY=inf_...
undefinedINFERENCE_API_KEY=inf_...
undefined3. Use the Component
3. 使用组件
tsx
import { Agent } from "@/registry/blocks/agent/agent"
export default function Page() {
return (
<Agent
proxyUrl="/api/inference/proxy"
agentConfig={{
core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
description: 'a helpful ai assistant',
system_prompt: 'you are helpful.',
}}
/>
)
}tsx
import { Agent } from "@/registry/blocks/agent/agent"
export default function Page() {
return (
<Agent
proxyUrl="/api/inference/proxy"
agentConfig={{
core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
description: 'a helpful ai assistant',
system_prompt: 'you are helpful.',
}}
/>
)
}Features
功能特性
| Feature | Description |
|---|---|
| Runtime included | No backend logic needed |
| Tool lifecycle | Pending, progress, approval, results |
| Human-in-the-loop | Built-in approval flows |
| Widgets | Declarative JSON UI from agent responses |
| Streaming | Real-time token streaming |
| Client-side tools | Tools that run in the browser |
| 功能 | 描述 |
|---|---|
| 内置运行时 | 无需后端逻辑 |
| 工具生命周期 | 待处理、执行中、审批、结果反馈 |
| 人机协同 | 内置审批流程 |
| 小组件 | 基于Agent响应生成声明式JSON UI |
| 流处理 | 实时令牌流传输 |
| 客户端工具 | 在浏览器中运行的工具 |
Client-Side Tools Example
客户端工具示例
tsx
import { Agent } from "@/registry/blocks/agent/agent"
import { createScopedTools } from "./blocks/agent/lib/client-tools"
const formRef = useRef<HTMLFormElement>(null)
const scopedTools = createScopedTools(formRef)
<Agent
proxyUrl="/api/inference/proxy"
config={{
core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
tools: scopedTools,
system_prompt: 'You can fill forms using scan_ui and fill_field tools.',
}}
/>tsx
import { Agent } from "@/registry/blocks/agent/agent"
import { createScopedTools } from "./blocks/agent/lib/client-tools"
const formRef = useRef<HTMLFormElement>(null)
const scopedTools = createScopedTools(formRef)
<Agent
proxyUrl="/api/inference/proxy"
config={{
core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
tools: scopedTools,
system_prompt: 'You can fill forms using scan_ui and fill_field tools.',
}}
/>Props
组件属性
| Prop | Type | Description |
|---|---|---|
| string | API proxy endpoint |
| string | Agent name (optional) |
| AgentConfig | Agent configuration |
| boolean | Enable file uploads |
| boolean | Enable image uploads |
| 属性 | 类型 | 描述 |
|---|---|---|
| string | API代理端点 |
| string | Agent名称(可选) |
| AgentConfig | Agent配置项 |
| boolean | 启用文件上传 |
| boolean | 启用图片上传 |
Related Skills
相关技能
bash
undefinedbash
undefinedChat UI building blocks
聊天UI构建模块
npx skills add inferencesh/skills@chat-ui
npx skills add inferencesh/skills@chat-ui
Declarative widgets from JSON
基于JSON的声明式小组件
npx skills add inferencesh/skills@widgets-ui
npx skills add inferencesh/skills@widgets-ui
Tool lifecycle UI
工具生命周期UI
npx skills add inferencesh/skills@tools-ui
undefinednpx skills add inferencesh/skills@tools-ui
undefinedDocumentation
文档
- Agents Overview - Building AI agents
- Agent SDK - Programmatic agent control
- Human-in-the-Loop - Approval flows
- Agents That Generate UI - Building generative UIs
- Agent UX Patterns - Best practices
Component docs: ui.inference.sh/blocks/agent
- Agents Overview - 构建AI Agent
- Agent SDK - Agent程序化控制
- Human-in-the-Loop - 审批流程
- Agents That Generate UI - 构建生成式UI
- Agent UX Patterns - 最佳实践