Skip to main content

Add your description here

Project description

Sequa 📼

Sequa is snapshot testing for LLM applications. Record once, replay forever.


The Magic

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.")
# ⏱️ Time taken: 2.3 seconds

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 (recorded to tests/cassettes/)
    # ⏱️ Second run: 12 ms (replayed locally!)

Features

  • Record once, replay forever: Speed up integration test suites from minutes to milliseconds.
  • Multiple Execution Modes: Support replay, record, auto, and live modes.
  • Robust Key Sorting & Hashing: Recursively sorts request inputs to generate deterministic hashes.
  • Custom Ignored Fields: Easily ignore dynamic/unstable fields (e.g. temperature, max_tokens).
  • Custom Normalizers: Redact, replace, or clean requests prior to hashing.
  • CLI Utilities: Inspect, format, and calculate statistics of stored cassettes.

Installation

uv pip install -e .

Configuration & Advanced API

1. Execution Modes

Control Sequa behavior via the mode parameter:

with cassette("tests/cassettes", mode="replay"):
    # Will raise CassetteNotFoundError if no matching cassette is found.
    # Guaranteed to make zero external network requests.
  • auto (Default): Replays if a matching cassette exists, otherwise calls the live API and records it.
  • record: Always calls the live API and records/overwrites the cassette.
  • replay: Never calls the live API. Raises CassetteNotFoundError on cache misses.
  • live: Direct pass-through to the live API, bypassing cassettes entirely.

2. Ignore Fields

Strip request parameters before generating hashes:

with cassette("tests/cassettes", ignore_fields=["temperature", "max_tokens"]):
    # These two calls generate the exact same hash and match the same cassette:
    model.invoke("hello", temperature=0.2)
    model.invoke("hello", temperature=0.9)

3. Custom Normalizers

For complex normalization or content redaction:

def redact_dates(request_dict):
    # Redact dynamic inputs or strip timestamps
    return request_dict

with cassette("tests/cassettes", normalizer=redact_dates):
    model.invoke(...)

Command Line Interface (CLI)

Sequa comes with a CLI tool to manage your cassettes.

Stats

Show the number of cassettes, total size on disk, and estimated API latency saved:

sequa stats --path ./tests/cassettes

Inspect

List all stored cassettes, their model, provider, and when they were recorded:

sequa inspect --path ./tests/cassettes

Clean

Clean dynamic fields (latency, created_at) from cassettes to prevent noisy git diffs:

sequa clean --path ./tests/cassettes --remove-latency --remove-timestamps

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

sequa-0.0.1.tar.gz (10.7 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.0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sequa-0.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sequa-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e770a942288194a90879983fe94612cb054b71a7ce999eb5477a7fabcda84b42
MD5 bcd14bb7a50800b8972daf5898f0227e
BLAKE2b-256 a7d371068340b29e8716475f7029f4e53b96531b594d512bcc7f77b663ac7086

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sequa-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sequa-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc92b2b39114655bb87e3cd0123d643cf714e6c6e26d28f76039a84647ceaf4b
MD5 ae5ad938edcdce5dc05cf29e3f2ef03f
BLAKE2b-256 848f57001ae42e8f46678ce1e1a6dca889f954ea72a2da416c8087e5cfe1b245

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