CrewAI is a multi-agent system designed for enterprise applications, offering a structured and robust framework. Unlike AutoGen, CrewAI operates without a user proxy agent, allowing agents to work collaboratively on assigned tasks.
CrewAI supports two processing models:
CrewAI requires detailed setup, enabling greater control. The configuration includes roles, goals, verbosity, memory, backstory, delegation, and additional tools.
pip install crewaiExample agents in a humor-based task include:
Each agent is assigned a task with a clear goal and expected output:
from crewai import Agent
senior_joke_researcher = Agent(
role="Senior Joke Researcher",
goal="Analyze humor trends and identify the funniest elements of a given topic.",
verbose=True
)
joke_writer = Agent(
role="Joke Writer",
goal="Craft jokes based on research findings and deliver them in a humorous style.",
verbose=True
)from crewai import Task
research_task = Task(
name="Humor Research",
description="Identify the most humorous elements of a given topic.",
agent=senior_joke_researcher
)
writing_task = Task(
name="Joke Writing",
description="Write a joke based on the research findings.",
agent=joke_writer,
depends_on=[research_task] # Sequential processing
)A CrewAI system integrates agents and tasks with additional settings like memory, cache, and execution limits. Running the system generates humorous AI-related jokes.
from crewai import Crew
jokester_crew = Crew(
agents=[senior_joke_researcher, joke_writer],
tasks=[research_task, writing_task],
memory=True # Enables memory for better task handling
)
# Run the crew
jokester_crew.kickoff()AgentOps is an observability tool that tracks CrewAI agent interactions, providing insights such as execution duration, token usage, and estimated costs.
To set up the AgentOps on your system, you should follow these instructions:
Install the package:
> pip install agentopsor with CrewAI:
> pip install crewai[agentops] Obtain an API key from AgentOps and add it to the .env file:
AGENTOPS_API_KEY="your API key"
Integrate AgentOps into the CrewAI Script
import agentops
agentops.init()Running the script allows users to track agent activities in the AgentOps dashboard, analyzing system efficiency and cost.
jokester_crew.kickoff() # This execution is now monitored by AgentOps