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.6.tar.gz (5.8 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.6-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prompt_firewall-0.1.6.tar.gz
Algorithm Hash digest
SHA256 a1d010de94c087f6f64763284d3eddfcd5fb9a12f3682b34ee1e9ef6394fe314
MD5 d1f1cdb5e229e7d922f8b3d55f95ca1f
BLAKE2b-256 428d76c93cb64aab49bb7b4246a58ec986b25e9253c827deecbf000f61a23d43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prompt_firewall-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 491a724b81996a9995e732dc661e6d8c78d526898b1b52ee6bd7fe206baa410d
MD5 d4f515d48e68e22ef36cc7ac8a00fa38
BLAKE2b-256 bc5aa7487975f7c4ff62b87ee28adce93959ec696eaad1b0d39b519bb4313a28

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