Skip to main content

Sequa 📼

Deterministic testing for AI applications.

Record once. Replay forever.

PyPI Python License


Stop paying for every AI test run.

Every time your AI application runs during testing, it probably:

  • 💸 Calls the LLM again
  • 🐢 Slows down your CI pipeline
  • 🎲 Produces slightly different outputs
  • 🌐 Depends on internet connectivity

Sequa records a real AI execution once and replays it locally during future test runs.

The result

  • ⚡ Millisecond replay
  • 💰 Zero replay API costs
  • 🧪 Deterministic testing
  • 💻 Works offline

Before

from langchain_groq import ChatGroq

model = ChatGroq(model_name="llama-3.1-8b-instant")

response = model.invoke(
    "Write a 3-word slogan for gravity."
)

# ⏱️ 2.3 seconds
# 🌐 Live API Call

After

from langchain_groq import ChatGroq
from sequa import cassette

model = ChatGroq(model_name="llama-3.1-8b-instant")

with cassette("tests/cassettes"):
    response = model.invoke(
        "Write a 3-word slogan for gravity."
    )

# First Run
# ⏱️ 2.3 seconds
# 🌐 Live API Call
# 💾 Recorded

# Every Run After
# ⏱️ 12 ms
# ❌ No API Calls
# 📼 Replayed Locally

Why Sequa?

Without Sequa With Sequa
Calls the LLM on every test Record once, replay forever
Seconds of latency Millisecond replay
API cost every execution No replay API cost
Internet required Works offline
Non-deterministic Deterministic

Supported Frameworks

  • ✅ OpenAI
  • ✅ Anthropic
  • ✅ LangChain
  • ✅ LangGraph

Installation

pip install sequa

or

uv add sequa

Quick Start

from langchain_groq import ChatGroq
from sequa import cassette

model = ChatGroq(model_name="llama-3.1-8b-instant")

with cassette("tests/cassettes"):
    response = model.invoke("Hello Sequa!")

That's it.

The first execution records the response.

Every matching execution after that replays it locally without calling the LLM.


Features

  • 🔎 Searchable AI Executions & Instant Replay (v0.5.0): Find past executions with TF-IDF cosine similarity (sequa search "refund" --since yesterday) and generate local replay code (sequa replay <hash>).
  • 📼 Record once, replay forever
  • ⚡ Replay, Record, Auto and Live execution modes
  • 🧰 Tool Calling & Function Calling support
  • 🌊 Streaming support (sync & async)
  • 🔒 PII & Sensitive Information Masking
  • 🛡️ NVIDIA NeMo Guardrails Integration
  • 🧠 Deterministic request hashing
  • 🎯 Custom ignored fields
  • 🔧 Custom request normalizers
  • 🗂️ File, Memory & PostgreSQL storage backends
  • 🧹 CLI utilities (search, replay, log, stats, inspect, clean)

Searchable AI Executions & Instant Replay (v0.5.0)

When a bug is reported ("The AI gave the wrong answer yesterday"), Sequa makes it reproducible in seconds:

# 1. Search past executions by TF-IDF cosine similarity & relative time
sequa search "refund request failed" --since yesterday -i

# 2. Inspect target execution and get instant Python replay code
sequa replay 1cea06570793

# 3. View chronological Git-like execution history
sequa log --path cassettes -n 5

Or query programmatically via Python API:

from sequa import search_cassettes

# Search recorded executions by natural language & metadata
results = search_cassettes(query="refund request", since="yesterday", provider="openai")

for res in results:
    print(f"Match Score: {res.score:.4f} | Hash: {res.hash[:12]}")
    print(f"  Input:  {res.input_snippet}")
    print(f"  Output: {res.output_snippet}")

CLI Reference

Sequa includes a built-in CLI to search, inspect, format, and debug your recorded cassettes:

Command Description Example
sequa diff Compare two cassette executions (text, markdown, html formats) sequa diff hash1 hash2 -f html -o diff.html
sequa search Search executions by vector cosine similarity, time window, or provider/model sequa search "refund" --since yesterday -i
sequa log Show Git-like chronological execution log sequa log --path cassettes -n 10
sequa replay Inspect a target cassette and generate copy-paste Python replay code sequa replay 1cea06570793
sequa stats View total cassette count, disk size, and saved API latency sequa stats --path cassettes
sequa inspect List all saved cassettes with providers, models, and timestamps sequa inspect --path cassettes
sequa clean Redact volatile timestamps and latency before committing to Git sequa clean --remove-latency --remove-timestamps

