import { createAgent } from '@src/index';
// Create multiple specialized agents for collaborative work
async function createCollaborativeAgents() {
const researchAgent = await createAgent({
name: 'Research Specialist',
providerAddress: '0x3feE5a4dd5FDb8a32dDA97Bed899830605dBD9D3', // deepseek-r1-70b for reasoning
memoryBucket: 'research-collab',
privateKey: 'your-private-key',
temperature: 0.3
});
const analysisAgent = await createAgent({
name: 'Analysis Specialist',
providerAddress: '0x3feE5a4dd5FDb8a32dDA97Bed899830605dBD9D3',
memoryBucket: 'analysis-collab',
privateKey: 'your-private-key',
temperature: 0.1
});
const reportAgent = await createAgent({
name: 'Report Writer',
providerAddress: '0xf07240Efa67755B5311bc75784a061eDB47165Dd', // llama-3.3-70b for writing
memoryBucket: 'report-collab',
privateKey: 'your-private-key',
temperature: 0.7
});
return { researchAgent, analysisAgent, reportAgent };
}
async function executeCollaborativeProject(topic: string) {
const { researchAgent, analysisAgent, reportAgent } = await createCollaborativeAgents();
console.log(`Starting collaborative project on: ${topic}`);
// Phase 1: Research
researchAgent.setSystemPrompt('You are a thorough researcher. Gather comprehensive information.');
const researchFindings = await researchAgent.chatWithContext(
`Research the topic "${topic}" and provide detailed findings with key insights.`
);
// Store research for other agents to access
await researchAgent.remember(`project:${topic}:research`, {
topic,
findings: researchFindings,
phase: 'research',
timestamp: new Date()
});
// Phase 2: Analysis
analysisAgent.setSystemPrompt('You are an analytical expert. Identify patterns and insights.');
const analysis = await analysisAgent.chatWithContext(
`Analyze these research findings and identify key patterns, trends, and insights:
${researchFindings}`
);
// Store analysis
await analysisAgent.remember(`project:${topic}:analysis`, {
topic,
analysis,
phase: 'analysis',
timestamp: new Date()
});
// Phase 3: Report Generation
reportAgent.setSystemPrompt('You are a skilled report writer. Create comprehensive, well-structured reports.');
const finalReport = await reportAgent.chatWithContext(
`Create a comprehensive report on "${topic}" using this research and analysis:
RESEARCH FINDINGS:
${researchFindings}
ANALYSIS:
${analysis}
Structure the report with executive summary, key findings, analysis, and recommendations.`
);
// Store final report
await reportAgent.remember(`project:${topic}:final_report`, {
topic,
report: finalReport,
phase: 'final_report',
timestamp: new Date()
});
return {
topic,
research: researchFindings,
analysis,
report: finalReport
};
}
// Usage
const project = await executeCollaborativeProject('Artificial Intelligence Trends 2024');
console.log('Project completed:', project.topic);