Basic Graphs
Create simple workflow graphs to orchestrate multi-step processes.
Quick Start
Clone the Complete Example
The easiest way to get started is to clone the complete example repository:
git clone https://github.com/astreus-ai/basic-graphs
cd basic-graphs
npm install
Or Install Package Only
If you prefer to build from scratch:
npm install @astreus-ai/astreus
Environment Setup
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db
Basic Graph Workflow
import { Agent, Graph } from '@astreus-ai/astreus';
// Create an agent
const agent = await Agent.create({
name: 'WorkflowAgent',
model: 'gpt-4o'
});
// 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);
}
Running the Example
If you cloned the repository:
npm run dev
Repository
The complete example is available on GitHub: astreus-ai/basic-graphs
How is this guide?