基础子智能体
在 Astreus 文档中了解 基础子智能体,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。
创建并协调多个 AI 智能体,以实现复杂的任务委派。
快速开始
克隆完整示例
最简单的开始方式是克隆完整的示例仓库:
git clone https://github.com/astreus-ai/examples
cd examples/sub-agents-basic
npm install或仅安装包
如果你更喜欢从零开始构建:
npm install @astreus-ai/astreus环境配置
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db简单的 Sub-Agent 设置
import { Agent } from '@astreus-ai/astreus';
// Create specialized sub-agents
const researcher = await Agent.create({
name: 'Researcher',
model: 'gpt-4o',
systemPrompt: 'You are an expert researcher who gathers comprehensive information.'
});
const writer = await Agent.create({
name: 'Writer',
model: 'gpt-4o',
systemPrompt: 'You are a skilled writer who creates clear, engaging content.'
});
// Create main coordinator agent
const mainAgent = await Agent.create({
name: 'Coordinator',
model: 'gpt-4o',
systemPrompt: 'You coordinate tasks between specialized agents.',
subAgents: [researcher, writer]
});
// Use auto delegation
const result = await mainAgent.ask(
'Research artificial intelligence trends and write a summary',
{
useSubAgents: true,
delegation: 'auto'
}
);
console.log(result);运行示例
如果你克隆了仓库:
npm run dev如果你从零开始构建,请创建一个 index.ts 文件并写入上面的代码,然后运行:
npx tsx index.ts仓库
完整示例可在 GitHub 上获取:examples/sub-agents-basic
最后更新时间:2026年7月6日
本节内容
你的第一个智能体
在 Astreus 文档中了解 你的第一个智能体,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。
带记忆的智能体
在 Astreus 文档中了解 带记忆的智能体,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。
带知识库的智能体
在 Astreus 文档中了解 带知识库的智能体,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。
基础 Graph
在 Astreus 文档中了解 基础 Graph,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。