CrewAI
Define Agents & Tasks
from crewai import Agent, Task, Crew
researcher = Agent(
role='Research Analyst',
goal='Find comprehensive information on the topic',
backstory='Expert researcher with access to web search',
tools=[search_tool],
llm=llm,
)
writer = Agent(
role='Content Writer',
goal='Write engaging content based on research',
backstory='Experienced technical writer',
llm=llm,
)
research_task = Task(description='Research {topic}', agent=researcher, expected_output='Research report')
write_task = Task(description='Write article from research', agent=writer, expected_output='Blog post', context=[research_task])
crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task], verbose=True)
result = crew.kickoff(inputs={'topic': 'AI agents'})
Process types: sequential, hierarchical (manager delegates)
Memory, callbacks, custom tools
1---2name: crewai-multiagent3description: CrewAI4---5# CrewAI67## Define Agents & Tasks8```python9from crewai import Agent, Task, Crew1011researcher = Agent(12 role='Research Analyst',13 goal='Find comprehensive information on the topic',14 backstory='Expert researcher with access to web search',15 tools=[search_tool],16 llm=llm,17)1819writer = Agent(20 role='Content Writer',21 goal='Write engaging content based on research',22 backstory='Experienced technical writer',23 llm=llm,24)2526research_task = Task(description='Research {topic}', agent=researcher, expected_output='Research report')27write_task = Task(description='Write article from research', agent=writer, expected_output='Blog post', context=[research_task])2829crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task], verbose=True)30result = crew.kickoff(inputs={'topic': 'AI agents'})31```3233## Process types: sequential, hierarchical (manager delegates)34## Memory, callbacks, custom tools