Skip to main content

A flexible workflow system for LLM applications

Project description

Hapax

A flexible workflow system for LLM applications with built-in observability.

Features

  • Simple, intuitive workflow creation
  • Built-in OpenTelemetry tracing
  • Type-safe workflow validation
  • Parallel and conditional execution
  • LangChain integration

Installation

pip install hapax

Quick Start

from hapax.workflow import Workflow

# Create a simple workflow
workflow = (
    Workflow()
    .add(load_document)
    .add(split_text)
    .add(create_embeddings)
    .add(search_relevant)
    .add(generate_answer)
)

# Run with tracing
result = await workflow.run(
    input={"document": doc, "question": "What is...?"},
    trace=True
)

RAG with Observability Example

The examples/rag_with_observability.py demonstrates how to build a Retrieval-Augmented Generation (RAG) pipeline with built-in observability using Hapax. This example showcases:

  • Processing both text and tabular data
  • Using LangChain's MultiVectorRetriever for improved retrieval
  • Adding observability using the @obs decorator
  • Error handling and state management
  • Type-safe workflow validation

To run the example:

  1. Install required dependencies:
pip install -r requirements.txt
  1. Set your OpenAI API key:
export OPENAI_API_KEY=your-api-key
  1. Run the test script:
python examples/test_rag_pipeline.py

The example will demonstrate:

  • Loading and processing semi-structured data (text and tables)
  • Generating summaries for improved retrieval
  • Answering questions using both context types
  • Observability metrics and tracing throughout the pipeline

Development

  1. Clone the repository:
git clone https://github.com/teilomillet/hapax-py.git
cd hapax-py
  1. Create a virtual environment and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,test]"
  1. Run tests:
pytest tests/ -v

License

MIT License

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

hapax-0.1.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

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

hapax-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file hapax-0.1.0.tar.gz.

File metadata

  • Download URL: hapax-0.1.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.18

File hashes

Hashes for hapax-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1bdae1a718921ef8347671afd6a7501d598f3fd0ebe2c181321fadc725b15ffb
MD5 0ef5dcd789b0c92da2819330be0ffa2d
BLAKE2b-256 706a893dd13185f12f45e9b3a529c975f0f0067029c1c581cbcf52dd755081b3

See more details on using hashes here.

File details

Details for the file hapax-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hapax-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.18

File hashes

Hashes for hapax-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63951524053072cfac6a302fa28b3be740863d1ecee6855909c51576fe6e4dbb
MD5 1df3fea0f903b241c915cd1f7156bb7a
BLAKE2b-256 5e1c1ca04e02d31fd33451712a761995a4e5a040adc9bd76f9c47ae685b082e4

See more details on using hashes here.

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