import { Agent } from '@agenite/agent';
import { prettyLogger } from '@agenite/pretty-logger';
import { OpenAIProvider } from '@agenite/openai';
// Create a child agent
const researchAgent = new Agent({
name: 'researcher',
provider: new OpenAIProvider({
model: 'gpt-3.5-turbo',
}),
instructions: 'You research information about topics.'
});
// Create a parent agent that uses the research agent
const supervisorAgent = new Agent({
name: 'supervisor',
provider: new OpenAIProvider({
model: 'gpt-4',
}),
middlewares: [
prettyLogger()
],
tools: [
{
name: 'research',
description: 'Research a topic in depth',
parameters: {
type: 'object',
properties: {
topic: {
type: 'string',
description: 'The topic to research'
}
},
required: ['topic']
},
handler: async ({ topic }) => {
return researchAgent.execute({
messages: [
{
role: 'user',
content: [{ type: 'text', text: `Research the topic: ${topic}` }]
}
]
});
}
}
],
instructions: 'You are a supervisor that delegates research tasks.'
});
// Execute the supervisor agent
const result = await supervisorAgent.execute({
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'I need information about quantum computing.' }
],
},
],
});