你的第一个智能体

使用 Astreus 框架创建你的第一个 AI 智能体。

快速开始#

克隆完整示例#

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

bash
git clone https://github.com/astreus-ai/examples
cd examples/your-first-agent
npm install

或仅安装包#

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

bash
npm install @astreus-ai/astreus

环境配置#

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

基础智能体#

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

const agent = await Agent.create({
  name: 'MyFirstAgent',
  model: 'gpt-6-astra',
  systemPrompt: 'You are a helpful assistant.'
});

// Create and execute a task
const task = await agent.createTask({
  prompt: "Hello, introduce yourself"
});

const result = await agent.executeTask(task.id);
console.log(result.response);

运行示例#

如果你克隆了仓库:

bash
npm run dev

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

bash
npx tsx index.ts

仓库#

完整示例可在 GitHub 上获取:examples/your-first-agent