Skip to main content

Prompt guard library for composing multiple safety checks.

Project description

Prompt Guard

Composable prompt-safety guards as a lightweight Python library. It provides:

  • TF‑IDF guard for fast lexical similarity against known phrases.
  • RAG guard for embedding-based retrieval against a sentence corpus.
  • LLM judge for a final model-based classification.

Quick start

from prompt_guard import GuardPipeline, PromptGuardConfig

cfg = PromptGuardConfig(
    embed_model_name="mxbai-embed-large",
    judge_model_name="qwen2.5:3b-instruct",
)
guard = GuardPipeline(cfg)
result = await guard.check("Some prompt")

Notes

  • TF‑IDF and RAG build in‑memory indexes at first use.
  • RAG and LLM judge use local Ollama models by default; ensure Ollama is running and the models are pulled.

Text file formats

  • phrases.txt: one phrase per line (blank lines are ignored).
  • sentences.txt: one sentence per line (blank lines are ignored).

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

prompt_firewall-0.1.5.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

prompt_firewall-0.1.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file prompt_firewall-0.1.5.tar.gz.

File metadata

  • Download URL: prompt_firewall-0.1.5.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for prompt_firewall-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a55344a515e3d8fa99796f0f2de9e435137b3d9b1a24262c7768b8588338fcf2
MD5 ea093cea2854878fdf9b1d589d2c6d17
BLAKE2b-256 a007fa3ede2c4cef7c5144545f325b6e8b68ad030045aac182aed2770fbe19d9

See more details on using hashes here.

File details

Details for the file prompt_firewall-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for prompt_firewall-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f532a12f46a19eaa67629dac500b4c5d23ed2b4704b611f9c7ec5bc864244098
MD5 bb0268d009f1f71398848db1079cfbb9
BLAKE2b-256 52abd99ed091f24ba40191aa89588840c91d67d81d3d02a41970c52150807fe0

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