import { Agent, AgentFlow } from 'praisonai';
const dataAgent = new Agent({
name: 'Data Analyst',
instructions: 'Analyze data and extract insights.'
});
const strategyAgent = new Agent({
name: 'Strategist',
instructions: 'Create strategies based on data insights.'
});
const reportAgent = new Agent({
name: 'Report Writer',
instructions: 'Write executive reports.'
});
const analysisWorkflow = new AgentFlow('business-analysis')
.addStep({
name: 'analyze',
execute: async (data, context) => {
const insights = await dataAgent.chat(`Analyze: ${JSON.stringify(data)}`);
context.set('insights', insights);
return insights;
}
})
.addStep({
name: 'strategize',
execute: async (insights, context) => {
const strategy = await strategyAgent.chat(`Create strategy for: ${insights}`);
context.set('strategy', strategy);
return strategy;
}
})
.addStep({
name: 'report',
execute: async (strategy, context) => {
const insights = context.get('insights');
return await reportAgent.chat(`
Write executive report:
Insights: ${insights}
Strategy: ${strategy}
`);
}
});
const { output, context } = await analysisWorkflow.run(salesData);