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 AgenticLoop
from flujo import make_agent_async, init_telemetry
from flujo.domain.commands import AgentCommand
from pydantic import TypeAdapter

# Enable telemetry (optional but recommended)
init_telemetry()

async def search_agent(query: str) -> str:
    """A simple tool agent that returns information."""
    if "python" in query.lower():
        return "Python is a high-level, general-purpose programming language."
    return "No information found."

PLANNER_PROMPT = """
You are a research assistant. Use the `search_agent` tool to gather facts.
When you know the answer, issue a `FinishCommand` with the final result.
"""
planner = make_agent_async(
    "openai:gpt-4o",
    PLANNER_PROMPT,
    TypeAdapter(AgentCommand),
)

loop = AgenticLoop(planner_agent=planner, agent_registry={"search_agent": search_agent})
result = loop.run("What is Python?")
print(result.final_pipeline_context.command_log[-1].execution_result)

Pipeline Example

from flujo import Flujo, step, PipelineResult

@step
async def to_uppercase(text: str) -> str:
    """A simple step to convert text to uppercase."""
    return text.upper()

@step
async def add_enthusiasm(text: str) -> str:
    """A second step to add emphasis."""
    return f"{text}!!!"

# Compose the pipeline using the decorator-created steps
pipeline = to_uppercase >> add_enthusiasm
runner = Flujo(pipeline)

# Run the pipeline
result: PipelineResult[str] = runner.run("hello world")

print(f"Final pipeline output: {result.step_history[-1].output}")
# Expected Output: Final pipeline output: HELLO WORLD!!!

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 AgenticLoop 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]"

# Set up the Hatch environment for tooling
pip install hatch
make setup

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.15.tar.gz (134.4 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.15-py3-none-any.whl (62.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flujo-0.4.15.tar.gz
  • Upload date:
  • Size: 134.4 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.15.tar.gz
Algorithm Hash digest
SHA256 ea0cdd8008e717258ef793aaccbbfe7e2760d49e2da75284994fce3679dd6e27
MD5 e46e82a30f0f127d383c89b819413d75
BLAKE2b-256 4dded2281a282aac7941cd84825f22d30cbd9fa62e14d9d43bd57431e6db16f6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: flujo-0.4.15-py3-none-any.whl
  • Upload date:
  • Size: 62.8 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.15-py3-none-any.whl
Algorithm Hash digest
SHA256 57afcb7d6d67aea5d423ebdaf4e6e958271132ecd04787370111a8500f8cb12c
MD5 f5eaf3592d0d85a14e0896a2b2c541c9
BLAKE2b-256 8ed0ebc35ae4449e87b9529307d50b8707d7398ac7e4689ea4fa1566f3a6dcac

See more details on using hashes here.

Provenance

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