Skip to main content

Production-grade LLM output validation package. Validates LLM outputs using your own LLM when needed — and no LLM when not.

Project description

llm-drift-ctl (Python)

llm-drift-ctl is a drop-in guard that validates LLM outputs using your own LLM when needed — and no LLM when not.

Production-grade LLM output validation package for Python. This package does NOT generate content. It validates LLM outputs after they are produced.

Installation

pip install llm-drift-ctl

Quick Start

FORMAT Mode (LLM-free, fully offline)

from llm_drift_ctl import DriftGuard, DriftGuardConfig

guard = DriftGuard(DriftGuardConfig(pipeline_id="my-pipeline"))

# Check JSON format (using keyword arguments)
result = await guard.check(
    json={"name": "John", "age": 30},
    mode="FORMAT"
)

# Or using CheckInput object
from llm_drift_ctl import CheckInput
result = await guard.check(
    CheckInput(json={"name": "John", "age": 30}, mode="FORMAT")
)

print(result)
# CheckResult(
#     block=False,
#     decision='ALLOW',
#     severity='LOW',
#     scores={'format': 1.0},
#     where=[]
# )

CONTENT Mode (requires your LLM)

from llm_drift_ctl import DriftGuard, DriftGuardConfig, UserLLM

# Implement your LLM adapter
class MyLLM(UserLLM):
    async def generate(self, prompt, text=None, json=None):
        # Call OpenAI, Gemini, Claude, or your custom LLM
        # You provide your own API key
        return "response from your LLM"

guard = DriftGuard(DriftGuardConfig(
    pipeline_id="my-pipeline",
    llm=MyLLM(),
    api_key="your-license-key"  # for cloud license verification
))

# Accept a baseline (approved output)
await guard.accept_baseline(json={"name": "John", "age": 30})

# Check against baseline
result = await guard.check(
    json={"name": "Jane", "age": 25},
    mode="CONTENT"
)

API Reference

See the main README.md for full documentation.

The Python API mirrors the Node.js API exactly.

License

MIT

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

llm_drift_ctl-0.1.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

llm_drift_ctl-0.1.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_drift_ctl-0.1.2.tar.gz.

File metadata

  • Download URL: llm_drift_ctl-0.1.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for llm_drift_ctl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ee78d7bd517d54fdf53690b21f1e4e1a351ec65e4389dbe3ead694c899591396
MD5 061e2d1c2a4e6a6dc97647787de937c8
BLAKE2b-256 7f87717bc92c1981cf13afca9ffdc99a7e642de313dc3d438fb1030add7ee4b3

See more details on using hashes here.

File details

Details for the file llm_drift_ctl-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: llm_drift_ctl-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for llm_drift_ctl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f3243ace2a58f4b811196443fe2b470b27ab15d6965ae6e163333dce19a1dfb0
MD5 4d916c433186729049263f2b8c8379cf
BLAKE2b-256 4c1a943e3248572a47f327e0071d7fd214cae8e69d4a83c9293b5414047f1cd9

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