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.11.tar.gz (125.1 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.11-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flujo-0.4.11.tar.gz
  • Upload date:
  • Size: 125.1 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.11.tar.gz
Algorithm Hash digest
SHA256 c61940c6d5f321f2f00a37a4f61c1e9ac5993249efe6596426e491834487a909
MD5 28de1b6fac809bf6e17b896734693b8f
BLAKE2b-256 91b2065aaf1be9ff1bf2a540857a9c6f7c09ee8f13f64b4cd3504f6ea9d676cd

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: flujo-0.4.11-py3-none-any.whl
  • Upload date:
  • Size: 58.1 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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 366dae193299dfa1f5ea41f9ca59ccd5850a6ab177be222bde6c955ebd427009
MD5 ab3f97acb2d32787aca19c4bf0b6994d
BLAKE2b-256 115092ee92432cc4c9b529bb519d362285f7432b9a97117eaf0a67c0692faee5

See more details on using hashes here.

Provenance

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