---
title: "AI 代理"
description: "了解如何使用 AI Toolkit 构建 AI 代理。"
canonical_url: "https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents"
---

# AI 代理

了解如何使用 AI Toolkit 构建 AI 代理。

AI agents can interact with their environment to accomplish complex tasks. The AI Toolkit contains [内置工具](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/tools.md) that allow your AI to read, edit, and comment on documents.

通过 AI 工具包，您可以构建具有广泛功能的代理：

[AI 代理聊天机器人
了解更多 →构建一个可以通过聊天阅读和编辑文档的对话式 AI 代理。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/ai-agent-chatbot.md)

[审查变更
了解更多 →使用装饰标记或跟踪更改预览并批准 AI 生成的更改。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/review-changes.md)

[工具流式传输
了解更多 →实时流式传输工具调用，实时查看变更过程。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/streaming.md)

[添加评论
了解更多 →赋予您的 AI 代理读取、撰写和编辑评论的能力。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/comments.md)

[多文档处理
了解更多 →构建一个可以同时编辑多个 Tiptap 文档的 AI 代理。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/multi-document.md)

[选区感知
了解更多 →让 AI 了解编辑器中选定的内容。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/selection-awareness.md)

[架构感知
了解更多 →使您的 AI 模型理解自定义节点、标记及属性。](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/schema-awareness.md)

## 可用工具

AI Toolkit 为流行的 AI 提供方库提供了[工具定义](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/agents/tools.md)，例如 Vercel AI SDK、LangChain.js、OpenAI 和 Anthropic。

当您将这些工具定义添加到 AI 代理时，AI 模型可以生成工具调用，随后通过 `executeTool` 方法执行。这使得 AI 能够根据用户请求读取、编辑和操作文档。

## AI 代理与工作流程的区别

在 AI 代理中，AI 模型可以从一组工具中选择来执行任务。另一方面，[工作流程](https://tiptap.zhcndoc.com/ai/ai-toolkit/client/workflows.md) 只允许 AI 模型执行单一操作，例如生成编辑内容或重写文档。

总体而言，工作流程比 AI 代理工具更简单且实现更快。然而，AI 代理更为灵活，适用于执行更复杂的任务。
