メモリを使ったエージェント
永続的なメモリ機能を備えたエージェントを構築します。
クイックスタート#
完全なサンプルをクローンする#
最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。
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