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(
    phrases_path="phrases.txt",
    sentences_path="sentences.txt",
    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.4.tar.gz (5.5 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.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prompt_firewall-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e5fc12fcfab7dd3a6a301fdd3a2a3524e53a378aa1ffa2b70d4786141ac7fd00
MD5 e05fe84367f5ac8fc68cce4838b404f6
BLAKE2b-256 f272727ef82b1004e502b41a2267a35789cbd728bd939694c90edf0ab1055afa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prompt_firewall-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ca7b5bd364098594ac6dea2b2ec1715d3b8c8807e9507331707d0bc3feab1f7a
MD5 aa63e33a48dfd529e36fddecce2153d5
BLAKE2b-256 a3cdb36bc257b9d3519961f895b9eb90b459d8ee4dcda9cb357672e12bd33835

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