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.0.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.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_drift_ctl-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 abebdbe3adcd8f5df64e35ea03c5fa8db9171c2cfc7659c122440826d5cce23b
MD5 2c5529b618444275ef4abeb91438e6b3
BLAKE2b-256 b817b21238f18dc5e6697c40f2fe90265a4e7d6dd8a97c206cac305163d28fbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llm_drift_ctl-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 326e84ad732357e39935ee5fdf7a8cddd9d90e3e9d5a2468eab0c45b06e50b1b
MD5 86992510529f49c7b84d2e93b91699e6
BLAKE2b-256 d7462761892c1fbe36dcad7b34eeaf35e432b6efecb40608a9237a892309927c

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