带记忆的智能体
构建具备持久化记忆能力的智能体。
快速开始#
克隆完整示例#
最简单的开始方式是克隆完整的示例仓库:
git clone https://github.com/astreus-ai/examples
cd examples/agent-with-memory
npm install或仅安装包#
如果你更喜欢从零开始构建:
npm install @astreus-ai/astreus环境配置#
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
# Database for memory storage
DB_URL=sqlite://./astreus.db记忆智能体#
import { Agent } from '@astreus-ai/astreus';
const agent = await Agent.create({
name: 'MemoryBot',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You remember our conversation history.'
});
// First conversation
const response1 = await agent.ask("My name is John and I like TypeScript");
console.log(response1);
// Later conversation - agent remembers
const response2 = await agent.ask("What's my name and what do I like?");
console.log(response2); // Should remember John and TypeScript运行示例#
如果你克隆了仓库:
npm run dev仓库#
完整示例可在 GitHub 上获取:examples/agent-with-memory