Skip to main content

Deterministic regression enforcement for LLM systems.

Project description

Phylax Logo

Phylax

Deterministic regression enforcement for LLM systems.

Python 3.10+ PyPI version License: MIT


The Problem

LLM outputs change unexpectedly. Same prompt, different model version → different behavior. Without Phylax, you discover this in production.

Installation

pip install phylax

For all LLM providers (OpenAI, Gemini, Groq, Mistral, HuggingFace, Ollama):

pip install phylax[all]

Individual providers:

pip install phylax[openai]       # OpenAI
pip install phylax[google]       # Gemini (google-genai SDK)
pip install phylax[groq]         # Groq LPU
pip install phylax[mistral]      # Mistral AI
pip install phylax[huggingface]  # HuggingFace Inference API
pip install phylax[ollama]       # Ollama (local models)

Quick Start

from phylax import trace, expect, execution, GeminiAdapter

@trace(provider="gemini")
@expect(must_include=["hello"], max_latency_ms=5000)
def greet(name: str):
    """Traced Gemini call with expectations."""
    adapter = GeminiAdapter()
    response, _ = adapter.generate(
        prompt=f"Say hello to {name}",
        model="gemini-2.5-flash",
    )
    return response

# Single call
result = greet("World")
print(result.text)

# Track multi-step agent flows
with execution() as exec_id:
    step1 = greet("Alice")
    step2 = greet("Bob")
# Start the UI server
phylax server
# Open http://127.0.0.1:8000/ui

# Mark a known-good response as baseline
phylax bless <trace_id>

# In CI: fail if output regresses
phylax check  # exits 1 on failure

That's it. Your CI now blocks LLM regressions.


Supported Providers

Provider Adapter Env Variable
OpenAI OpenAIAdapter OPENAI_API_KEY
Gemini GeminiAdapter GOOGLE_API_KEY
Groq GroqAdapter GROQ_API_KEY
Mistral MistralAdapter MISTRAL_API_KEY
HuggingFace HuggingFaceAdapter HF_TOKEN
Ollama OllamaAdapter OLLAMA_HOST
from phylax import OpenAIAdapter, GroqAdapter, MistralAdapter

# All adapters share the same interface
adapter = GroqAdapter()
response, trace = adapter.generate(prompt="Hello!", model="llama3-70b-8192")

What Phylax is NOT

  • Not monitoring — no metrics, no dashboards
  • Not observability — no traces-to-cloud, no analytics
  • Not AI judgment — rules are deterministic, not LLM-based
  • Not cloud-dependent — runs entirely local
  • Not prompt engineering — tests outputs, not prompts

Phylax is a test framework. It tells you when LLM behavior changes.


CI Integration

# .github/workflows/phylax.yml
- run: phylax check
  env:
    GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}

Exit codes:

  • 0 — All golden traces pass
  • 1 — Regression detected

Commands

Command What it does
phylax init Initialize config
phylax server Start API server + UI
phylax list List traces
phylax list --failed Show only failed traces
phylax show <id> Show trace details
phylax replay <id> Re-run a trace
phylax bless <id> Mark as golden baseline
phylax check CI regression check

Features

Feature Description
Trace Capture Record every LLM call automatically
Expectations Validate with @expect rules
Execution Context Group traces by execution() context
Golden Traces Baseline comparisons with hash verification
Golden Reference UI ⭐ Bless/unbless traces from web interface
Trace ID Search 🔍 Search traces by ID in sidebar
CI Integration phylax check exits 1 on regression
Web UI View traces at http://127.0.0.1:8000/ui
Multi-Provider OpenAI, Gemini, Groq, Mistral, HuggingFace, Ollama

Demos

See the demos/ directory for runnable examples:

python demos/01_basic_trace.py      # Basic tracing
python demos/02_expectations.py     # All @expect rules
python demos/03_execution_context.py # Trace grouping
python demos/04_graph_nodes.py      # Graph API
python demos/05_golden_workflow.py  # CI workflow
python demos/06_raw_evidence.py     # Evidence API
python demos/07_error_contracts.py  # Error codes

Documentation


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

phylax-1.1.6.tar.gz (6.8 MB view details)

Uploaded Source

Built Distribution

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

phylax-1.1.6-py3-none-any.whl (6.8 MB view details)

Uploaded Python 3

File details

Details for the file phylax-1.1.6.tar.gz.

File metadata

  • Download URL: phylax-1.1.6.tar.gz
  • Upload date:
  • Size: 6.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for phylax-1.1.6.tar.gz
Algorithm Hash digest
SHA256 241477a77c709cedbc37e2f0aa086b0f7b8a6d303bb8806e952c7bc0a2764d4e
MD5 af3aba3cfade641466de5a88a8c9927b
BLAKE2b-256 4d3e389c24936807aa3d8b05e4fc8c648ac70350612beace77b08f37a86259ed

See more details on using hashes here.

File details

Details for the file phylax-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: phylax-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for phylax-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 240e66caa268989461d34f5318c6ca20961aba5f3d3d8e18102e731b58b3ae2d
MD5 2b07ad8f37cfacbe5a575d504871f3eb
BLAKE2b-256 3f3f384d8ec76519071e365fe654c2257fe590a320c5566ce1a462945b9b5d62

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