What’s new in CrewAI v0.51.0
The CrewAI team has just released a new version packed with new features. As usual, I’m going to unpack the ones I find the most exciting.
To upgrade to the new version run the following command from the terminal
pip install --upgrade crewai 'crewai[tools]'
Remember the CrewAI documentation is the ultimate source of information, head over there to get more details. You can read the release notes on Github v0.51.0
Key Features Highlight
crewAI Testing / Evaluation
CrewAI introduced new built-in testing capabilities that allow you to easily test your crew and evaluate its performance.
Simply type crewai test
in your command line, and your crew will run through their tasks, and you'll get a report card at the end. You can adjust two settings:
- Number of test runs (default is 2)
- AI model to use (default is gpt-4o-mini)
For example, to run 5 tests using the gpt-4o model, just type:
crewai test --n_iterations 5 --model gpt-4o
At the end, you get a score card which shows how well each task was performed and gives an overall score for your crew. The higher the score (out of 10), the better! With this new feature, you can easily track your AI crew's performance and make improvements where needed.
Allowing all attributes on YAML
CrewAI allows you to create projects via a CLI tool that is available when you install crewAI. Below is an example of how to create a new project
$ crewai create crew <project_name>
This creates a project structure that allows you to define your tasks and agents as yaml
files. You define your agents in src/my_project/config/agents.yaml
and your tasks in src/my_project/config/tasks.yaml
Pipeline Structure
Pipelines in crewAI are structured workflows that allow for the sequential or parallel execution of multiple crews. They represent a way to organize complex processes involving multiple stages, where the output of one stage can serve as input for subsequent stages.
Pipelines are used for:
- Sequencing operations: Execute crews in a specific order
- Parallel processing: Run multiple crews concurrently within a stage
- Managing complex workflows: Break down large tasks into smaller, manageable steps
- Handling multi-stage processes like research, analysis, and content generation
Key components of a pipeline include:
- Stages: Distinct parts of the pipeline, either sequential (single crew) or parallel (multiple crews)
- Runs: Specific executions of the pipeline for a given set of inputs
- Branches: Parallel executions within a stage
- Traces: The journey of an individual input through the entire pipeline
- Routers: Special components that allow for dynamic decision-making and branching within the workflow
Additional important information:
- Pipeline creation: Pipelines are created by defining a series of stages, each consisting of either a single crew or a list of crews for parallel execution.
- Output handling: Pipeline outputs are encapsulated in the PipelineKickoffResult class, providing structured access to results in various formats (raw strings, JSON, Pydantic models).
- Advanced features: Pipelines support parallel execution within stages and the use of routers for dynamic workflow management.
- Routers: These allow for conditional branching in pipelines, directing the flow of execution based on specific criteria.
- Error handling and validation: The Pipeline class includes validation mechanisms to ensure the robustness of the pipeline structure.
Overall, pipelines in crewAI provide a flexible and powerful way to structure complex AI-driven workflows, allowing for efficient execution of multi-stage processes with dynamic routing capabilities.
Planning step LLM
CrewAI has the ability to enable your crew to have a planning step. Now with this release, you are now able to set a LLM that should be used for planning. This allows you to set a more powerful (potentially expensive) LLM for the planning stage and then use more affordable and capable LLMs for the other stages of the crew execution.
my_crew = Crew(
...
planning=True,
planning_llm=ChatOpenAI(model="gpt-4o")
)
crew run
command
A new command has been added to the CLI that is used to execute your projects
$ crewai run
New tools
4 new tools were added in this release. To access CrewAI tools you need to install the tools package first
pip install 'crewai[tools]'
Vision tool
The Vision Tool is designed to extract text from images. When using the tool, provide either the URL or file path of the image to the agent. This tool enables agents to work with image-based text data, expanding their capabilities to include visual information processing.
from crewai_tools import VisionTool
vision_tool = VisionTool()
To use the Vision tool you need to set the OPENAI_API_KEY
in the environment variables first.
DALL-E Tool
This tool is used to give the Agent the ability to generate images using the DALL-E model. It allows your agents to create images from text descriptions users pass in.
from crewai_tools import DallETool
dalle_tool = DallETool()
MySQL tool
The MySQLSearchTool is a specialized tool for performing semantic searches in MySQL databases. This tool simplifies the process of finding relevant information in large MySQL datasets through semantic search capabilities, making it valuable for users who need to perform complex queries on extensive data.
from crewai_tools import MySQLSearchTool
tool = MySQLSearchTool(db_uri='mysql://user:password@localhost:3306/mydatabase', table_name='employees')
NL2SQL Tool
The tool described converts natural language into SQL queries, allowing agents to interact with databases using regular language. It enables workflows where an agent can:
- Access database information based on its goal
- Use retrieved data to generate responses, reports, or other outputs
- Update the database if needed
from crewai_tools import NL2SQLTool
# psycopg2 was installed to run this example with PostgreSQL
nl2sql = NL2SQLTool(db_uri="postgresql://example@localhost:5432/test_db")
Bug Fixes and Documentation
In addition to the new features, this release includes several important bug fixes and improvements:
- Bug with planning feature output
- Async tasks for hierarchical process
- Better Pydantic output for non OAI models
- JSON truncation issues
- Fix logging types
- Only import AgentOps if the Env Key is set
- Sanitize agent roles to ensure valid directory names (Windows)
- Tools name shouldn't contain space for OpenAI
CrewAI continues to improve and version 0.51.0 brings in new features and improvements that enhance it’s capabilities and user experience. This release empowers developers to create more sophisticated and efficient AI-driven workflows. With these advancements and ongoing bug fixes, CrewAI solidifies its position as a leading framework for building and managing collaborative AI agent teams.
AI should drive results, not complexity. AgentemAI helps businesses build scalable, efficient, and secure AI solutions. See how we can help.