Menu

Building with crewAI

Introduction

crewAI is an emerging, powerful framework specifically designed for orchestrating role-playing, autonomous AI agents. It simplifies the process of creating multi-agent setups.

Core Concepts in crewAI

  • Agents: You define an agent by giving it a Role, a Goal, and a Backstory.
  • Tasks: Specific assignments you give to the agents, including the expected output format.
  • Tools: Capabilities (like web search or file reading) assigned to specific agents.
  • Crew: The overarching container that manages the agents and tasks, dictating the process (e.g., sequential or hierarchical execution).
from crewai import Agent, Task, Crew

# Define an agent
researcher = Agent(
  role='Senior Research Analyst',
  goal='Uncover cutting-edge developments in AI',
  backstory='You work at a leading tech think tank.',
  verbose=True
)

# Define a task
task = Task(
  description='Research the latest advancements in quantum computing.',
  expected_output='A 3-paragraph executive summary.',
  agent=researcher
)

# Form a crew
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()

Assignment

  1. Read the crewAI documentation.
  2. Install crewai and build a simple 2-agent crew: a Researcher who finds information on the web, and a Writer who turns that information into a blog post.

Support me!

I am a software engineer giving back to the community - my name is Musila Peter. Join me in empowering learners around the globe by supporting SaneGenius!