Skip to main content

Production-ready orchestration for AI agents, built with Pydantic.

Project description

Flujo Logo

Flujo

A powerful Python library for orchestrating AI workflows using Pydantic models. The flujo package (repository hosted at github.com/aandresalvarez/flujo) provides utilities to manage multi-agent pipelines with minimal setup.

Features

  • 📦 Pydantic Native – agents, tools, and pipeline context are all defined with Pydantic models for reliable type safety.
  • 🔁 Opinionated & Flexible – the Default recipe gives you a ready‑made workflow while the DSL lets you build any pipeline.
  • 🏗️ Production Ready – retries, telemetry, and quality controls help you ship reliable systems.
  • 🧠 Intelligent Evals – automated scoring and self‑improvement powered by LLMs.

Quick Start

Installation

pip install flujo

Basic Usage

from flujo.recipes import Default
from flujo import (
    Task,
    review_agent, solution_agent, validator_agent,
    init_telemetry,
)

# Optional: enable telemetry for your application
init_telemetry()

# Assemble an orchestrator with the library-provided agents. The class
# runs a fixed pipeline: Review -> Solution -> Validate.
flujo = Default(
    review_agent=review_agent,
    solution_agent=solution_agent,
    validator_agent=validator_agent,
)

# Define a task
task = Task(prompt="Write a Python function to calculate Fibonacci numbers")

# Run synchronously
best_candidate = flujo.run_sync(task)

# Print the result
if best_candidate:
    print("Solution:\n", best_candidate.solution)
    if best_candidate.checklist:
        print("\nQuality Checklist:")
        for item in best_candidate.checklist.items:
            status = "✅ Passed" if item.passed else "❌ Failed"
            print(f"  - {item.description:<45} {status}")
else:
    print("No solution found.")

Pipeline Example

from flujo import (
    Step, Flujo, Task,
    review_agent, solution_agent, validator_agent,
)

# Build a custom pipeline using the Step DSL. This mirrors the internal
# workflow used by :class:`Default` but is fully configurable.
custom_pipeline = (
    Step.review(review_agent)
    >> Step.solution(solution_agent)
    >> Step.validate(validator_agent)
)

pipeline_runner = Flujo(custom_pipeline)

# Run synchronously; Flujo returns a PipelineResult.
pipeline_result = pipeline_runner.run(
    "Generate a REST API using FastAPI for a to-do list application."
)

print("\nPipeline Execution History:")
for step_res in pipeline_result.step_history:
    print(f"- Step '{step_res.name}': Success={step_res.success}")

if len(pipeline_result.step_history) > 1 and pipeline_result.step_history[1].success:
    solution_output = pipeline_result.step_history[1].output
    print("\nGenerated Solution:\n", solution_output)

Documentation

Getting Started

User Guides

Advanced Topics

Development

Examples

Check out the examples directory for more usage examples:

Script What it shows
00_quickstart.py Hello World with the Default recipe.
01_weighted_scoring.py Weighted scoring to prioritize docstrings.
02_custom_agents.py Building creative agents with custom prompts.
03_reward_scorer.py Using an LLM judge via RewardScorer.
04_batch_processing.py Running multiple workflows concurrently.
05_pipeline_sql.py Pipeline DSL with SQL validation plugin.
06_typed_context.py Sharing state with Typed Pipeline Context.
07_loop_step.py Iterative refinement using LoopStep.
08_branch_step.py Dynamic routing with ConditionalStep.

Looking for more community resources? Check out the Awesome Flujo list.

Requirements

  • Python 3.11 or higher
  • OpenAI API key (for OpenAI models)
  • Anthropic API key (for Claude models)
  • Google API key (for Gemini models)

Installation

Basic Installation

pip install flujo

Development Installation

# Clone the repository
git clone https://github.com/aandresalvarez/flujo.git
cd flujo

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Linux/macOS
# or
.\venv\Scripts\activate  # Windows

# Install development dependencies
pip install -e ".[dev]"

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

License

This project is dual-licensed:

  1. Open Source License: GNU Affero General Public License v3.0 (AGPL-3.0)

    • Free for open-source projects
    • Requires sharing of modifications
    • Suitable for non-commercial use
  2. Commercial License

    • For businesses and commercial use
    • Includes support and updates
    • No requirement to share modifications
    • Contact for pricing and terms

For commercial licensing, please contact: alvaro@example.com

See LICENSE and COMMERCIAL_LICENSE for details.

Acknowledgments

Citation

If you use this project in your research, please cite:

@software{flujo,
  author = {Alvaro Andres Alvarez},
  title = {Flujo},
  year = {2024},
  url = {https://github.com/aandresalvarez/flujo}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flujo-0.4.1.tar.gz (123.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flujo-0.4.1-py3-none-any.whl (57.0 kB view details)

Uploaded Python 3

File details

Details for the file flujo-0.4.1.tar.gz.

File metadata

  • Download URL: flujo-0.4.1.tar.gz
  • Upload date:
  • Size: 123.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for flujo-0.4.1.tar.gz
Algorithm Hash digest
SHA256 3de37b481ae55a556370401630dd47a78463d2400166cd15b5dfff0aaacb03b6
MD5 191df1c742b21dd9d31a883b04d54c53
BLAKE2b-256 de8db12a8d8b54d77288a31d4d6588561011e157bc1acedc21a7ac34fb9b68c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for flujo-0.4.1.tar.gz:

Publisher: release.yml on aandresalvarez/flujo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flujo-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: flujo-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 57.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for flujo-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebecd92f9e3856455d6c6e9b5999df417e4fee300ce16f53c06010ffd2b4ec35
MD5 d9d855958bd4e12246c2edfa7dd3ba69
BLAKE2b-256 c8dd11a0716186bea26ef37976fcfad95760751a1aed02e0b7249977b47cc2d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for flujo-0.4.1-py3-none-any.whl:

Publisher: release.yml on aandresalvarez/flujo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page