Create a New CrewAI Pipeline Template Method
Creating a CrewAI Pipeline Project
Welcome to the comprehensive guide for creating a new CrewAI pipeline project. This document will walk you through the steps to create, customize, and run your CrewAI pipeline project, ensuring you have everything you need to get started.
To learn more about CrewAI pipelines, visit the CrewAI documentation.
Prerequisites
Before getting started with CrewAI pipelines, make sure that you have installed CrewAI via pip:
The same prerequisites for virtual environments and Code IDEs apply as in regular CrewAI projects.
Creating a New Pipeline Project
To create a new CrewAI pipeline project, you have two options:
- For a basic pipeline template:
- For a pipeline example that includes a router:
These commands will create a new project folder with the following structure:
Customizing Your Pipeline Project
To customize your pipeline project, you can:
- Modify the crew files in
src/<project_name>/crews/
to define your agents and tasks for each crew. - Modify the pipeline files in
src/<project_name>/pipelines/
to define your pipeline structure. - Modify
src/<project_name>/main.py
to set up and run your pipelines. - Add your environment variables into the
.env
file.
Example 1: Defining a Two-Stage Sequential Pipeline
Here’s an example of how to define a pipeline with sequential stages in src/<project_name>/pipelines/pipeline.py
:
Example 2: Defining a Two-Stage Pipeline with Parallel Execution
Annotations
The main annotation you’ll use for pipelines is @PipelineBase
. This annotation is used to decorate your pipeline classes, similar to how @CrewBase
is used for crews.
Installing Dependencies
To install the dependencies for your project, use uv
the install command is optional because when running crewai run
, it will automatically install the dependencies for you:
Running Your Pipeline Project
To run your pipeline project, use the following command:
This will initialize your pipeline and begin task execution as defined in your main.py
file.
Deploying Your Pipeline Project
Pipelines can be deployed in the same way as regular CrewAI projects. The easiest way is through CrewAI+, where you can deploy your pipeline in a few clicks.
Remember, when working with pipelines, you’re orchestrating multiple crews to work together in a sequence or parallel fashion. This allows for more complex workflows and information processing tasks.
Was this page helpful?