NEW: Find your perfect tool with our matching quiz

Take a quiz

Table of Content

Crew AI: Multi-Agent Framework

Generative AI
|
Rokas Jurkėnas

You’ve probably been using some AI tools to improve your productivity or work for a while now, but have you ever considered creating a team of artificial agents working together towards a common goal? Creating a team of artificial humans that can perform marketing, sales, and other tasks seems like something out of a sci-fi movie.

Crew AI introduces a new way of using AI to solve complicated tasks. By arranging multiple AI agents, each with a unique role, it effectively solves a variety of challenges. It’s a mix of autonomy and collaboration, with agents sharing tasks and working together smoothly.

What is Crew AI?

CrewAI logo

Crew AI is a framework for organizing multiple independent AI agents to work together. These agents, each with a specific role, work together to solve complex tasks.

CrewAI’s design and capabilities make it an innovative tool for creating complex multi-agent systems, useful for a range of tasks from simulations and data analysis to more complex scenarios requiring coordinated multi-agent cooperation.

Crew AI Features

  • Role-based agent design: Customise agents with specific roles, goals, and tools.
  • Autonomous cross-agent assignment: Agents can collaborate and share tasks.
  • Flexible task management: Create tasks with custom tools. Then assign them to agents as needed.
  • Process Driven: Only supports sequential task execution and hierarchical processes. More complex processes such as consensual and autonomous are being worked on.
  • Save output to a file: Save the output of individual tasks as a file for later use.
  • Works with open source models: Run your team using Open AI or open source models.

Building and Managing AI Agents

Building and managing AI agents in CrewAI involves defining and customising agents based on their roles, goals, backstories, and tools. With CrewAI’s custom GPT, you can easily chat with the documentation to help you set up your project.

AI agents

Here’s an overview of how you can build and manage agents:

Step 1: To create an agent, you instantiate the Agent class with specific attributes. Key attributes include:

  • role: Defines the role of the agent, like ‘Researcher’, ‘Writer’, etc.
  • goal: Outlines the objective the agent aims to achieve.
  • backstory: Provides a narrative background for the agent, enhancing the role-playing aspect.
  • tools: A list of tools (from crewai_tools or other LangChain tools) the agent can use to accomplish tasks.
  • allow_delegation: Allows the agent to delegate tasks to other agents.
  • memory: Determines if the agent should have memory capabilities.
  • verbose: Enables verbose mode for detailed execution logs.
  • max_rpm: Sets the maximum number of requests per minute for the agent.

Step 2: The agent’s execution can be customized with several parameters:

  • max_iter: Maximum iterations for an agent to execute a task.
  • max_execution_time: Limits the time an agent can spend on a task.
  • agent_executor: Instance of CrewAgentExecutor to handle the execution of the agent’s tasks.
  • step_callback: Allows executing a callback function after each step of the agent execution.

Step 3: The agent can execute tasks using the execute_task method. This method considers the agent’s tools, context, and the specific task to generate the output.

Additional information:

Inter-Agent Communication: Agents can delegate tasks and communicate with each other, improving problem-solving efficiency. This is set up by the allow_delegation attribute.

Memory and RPM Control: Agents can have contextual memory and are controlled by an RPM (requests per minute) controller to manage the execution rate.

Custom Tools: Agents can be equipped with custom tools built using the BaseTool class from crewai_tools. These tools are converted to LangChain tools for compatibility.

Real-World Examples and Use Cases

You can create a team of AI agents that can completely oversee marketing operations. The CrewAI framework is particularly useful if you do not have the resources for your company or yourself to run a marketing team, and instead, you can have an artificial intelligence team to do it for you.

Setting up a team of artificial intelligence agents

Define Agents and Tasks: Create agent instances for each team member and define their respective tasks.
# Define agents with their roles, goals, and tasks

market_research_agent = Agent(role=’Market Research Agent’, goal=’Conduct market analysis’, …)

content_strategist_agent = Agent(role=’Content Strategist Agent’, goal=’Develop content strategy’, …)

# … Define other agents similarly

# Define tasks for each agent

market_research_task = Task(description=’Analyze market data’, agent=market_research_agent, …)

content_strategy_task = Task(description=’Create content strategy document’, agent=content_strategist_agent, …)

# … Define other tasks similarly

Create a Crew: Instantiate a Crew class including all agents and tasks

    marketing_crew = Crew(

        agents=[market_research_agent, content_strategist_agent, …],

        tasks=[market_research_task, content_strategy_task, …],

        process=Process.sequential

    )

    Execute the Campaign: Kick off the crew to start executing the tasks.
    result = marketing_crew.kickoff()

    print(result)

    Expected Outcome

    • Market Research Agent provides detailed market insights.
    • Content Strategist Agent develops a comprehensive content plan.
    • Social Media Manager Agent effectively runs social media campaigns.
    • SEO Specialist Agent improves the product’s online visibility.
    • Graphic Designer Agent creates attractive visual content.

    This scenario demonstrates how a team of AI agents can collaboratively work towards a common goal in a marketing campaign, with each agent contributing its expertise to different aspects of the campaign.

    This is just a simple example of a marketing team created with CrewAI, you can create more complicated or simpler teams.

    More CrewAI Framework Use Cases

    Data analysis and reporting teams: Create a team where each AI agent has a specific role in analyzing data, generating reports, and providing insights. For example, you could have agents focused on collecting data from different sources, another agent analyzing the data, and a third agent creating a detailed report.

    Customer support automation teams: Use AI agents to automate customer support tasks. One agent could collect data from customer interactions, another could analyze that data to identify common issues, and another could draft responses or solutions.

    Product development teams: Create a team to brainstorm product ideas from scratch. For example, one agent might brainstorm ideas based on market research, another might evaluate the potential of the idea, and another can plan and execute the development process.

    Financial analysis teams: You can also create teams that focus on financial tasks, such as stock analysis. Different agents can handle tasks such as researching market trends, analyzing specific stocks, and providing investment recommendations.

    Is Crew AI open source?

    CrewAI is open source and encourages contributions for the feature or improvement. If you would like to contribute, it is easy to do so.

    Final thoughts

    All in all, CrewAi is a great tool for trying to create a team of agents that can perform tasks and work together. It is a great step in the right direction and hopefully, we will see similar tools that provide even more services that will help businesses and individuals.

    Illustration of an ai robot

    This short overview is just an example of how it can be used, you can try to experiment and create different types of artificial intelligence agents that can do other tasks as the tool is free for everyone to use with a business plan coming soon.

    I am excited about AI because the future looks bright. We will soon see more advanced tools like this that can do even more.

    Author

    Avatar photo
    Rokas Jurkėnas

    Need some help with No-code?

    For several years, I have been developing various products and systems using the No Code tools.

    References

    Read more