Skip to main content
Workflows are deterministic, stateful, multi-agent programs that are built for production applications. They’re incredibly powerful and offer the following benefits:
  • Full control and flexibility: You have full control over the multi-agent process, how the input is processed, which agents are used and in what order. This is critical for reliability.
  • Pure python: Control the agent process using standard python. Having built 100s of AI products, no framework will give you the flexibility of pure-python.
  • Built-in state management and caching: Store state and cache intermediate results in a database, enabling your agents to re-use results from previous executions.
How to build a workflow:
  1. Define your workflow as a class by inheriting from the Workflow class.
  2. Add one or more agents to the workflow.
  3. Implement your logic in the run() method.
  4. Cache results in the session_state as needed.
  5. Run the workflow using the .run() method.

Example: Blog Post Generator

Let’s create a blog post generator that can search the web, read the top links and write a blog post for us. We’ll cache intermediate results in the database to improve performance.

Create the Workflow

Create a file blog_post_generator.py
blog_post_generator.py

Run the workflow

Install libraries
Run the workflow
Now the results are cached in the database and can be re-used for future runs. Run the workflow again to view the cached results.