クイックスタート
2分以内にAstreusで最初のAIエージェントを構築する
タスクを実行し、知的に応答できるシンプルなエージェントを作成しましょう。
進める前に、Astreusがインストールされていることを確認してください。まだインストールしていない場合は、インストールガイドに従ってください。
最初のエージェントを構築する#
環境ファイルを作成する#
プロジェクトのルートに.envファイルを作成し、OpenAI APIキーを追加します。
touch .env.envファイルにAPIキーを追加します。
OPENAI_API_KEY=sk-your-openai-api-key-here最初のエージェントを作成する#
メモリとシステムプロンプトを持つエージェントを作成します。
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});タスクを作成して実行する#
タスクを作成し、エージェントで実行します。
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a task
const task = await agent.createTask({
prompt: "Research latest news in Anthropic and OpenAI"
});
// Execute the task
const result = await agent.executeTask(task.id);
console.log(result.response);グラフワークフローを構築する#
複数のタスクを持つワークフローグラフを作成します。
import { Agent, Graph } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a graph for complex workflows
const graph = new Graph({
name: 'Research Pipeline',
defaultAgentId: agent.id
});
// Add task nodes
const researchNode = graph.addTaskNode({
prompt: 'Research the latest AI developments'
});
const analysisNode = graph.addTaskNode({
prompt: 'Analyze the research findings',
dependencies: [researchNode]
});
const summaryNode = graph.addTaskNode({
prompt: 'Create a summary report',
dependencies: [analysisNode]
});
// Run the graph
const graphResult = await graph.run();
console.log(graphResult.results[summaryNode]);おめでとうございます!Astreusで最初のAIエージェントを作成できました。