高级子智能体

通过复杂的协调模式和专业化能力,构建复杂的多智能体工作流。

快速开始#

克隆完整示例#

最简单的开始方式是克隆完整的示例仓库:

bash
git clone https://github.com/astreus-ai/examples
cd examples/sub-agents-advanced
npm install

或仅安装包#

如果你更喜欢从零开始构建:

bash
npm install @astreus-ai/astreus

环境配置#

bash
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
ANTHROPIC_API_KEY=your-anthropic-api-key-here
DB_URL=sqlite://./astreus.db

多模型智能体团队#

typescript
import { Agent } from '@astreus-ai/astreus';

// Create diverse agent team with different models
const strategicPlanner = await Agent.create({
  name: 'StrategicPlanner',
  model: 'gpt-6-astra',  // High reasoning for strategy
  systemPrompt: 'You are a strategic business consultant with deep analytical thinking.',
  memory: true,
  knowledge: true
});

const creativeWriter = await Agent.create({
  name: 'CreativeWriter',
  model: 'claude-sonnet-5',  // Excellent for creative writing
  systemPrompt: 'You are a creative copywriter who crafts compelling narratives.',
  vision: true
});

const dataScientist = await Agent.create({
  name: 'DataScientist',
  model: 'gpt-6-astra',  // Strong analytical capabilities
  systemPrompt: 'You are a data scientist specializing in statistical analysis and insights.',
  useTools: true
});

const executiveTeam = await Agent.create({
  name: 'ExecutiveTeam',
  model: 'gpt-6-astra',  // High-level coordination
  systemPrompt: 'You coordinate executive-level strategic initiatives across expert teams.',
  subAgents: [strategicPlanner, creativeWriter, dataScientist]
});

const businessPlan = await executiveTeam.ask(
  'Develop comprehensive go-to-market strategy for AI-powered healthcare platform',
  {
    useSubAgents: true,
    delegation: 'auto',
    coordination: 'sequential'
  }
);

console.log('Business plan completed:', businessPlan);

运行示例#

如果你克隆了仓库:

bash
npm run dev

如果你从零开始构建,请创建一个 index.ts 文件并写入上面的代码,然后运行:

bash
npx tsx index.ts

仓库#

完整示例可在 GitHub 上获取:examples/sub-agents-advanced