CopilotKit/CopilotKit
GitHub: CopilotKit/CopilotKit
一个多平台 AI Agent 前端开发框架,提供生成式 UI、共享状态和人机交互能力,帮助开发者快速构建跨平台的智能助手应用。
Stars: 35150 | Forks: 4366
# CopilotKit
[文档](https://docs.copilotkit.ai/?ref=github_readme) ·
[示例](https://www.copilotkit.ai/examples) ·
[企业智能平台](https://go.copilotkit.ai/enterprise-intelligence-platform) ·
[Discord](https://discord.gg/6dffbvGU3D?ref=github_readme)
构建 **原生 Agent 应用** —— 支持任何框架,覆盖任何平台。
为 React、Angular、Vue、React Native 提供生成式 UI、共享状态和人机交互工作流,并延伸至浏览器之外。
## 什么是 CopilotKit
CopilotKit 是一个顶级的 SDK,用于构建全栈 Agent 应用、生成式 UI 和聊天应用。
它最初只是一个 React 库,如今已发展成为一个**多平台 Agent 框架**:同一个 agent 可以为你的 Web 应用、移动应用以及团队的 Slack 工作区提供支持。
我们还是 **[AG-UI 协议](https://github.com/ag-ui-protocol/ag-ui)** 背后的公司,该协议已被 Google、LangChain、AWS、Microsoft、Mastra、PydanticAI 等广泛采用!
## 快速开始
五分钟即可启动并运行。你只需要一个 LLM 密钥(OpenAI、Anthropic、Gemini 等)。
```
npx copilotkit@latest create
```
## Agent 技能
CopilotKit 提供了 [agent 技能](https://docs.copilotkit.ai),可以教你使用的编程 agent(Claude Code、Codex、Cursor、Gemini 等)如何设置、构建、集成、调试和升级 CopilotKit。
将它们安装到任何项目目录中:
```
npx copilotkit@latest skills install
```
随时再次运行该命令即可刷新并获取最新技能。
## 让你的应用焕发生机
https://github.com/user-attachments/assets/72b7b4f3-b6e7-460c-a932-5746fe3c8db3
```
查看 [useAgent 文档](https://go.copilotkit.ai/useagent-docs) 以了解更多信息。
https://github.com/user-attachments/assets/67928406-8abc-49a1-a851-98018b52174f
## 生成式 UI
生成式 UI 是 CopilotKit 的核心模式,允许 agent 在其工作流中动态渲染 UI。
https://github.com/user-attachments/assets/3cfacac0-4ffd-457a-96f9-d7951e4ab7b6
### 三种类型对比
#### 探索:
- [静态 (AG-UI Protocol)](https://docs.copilotkit.ai/ag-ui-protocol)
- [声明式 (A2UI)](https://docs.copilotkit.ai/generative-ui/specs/a2ui#using-a2ui-with-copilotkit)
- [开放式 (MCP Apps & Open JSON)](https://docs.copilotkit.ai/generative-ui/specs/mcp-apps)
[生成式 UI 教学仓库 →](https://github.com/CopilotKit/CopilotKit/tree/main/examples/showcases/generative-ui)
## 🖥️ AG-UI:Agent-用户交互协议
将 agent 工作流连接到面向用户的应用,在整个 agent 技术栈中拥有深度合作伙伴关系和第一方集成——包括 LangChain、CrewAI、Mastra、PydanticAI 等。
[](https://go.copilotkit.ai/ag-ui)
```
npx create-ag-ui-app my-agent-app
```
在 AG-UI README 中了解更多 →
## 📄 许可证
本仓库的源代码基于 [MIT License](https://github.com/CopilotKit/CopilotKit/blob/main/LICENSE) 开源。
1 分钟内为你的应用添加 AI
**功能:**
- **聊天 UI** – 一个完全可定制的聊天界面,支持消息流式传输、工具调用和 agent 响应。
- **后端工具渲染** – 使 agent 能够调用后端工具,返回的 UI 组件可直接在客户端渲染。
- **生成式 UI** – 允许 agent 在运行时根据用户意图和 agent 状态动态生成和更新 UI 组件。
- **共享状态** – 一个同步的状态层,agent 和 UI 组件都可以实时读取和写入。
- **人机交互** – 允许 agent 暂停执行,以便在继续之前请求用户输入、确认或编辑。
- **自我学习** _(早期体验)_ – agent 通过上下文内强化学习 (CLHF) 不断从用户反馈中改进。
## 🧩 兼容你的技术栈
一个 agent 后端。适配所有前端。
| 平台 | 状态 | 快速开始 |
| ------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------- |
| ⚛️ React / Next.js | ✅ GA | [快速入门](https://docs.copilotkit.ai/built-in-agent/quickstart) |
| 🅰️ Angular | ✅ 受支持 | [源代码 - 快速入门即将推出](https://github.com/CopilotKit/CopilotKit/tree/main/packages/angular) |
| 💚 Vue | ✅ 受支持 | [源代码 - 快速入门即将推出](https://github.com/CopilotKit/CopilotKit/tree/main/packages/vue) |
| 📱 React Native | ✅ 受支持 | [快速入门](https://docs.copilotkit.ai/react-native) |
| 💬 Slack / MS Teams / Discord / Google Chat | 🟡 Beta | [申请抢先体验](https://go.copilotkit.ai/beyond-the-web-form) |
你的 agent 逻辑保持不变 —— AG-UI 负责处理通信协议,CopilotKit 为每个框架处理 UI 层。
## 💬 浏览器之外:Slack 与 Microsoft Teams(Discord、Google Chat 即将推出...)
你的 agent 可以在 Web 应用之外运行并生成生成式 UI(**[了解更多](https://www.copilotkit.ai/integrations)**)。
CopilotKit 现在允许你将**同一个 agent** 部署到用户日常工作的平台上:
- **Slack** – 作为一等公民的 Slack 应用:直接在频道中实现对话、工具调用和人机交互审批。
- **Microsoft Teams** – 将 agent 工作流引入企业,融入你组织已有的工作环境中。
🔒 **抢先体验:** 我们正在逐步接入各个团队。
👉 **[申请抢先体验 →](https://go.copilotkit.ai/beyond-the-web-form)**
## 🧠 自我学习型 Agent
通过不断学习,随着时间的推移改进你的产品。
作为 [CopilotKit 智能平台](https://www.copilotkit.ai/copilotkit-intelligence) 的一部分,借助**基于人类反馈的持续学习 (CLHF)**,agent 会在每次交互中不断改进:
- **上下文内强化学习** – agent 自动从用户交互中改进,无需进行模型微调。
- **自动 prompt 增强** – agent 行为会根据最近的交互和结果进行自适应调整。
- **个性化适配** – agent 学习个人偏好,并随着时间推移为每位用户提供更好的体验。
- **对话串与持久化** – 完整的交互记录 —— 生成式 UI、人机交互、共享状态 —— 跨会话捕获保存。
可通过 CopilotKit Cloud 或自行托管使用。
🔒 **抢先体验:** 我们正在逐步接入各个团队。
👉 **[申请抢先体验 →](https://go.copilotkit.ai/beyond-the-web-form)**
https://github.com/user-attachments/assets/7372b27b-8def-40fb-a11d-1f6585f556ad
这将为你带来:
- **已安装的 CopilotKit** – 核心包已在你的应用中完全配置好
- **已配置的 Provider** – Context、状态和 hooks 已准备就绪可供使用
- **Agent 与 UI 已连接** – Agent 可以流式传输操作并立即渲染 UI
- **部署就绪** – 你的应用已准备好进行部署
[完整的入门指南 →](https://docs.copilotkit.ai/langgraph/quickstart)
## 工作原理:
CopilotKit 将你的 UI、agent 和工具连接到一个单一的交互循环中。

这实现了:
- 向用户请求输入的 agent
- 渲染 UI 的工具
- 跨步骤和会话的有状态工作流
- 一个 agent,可部署在 Web、移动端和聊天平台上
## ⭐️ useAgent Hook
`useAgent` hook 直接作用于 AG-UI,让你能够完全通过编程方式控制 agent 连接。
```
// Programmatically access and control your agents
const { agent } = useAgent({ agentId: "my_agent" });
// Render and update your agent's state
return {agent.state.city}
#### 探索:
- [静态 (AG-UI Protocol)](https://docs.copilotkit.ai/ag-ui-protocol)
- [声明式 (A2UI)](https://docs.copilotkit.ai/generative-ui/specs/a2ui#using-a2ui-with-copilotkit)
- [开放式 (MCP Apps & Open JSON)](https://docs.copilotkit.ai/generative-ui/specs/mcp-apps)
[生成式 UI 教学仓库 →](https://github.com/CopilotKit/CopilotKit/tree/main/examples/showcases/generative-ui)
## 🖥️ AG-UI:Agent-用户交互协议
将 agent 工作流连接到面向用户的应用,在整个 agent 技术栈中拥有深度合作伙伴关系和第一方集成——包括 LangChain、CrewAI、Mastra、PydanticAI 等。
[](https://go.copilotkit.ai/ag-ui)
```
npx create-ag-ui-app my-agent-app
```
在 AG-UI README 中了解更多 →
## 📄 许可证
本仓库的源代码基于 [MIT License](https://github.com/CopilotKit/CopilotKit/blob/main/LICENSE) 开源。标签:AI智能体, Copilot, React, Syscalls, 多框架集成, 自动化攻击