メモリを使ったエージェント

永続的なメモリ機能を備えたエージェントを構築します。

クイックスタート#

完全なサンプルをクローンする#

最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。

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

またはパッケージのみをインストール#

ゼロから構築したい場合は次のようにします。

bash
npm install @astreus-ai/astreus

環境設定#

bash
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here

# Database for memory storage
DB_URL=sqlite://./astreus.db

メモリエージェント#

typescript
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

サンプルの実行#

リポジトリをクローンした場合は次を実行します。

bash
npm run dev

リポジトリ#

完全なサンプルはGitHubで公開されています: examples/agent-with-memory