Introduction

A unified framework for Python workflow orchestration. DAG pipelines, agentic workflows, and everything in between.

  • Unified - One framework for data pipelines and agentic AI. Same elegant code.

  • Hierarchical - Graphs nest as nodes. Build big from small, tested pieces.

  • Versatile - Sync, async, streaming. Branches, loops, human-in-the-loop. No limits.

  • Minimal - Pure functions with named outputs. Edges inferred automatically.

Quick Start

Define functions. Name their outputs. Hypergraph connects them automatically.

from hypergraph import Graph, node, SyncRunner

@node(output_name="embedding")
def embed(text: str) -> list[float]:
    # Your embedding model here
    return [0.1, 0.2, 0.3]

@node(output_name="docs")
def retrieve(embedding: list[float]) -> list[str]:
    # Your vector search here
    return ["Document 1", "Document 2"]

@node(output_name="answer")
def generate(docs: list[str], query: str) -> str:
    # Your LLM here
    return f"Based on {len(docs)} docs: answer to {query}"

# Edges inferred from matching names
graph = Graph(nodes=[embed, retrieve, generate])

# Run the graph
runner = SyncRunner()
result = runner.run(graph, {"text": "RAG tutorial", "query": "What is RAG?"})
print(result["answer"])

embed produces embedding. retrieve takes embedding. Connected automatically.

Why Hypergraph?

Pure Functions Stay Pure

Your functions are just functions. Test them directly, with any test framework.

Build-Time Validation

Type mismatches, missing connections, invalid configurations - caught when you build the graph, not at runtime.

Hierarchical Composition

Test pieces independently. Reuse across workflows.

Documentation

Getting Started

Core Concepts

  • Getting Started - Core concepts, creating nodes, building graphs, running workflows

Patterns

Real-World Examples

How-To Guides

API Reference

  • Graph - Graph construction, validation, and properties

  • Nodes - FunctionNode, GraphNode, and HyperNode

  • Gates - RouteNode, IfElseNode, @route, @ifelse

  • Runners - SyncRunner, AsyncRunner, and execution model

  • Events - Event types, processors, and RichProgressProcessor

  • InputSpec - Input categorization and requirements

Design

Design Principles

  1. Pure functions - Nodes are testable without the framework

  2. Automatic wiring - Edges inferred from matching output/input names

  3. Composition over configuration - Nest graphs, don't configure flags

  4. Unified execution - Topo over SCCs, local iteration for feedback

  5. Fail fast - Validate at build time, not runtime

  6. Explicit dependencies - All inputs visible in function signatures

Beyond AI/ML

While the examples focus on AI/ML use cases, hypergraph is a general-purpose workflow framework. It has no dependencies on LLMs, vector databases, or any AI tooling. Use it for any multi-step workflow: ETL pipelines, business process automation, testing harnesses, or anything else that benefits from graph-based orchestration.

Last updated