DEV Community

Pavel Koryagin
Pavel Koryagin

Posted on

Flow vs. Crew: The clash of CrewAI templates

Welcome to the least informative post of the whole series! 😁 Just a small heads-up. The really complex topic is for tomorrow.

ℹ️ This post is part of the “Crew AI Caveats” series, which I create to fill in the gaps left by official courses and to help you master CrewAI faster and easier.

These two commands create entry points that are structured very differently:

  • crewai create crew <name>
  • crewai create flow <name>

create crew version main.py:

def run():
    ...

def train():
    ...

def replay():
    ...

def test():
    ...

# No `if __name__ == "__main__"` statement at all
Enter fullscreen mode Exit fullscreen mode

create flow version main.py:

def kickoff():
    poem_flow = PoemFlow()
    poem_flow.kickoff()

def plot():
    poem_flow = PoemFlow()
    poem_flow.plot()

if __name__ == "__main__":
    kickoff()
Enter fullscreen mode Exit fullscreen mode

The difference is that the flow version is structured as a script entry point and the crew version is nonfunctional without the crewai run command.

Additionally, the crew version exports some interesting entrypoints, while the flow version does not. Not sure why—maybe because they design that the crews should be trained independently.

Stay tuned

In the next post: CrewAI hurts TDD fans! Let’s invent a cure.

Top comments (0)