에이전트 영속성

재사용을 위해 데이터베이스에서 에이전트를 저장하고 불러옵니다.

빠른 시작#

전체 예제 클론하기#

가장 쉬운 시작 방법은 전체 예제 저장소를 클론하는 것입니다:

bash
git clone https://github.com/astreus-ai/examples
cd examples/agent-persistence
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: 'ProjectAssistant',
  model: 'gpt-6-astra',
  memory: true,
  systemPrompt: 'You are a project management assistant.'
});

// 에이전트 사용
await agent.ask("Remember that our project deadline is March 15th");

// 나중에 이름으로 동일한 에이전트를 불러옴
const loadedAgent = await Agent.findByName('ProjectAssistant');
const response = await loadedAgent?.ask("What is our project deadline?");
console.log(response); // Should remember March 15th

예제 실행하기#

저장소를 클론했다면:

bash
npm run dev

저장소#

전체 예제는 GitHub에서 확인할 수 있습니다: examples/agent-persistence