From b0f9637662dda1b182ef5a7ebfddab57560ca66e Mon Sep 17 00:00:00 2001 From: theadityarao <63926883+theadityarao@users.noreply.github.com> Date: Tue, 1 Apr 2025 23:01:22 +0530 Subject: [PATCH] fix documentation for "Using Crews and Flows Together" (#2490) * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: Lorenze Jay <63378463+lorenzejay@users.noreply.github.com> --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b44ff6f4f..a1bf63645 100644 --- a/README.md +++ b/README.md @@ -401,11 +401,16 @@ You can test different real life examples of AI crews in the [CrewAI-examples re ### Using Crews and Flows Together -CrewAI's power truly shines when combining Crews with Flows to create sophisticated automation pipelines. Here's how you can orchestrate multiple Crews within a Flow: +CrewAI's power truly shines when combining Crews with Flows to create sophisticated automation pipelines. +CrewAI flows support logical operators like `or_` and `and_` to combine multiple conditions. This can be used with `@start`, `@listen`, or `@router` decorators to create complex triggering conditions. +- `or_`: Triggers when any of the specified conditions are met. +- `and_`Triggers when all of the specified conditions are met. + +Here's how you can orchestrate multiple Crews within a Flow: ```python -from crewai.flow.flow import Flow, listen, start, router -from crewai import Crew, Agent, Task +from crewai.flow.flow import Flow, listen, start, router, or_ +from crewai import Crew, Agent, Task, Process from pydantic import BaseModel # Define structured state for precise control @@ -479,7 +484,7 @@ class AdvancedAnalysisFlow(Flow[MarketState]): ) return strategy_crew.kickoff() - @listen("medium_confidence", "low_confidence") + @listen(or_("medium_confidence", "low_confidence")) def request_additional_analysis(self): self.state.recommendations.append("Gather more data") return "Additional analysis required"