기본 그래프

다단계 프로세스를 조율하기 위한 간단한 워크플로우 그래프를 만듭니다.

빠른 시작#

전체 예제 클론하기#

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

bash
git clone https://github.com/astreus-ai/examples
cd examples/basic-graphs
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, Graph } from '@astreus-ai/astreus';

// 에이전트 생성
const agent = await Agent.create({
  name: 'WorkflowAgent',
  model: 'gpt-6-astra'
});

// 간단한 순차 그래프 생성
const graph = new Graph({
  name: 'research-workflow'
}, agent);

// 의존성을 가진 작업 추가
const research = graph.addTaskNode({
  prompt: 'Research artificial intelligence trends'
});

const summary = graph.addTaskNode({
  prompt: 'Summarize the research findings',
  dependencies: [research]
});

// 워크플로우 실행
const results = await graph.run();

// 결과를 파싱하고 응답을 추출
if (results.success && results.results[summary]) {
  const summaryResult = JSON.parse(results.results[summary]);
  console.log(summaryResult.response);
}

예제 실행하기#

저장소를 클론했다면:

bash
npm run dev

저장소#

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