複雑なワークフロー
高度なオーケストレーションパターンを用いた洗練されたマルチエージェントワークフローを構築します。
クイックスタート#
完全なサンプルをクローンする#
最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。
git clone https://github.com/astreus-ai/examples
cd examples/complex-workflows
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 specialized agents
const researcher = await Agent.create({
name: 'Researcher',
model: 'gpt-6-astra',
systemPrompt: 'You research topics thoroughly.'
});
const writer = await Agent.create({
name: 'Writer',
model: 'gpt-6-astra',
systemPrompt: 'You create engaging content.'
});
// Create workflow pipeline
const pipeline = new Graph({
name: 'content-pipeline'
}, researcher);
// Define workflow steps
const research = pipeline.addTaskNode({
prompt: 'Research AI trends in 2024',
agentId: researcher.id
});
const article = pipeline.addTaskNode({
prompt: 'Write an article based on the research',
agentId: writer.id,
dependencies: [research]
});
// Execute the workflow
const results = await pipeline.run();
// Parse the result and extract the response
if (results.success && results.results[article]) {
const articleResult = JSON.parse(results.results[article]);
console.log(articleResult.response);
}サンプルの実行#
リポジトリをクローンした場合は次を実行します。
npm run devリポジトリ#
完全なサンプルはGitHubで公開されています: examples/complex-workflows