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 Minimal, single-task run (ratio scorer).
01_weighted_scoring.py Passing custom checklist weights.
02_custom_agents.py Mixing models or replacing the solution agent.
03_reward_scorer.py Using the reward-model scorer.
04_batch_processing.py Running many prompts from a CSV and exporting results.
05_pipeline_sql.py DSL pipeline with SQL validation plugin.
06_typed_context.py Sharing state across steps using TypedPipelineContext.
07_loop_step.py Iterative refinement with LoopStep.
08_branch_step.py Conditional routing with ConditionalStep.

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.3.1.tar.gz (96.9 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.3.1-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flujo-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3de88d74fece278923462808de22aae38f81647c1045e848ce9e988cd183b55f
MD5 15d7f47b1fc20c2f5139d0ed7493face
BLAKE2b-256 daabeca67136de90dab239f2624f7c62f722017afa3d515e8c08859d397f53b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for flujo-0.3.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.3.1-py3-none-any.whl.

File metadata

  • Download URL: flujo-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 43.6 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54567cffe84e4f2775c9062bcd766039a514482cb087d25444bda1cbb08c42f9
MD5 b3a6600bedc0310965b0c91b426ce150
BLAKE2b-256 4bfef480c0a61cb2418a313899bfe2a695bc65d245ce7e41bce8646a3c9c0712

See more details on using hashes here.

Provenance

The following attestation bundles were made for flujo-0.3.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