Avvio rapido
Costruisci il tuo primo agente AI con Astreus in meno di 2 minuti
Creiamo un semplice agente in grado di eseguire task e rispondere in modo intelligente.
Prima di procedere, assicurati di avere Astreus installato. Se non l'hai ancora installato, segui la guida all'installazione.
Costruisci il tuo primo agente#
Crea il file di ambiente#
Crea un file .env nella root del tuo progetto e aggiungi la tua chiave API OpenAI:
touch .envAggiungi la tua chiave API al file .env:
OPENAI_API_KEY=sk-your-openai-api-key-hereCrea il tuo primo agente#
Crea un agente con memoria e system prompt:
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.'
});Crea ed esegui un task#
Crea un task ed eseguilo con il tuo agente:
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);Costruisci un workflow a grafo#
Crea un grafo di workflow con più task:
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]);Congratulazioni! Hai creato il tuo primo agente AI con Astreus.