Cassette Execution Diffing (sequa diff) 🔍

Compare any two recorded cassettes by hash, ID, or file path to inspect prompt, model, parameter, or output differences:

# 1. Compare two cassette executions in terminal text mode
sequa diff 1cea06570793 4b93d6e3 --path cassettes

# 2. Export diff comparison report to GitHub Markdown
sequa diff 1cea06570793 4b93d6e3 -f markdown -o diff.md

# 3. Export standalone styled HTML diff report
sequa diff 1cea06570793 4b93d6e3 -f html -o diff.html

# 4. Interactive Diff from Search Results
sequa search "refund request" -i
# Enter result numbers to diff (e.g., '1,2' or 'diff 1 2'):

Pytest Integration 🧪

Sequa includes built-in Pytest support via the sequa plugin.

Markers & Fixtures

Use @pytest.mark.sequa (or alias @pytest.mark.cassette) or inject the sequa_cassette fixture:

import pytest
from langchain_groq import ChatGroq

@pytest.mark.sequa(mode="auto")
def test_llm_feature():
    model = ChatGroq(model_name="llama-3.1-8b-instant")
    response = model.invoke("Say hello")
    assert "hello" in response.content.lower()

def test_with_fixture(sequa_cassette):
    model = ChatGroq(model_name="llama-3.1-8b-instant")
    response = model.invoke("Hello world")

Pytest CLI Flags

Flag Description Default
--sequa-mode=<mode> Globally override cassette mode (auto, record, replay, live) Marker / auto
--sequa-path=<path> Set base cassette directory tests/cassettes
--sequa-mask-pii Enable PII masking across all test cassette recordings False

GitHub Actions Integration 🐙

Run deterministic LLM snapshot tests in CI/CD with zero API costs using the official Sequa GitHub Action.

Quick Workflow Setup

Add .github/workflows/ai-tests.yml to your repository:

name: AI Snapshot Tests

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run Sequa LLM Tests
        uses: thetechnoadvisor/sequa@v1
        with:
          mode: replay
          cassette-path: tests/cassettes
          post-summary: true

Action Options

Input Description Default
mode Execution mode (replay, auto, record, live) replay
cassette-path Path to saved cassette files directory tests/cassettes
python-version Python version for setup 3.12
pytest-args Additional arguments passed to pytest ""
post-summary Post cassette stats report to $GITHUB_STEP_SUMMARY true

Common Use Cases

🚀 Speed up AI integration tests

Run your test suite in milliseconds instead of waiting for repeated LLM calls.


💰 Reduce API costs

Replay previously recorded executions without paying for another API request.


🧪 Deterministic testing

Replay the exact same execution every time.


💻 Offline development

Develop and test AI applications without internet connectivity.


🐞 Reproduce bugs

Replay the exact LLM interaction that caused the issue.


Storage Backends

Sequa supports multiple storage backends.

  • 📁 File Storage
  • 🧠 In-Memory Storage
  • 🐘 PostgreSQL Storage

Choose whichever fits your workflow.


Documentation

Comprehensive documentation is available at:

👉 https://sequa.thetechnoadvisor.com/docs


Contributing

Contributions are always welcome.

  • ⭐ Star the repository
  • 🐞 Report bugs
  • 💡 Suggest new features
  • 🔧 Open a Pull Request

License

MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sequa-0.6.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

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

sequa-0.6.0-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file sequa-0.6.0.tar.gz.

File metadata

  • Download URL: sequa-0.6.0.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sequa-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2c3dc5032834c40560e2566eecbcb614cf3a4831f8fbcb20700f625bff8a65f0
MD5 310b243151f5503681bcfdf98c51802b
BLAKE2b-256 21d31af44b141d448c0180a11970e7c209e47269bbfc952efd8cb667cf4a364b

See more details on using hashes here.

File details

Details for the file sequa-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: sequa-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sequa-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03f10fd7b445c89b5038f45061c90bba3680b59e74f96b16336a81228c928999
MD5 b1b882f0691d43ff51dd369533cb9756
BLAKE2b-256 10f001a4f7c1c91124b673f7b74e3e444e95002fb734e490f540cb080b9cd17e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.8.0

2 files

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page