基本的なグラフ
複数ステップのプロセスをオーケストレーションするシンプルなワークフローグラフを作成します。
クイックスタート#
完全なサンプルをクローンする#
最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。
git clone https://github.com/astreus-ai/examples
cd examples/basic-graphs
npm installまたはパッケージのみをインストール#
ゼロから構築したい場合は次のようにします。
npm install @astreus-ai/astreus環境設定#
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db基本的なグラフワークフロー#
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);
}サンプルの実行#
リポジトリをクローンした場合は次を実行します。
npm run devリポジトリ#
完全なサンプルはGitHubで公開されています: examples/basic-graphs