基本的なグラフ

複数ステップのプロセスをオーケストレーションするシンプルなワークフローグラフを作成します。

クイックスタート#

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

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

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';

// Create an agent
const agent = await Agent.create({
  name: 'WorkflowAgent',
  model: 'gpt-6-astra'
});

// Create a simple sequential graph
const graph = new Graph({
  name: 'research-workflow'
}, agent);

// Add tasks with dependencies
const research = graph.addTaskNode({
  prompt: 'Research artificial intelligence trends'
});

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

// Execute the workflow
const results = await graph.run();

// Parse the result and extract the response
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