0
0
Agentic AIml~5 mins

CrewAI for multi-agent teams in Agentic AI

Choose your learning style9 modes available
Introduction
CrewAI helps multiple AI agents work together like a team to solve problems faster and better.
When you want different AI agents to share tasks and help each other.
When solving complex problems that need many skills or viewpoints.
When you want to improve AI decision-making by teamwork.
When building AI systems that mimic how people collaborate in groups.
Syntax
Agentic AI
crew = CrewAI(agents=[agent1, agent2, agent3])
crew.assign_task('Collect data')
results = crew.run()
print(results)
Each agent in the crew can have different skills or roles.
The crew manages communication and task sharing automatically.
Examples
Two agents work together: one collects data, the other analyzes it.
Agentic AI
crew = CrewAI(agents=[DataAgent(), AnalysisAgent()])
crew.assign_task('Analyze sales data')
output = crew.run()
Three agents collaborate to plan an event by sharing subtasks.
Agentic AI
crew = CrewAI(agents=[AgentA(), AgentB(), AgentC()])
crew.assign_task('Plan event')
results = crew.run()
Sample Model
This simple example shows two agents in a crew working on the same task and returning their results.
Agentic AI
class Agent:
    def __init__(self, name):
        self.name = name
    def perform(self, task):
        return f'{self.name} completed {task}'

class CrewAI:
    def __init__(self, agents):
        self.agents = agents
        self.task = ''
    def assign_task(self, task):
        self.task = task
    def run(self):
        results = []
        for agent in self.agents:
            result = agent.perform(self.task)
            results.append(result)
        return results

# Create agents
agent1 = Agent('Agent 1')
agent2 = Agent('Agent 2')

# Create crew with agents
crew = CrewAI(agents=[agent1, agent2])

# Assign a task to the crew
crew.assign_task('data collection')

# Run the crew and get results
output = crew.run()

print(output)
OutputSuccess
Important Notes
CrewAI helps break big tasks into smaller parts shared by agents.
Good communication between agents is key for teamwork success.
You can customize agents with different skills for better results.
Summary
CrewAI lets multiple AI agents work together as a team.
It improves problem-solving by sharing tasks and ideas.
You create a crew, assign tasks, and get combined results.