模板
关于项目模板和常见配置的说明。
默认项目#
当你运行 create-astreus-agent 时,会进入一个交互式设置流程,根据你的选择生成项目。
npx create-astreus-agent my-agent生成的项目包含了开始所需的一切。
生成的项目结构#
my-agent/
├── src/
│ └── index.ts # 包含智能体配置的主入口文件
├── package.json # 依赖项和脚本
├── tsconfig.json # TypeScript 配置(若选择了 TypeScript)
├── .env.example # 环境变量模板
├── .gitignore # Git 忽略规则
└── README.md # 项目文档Package.json 脚本#
{
"scripts": {
"dev": "tsx src/index.ts",
"build": "tsc",
"start": "node dist/index.js"
}
}常见配置#
基础聊天智能体#
只选择 Memory 功能,构建一个简单的对话式智能体:
? Which features do you want to include?
◉ Memory - Persistent agent memory with vector search
◯ Knowledge (RAG)
◯ Graph Workflows
◯ Sub-Agents
◯ Custom Plugins
◯ MCP Integration启用 RAG 的智能体#
选择 Memory 和 Knowledge,以实现基于文档的响应:
? Which features do you want to include?
◉ Memory - Persistent agent memory with vector search
◉ Knowledge (RAG) - Document ingestion and retrieval
◯ Graph Workflows
◯ Sub-Agents
◯ Custom Plugins
◯ MCP Integration全功能智能体#
选择全部功能以获得最大能力:
? Which features do you want to include?
◉ Memory - Persistent agent memory with vector search
◉ Knowledge (RAG) - Document ingestion and retrieval
◉ Graph Workflows - DAG-based task orchestration
◉ Sub-Agents - Multi-agent coordination
◉ Custom Plugins - Extensible tool system
◉ MCP Integration - Model Context Protocol support特定提供商的设置#
OpenAI#
默认模型:gpt-4o
生成的 .env.example:
OPENAI_API_KEY=your-api-key-hereAnthropic(Claude)#
默认模型:claude-sonnet-5
生成的 .env.example:
ANTHROPIC_API_KEY=your-api-key-hereGoogle(Gemini)#
默认模型:gemini-2.0-flash
生成的 .env.example:
GEMINI_API_KEY=your-api-key-hereOllama(本地)#
默认模型:llama3
生成的 .env.example:
# Ollama runs locally, no API key needed
OLLAMA_HOST=http://localhost:11434多提供商#
生成的 .env.example:
# Add API keys for providers you want to use
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key
GEMINI_API_KEY=your-gemini-key功能对比#
| Feature | Use Case |
|---|---|
| Memory | 记住用户偏好、对话历史 |
| Knowledge | 文档问答、研究助手 |
| Graph | 多步骤工作流、流水线 |
| Sub-Agents | 专业化任务、并行处理 |
| Plugins | 自定义工具、API 集成 |
| MCP | 标准化的工具生态 |
后续步骤#
创建项目之后:
cd my-agent
npm install
cp .env.example .env
# Edit .env with your API keys
npm run dev详细的环境设置请参见配置。