icon: LiWrench
Title: Create Multi-Agent Systems with CrewAI
CrewAI is an open-source framework designed to orchestrate and coordinate teams of autonomous AI agents, similar to Autogen. Think of it as a way to assemble and manage a group of AI assistants that collaborate to achieve a shared objective, much like a crew on a ship or a project team.
Here are some essential aspects of CrewAI:
1. Building a Smart Assistant Platform: CrewAI can be leveraged to develop a team of agents capable of managing various tasks, such as scheduling appointments, arranging travel, and responding to user inquiries. This creates a comprehensive smart assistant that streamlines everyday activities.
2. Creating an Automated Customer Service System: With CrewAI, you can assemble a team of agents dedicated to handling customer inquiries, resolving issues, and providing support. This automated system enhances customer experience by ensuring timely and efficient responses.
3. Developing a Multi-Agent Research Team: CrewAI can facilitate the formation of a collaborative research team composed of agents that work together on projects. They can analyze data, generate hypotheses, and test ideas, making the research process more efficient and effective.
The CrewAI workflow process typically involves the following steps:
1. Agents: In this initial phase, you define the capabilities of your CrewAI workflow by specifying the agents involved. This includes outlining their roles and the skills they should possess, effectively determining who does what within the team.
2. Tasks: Next, you establish the specific objectives you want your agents to achieve. This step is crucial for guiding the agents toward accomplishing the desired outcomes.
3. Process: Here, you outline how CrewAI will utilize the defined agents and tasks to meet the overarching goals of your project. This involves mapping out the interactions and workflows that will drive the collaboration.
4. Run: Finally, you initiate the execution of your agents and tasks. Once the run is underway, assuming everything goes smoothly, CrewAI will generate results aimed at solving the stated objectives. This step marks the transition from planning to action, bringing your workflow to life.
✦ Focus
✦ Tools
✦ Memory
A tool in CrewAI is a skill or function that agents can utilize to perform various actions.
Tools are pivotal in extending the capabilities of CrewAI agents, enabling them to undertake a broad spectrum of tasks and collaborate effectively. When building solutions with CrewAI, leverage both custom and existing tools to empower your agents and enhance the AI ecosystem
Here are the primary distinctions:
Purpose of Tools for Agents vs. Tasks
Scope and Context of Tool Usage
Control Over Execution
Tool Management and Overlap
CrewAI's ability to support not only its native tools but also third-party tools from LangChain
and LlamaIndex
offers significant advantages.
✦ This flexibility allows users to leverage a broader range of functionalities and integrations, enhancing the overall versatility and capability of the platform.
✦ Developers are not confined to the tools provided by CrewAI alone; they can seamlessly integrate and utilize the best tools available in the market, tailored to their specific needs.
walkthrough
notebook, we have tried a more advanced example that uses toolkits
(a suit of tools) from LangChain to create a tool that can manipulate and analyze tabular data by actually running Python code.
✦ This tool uses the pandas
library to manipulate the data and the ChatOpenAI
agent to run the code.
✦ While the example is a bit more complex, but we think it's worth to include it because the simplier examples (using a single tool
from LangChain) are already well documented in CrewAI's documentation.
✦ The toolkits
are usually much more powerful and can be used to achieve more complex tasks, but we have yet to come across a comprehensive documentation on how to incorporate them into CrewAI's agents.
from langchain.agents import Tool
from langchain.agents.agent_types import AgentType
from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain_openai import ChatOpenAI
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv")
pandas_tool_agent = create_pandas_dataframe_agent(
llm=ChatOpenAI(temperature=0, model='gpt-4o-mini'),
df=df,
agent_type=AgentType.OPENAI_FUNCTIONS,
allow_dangerous_code=True # <-- This is an "acknowledgement" that this can run potentially dangerous code
)
# Create the tool
pandas_tool = Tool(
name="Manipulate and Analyze tabular data with Code",
func=pandas_tool_agent.invoke, # <-- This is the function that will be called when the tool is run. Note that there is no `()` at the end
description="Useful for search-based queries",
)
LangChain
tools in CrewAI, see https://docs.crewai.com/core-concepts/Using-LangChain-Tools/LlamaIndex
tools in CrewAI, see https://docs.crewai.com/core-concepts/Using-LlamaIndex-Toolsfor more info about
Tools
, such as the list of tools or how to create your own tool, see https://docs.crewai.com/core-concepts/Tools/#introduction