{"id":51861556,"url":"https://github.com/m4vic/promptshields","last_synced_at":"2026-07-24T08:01:30.826Z","repository":{"id":369268123,"uuid":"1284908862","full_name":"m4vic/promptshields","owner":"m4vic","description":"An enterprise-grade, bidirectional LLM security framework. Defend against prompt injection, jailbreaks, data leakage, and PII exposure in production applications.","archived":false,"fork":false,"pushed_at":"2026-07-04T11:13:59.000Z","size":12397,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-04T13:06:17.411Z","etag":null,"topics":["agenticsecops","ai","ai-agents","aisecurity","cybersecurity","framework","llm","llm-evaluation","llmsecurity","security-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m4vic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-30T09:55:40.000Z","updated_at":"2026-07-04T11:14:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/m4vic/promptshields","commit_stats":null,"previous_names":["m4vic/promptshields"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/m4vic/promptshields","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4vic%2Fpromptshields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4vic%2Fpromptshields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4vic%2Fpromptshields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4vic%2Fpromptshields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m4vic","download_url":"https://codeload.github.com/m4vic/promptshields/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4vic%2Fpromptshields/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35832970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-24T02:00:07.870Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agenticsecops","ai","ai-agents","aisecurity","cybersecurity","framework","llm","llm-evaluation","llmsecurity","security-tools"],"created_at":"2026-07-24T08:01:30.134Z","updated_at":"2026-07-24T08:01:30.816Z","avatar_url":"https://github.com/m4vic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# PromptShields\n\n**Secure AI Applications in 3 Lines of Code**\n\n[![PyPI](https://img.shields.io/pypi/v/promptshields.svg)](https://pypi.org/project/promptshields/)\n[![Python](https://img.shields.io/pypi/pyversions/promptshields.svg)](https://pypi.org/project/promptshields/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Downloads](https://pepy.tech/badge/promptshields)](https://pepy.tech/project/promptshields)\n\nbidirectional LLM security framework. Defend against prompt injection, jailbreaks, data leakage, and PII exposure in production applications.\n\n--------------------------------------------------------------------------------\n\n## Installation\n\n```bash\npip install promptshields\n```\n\n### Optional extras\n\nCore install covers pattern matching, session tracking, canary tokens, and the\npre-trained ML ensemble. Some features need extra dependencies:\n\n```bash\n# Output DLP engine (Bloom filters, Aho-Corasick, semantic similarity)\npip install \"promptshields[output]\"\n\n# Semantic/embedding-based matching (sentence-transformers)\npip install \"promptshields[ml]\"\n\n# Framework integrations (LangChain, LiteLLM, LlamaIndex, CrewAI)\npip install \"promptshields[integrations]\"\n\n# Everything\npip install \"promptshields[all]\"\n```\n\n## Quick Start\n\n```python\nfrom promptshield import Shield\n\nshield = Shield.balanced()\nresult = shield.protect_input(user_input, system_prompt)\n\nif result['blocked']:\n    print(f\"Blocked: {result['reason']} (score: {result['threat_level']:.2f})\")\n    print(f\"Breakdown: {result['threat_breakdown']}\")\n```\n\n--------------------------------------------------------------------------------\n\n## Features \u0026 Capabilities\n\n| Feature | PromptShields | DIY Regex | Paid APIs |\n|---------|---------------|-----------|-----------| \n| **Setup Time** | 3 minutes | Weeks | Days |\n| **Cost** | Free | Free | $$$$ |\n| **Privacy** | 100% Local | Local | Cloud |\n| **F1 Score** | 0.97 (RF) / 0.96 (DeBERTa) | ~0.60 | ~0.95 |\n| **ML Models** | 3 + DeBERTa | None | Black box |\n| **Async** | Native | DIY | Varies |\n\n### Protection Scope\n- Prompt injection attacks (direct and indirect)\n- Jailbreak attempts (DAN, persona replacement)\n- System prompt extraction\n- PII leakage and sensitive data exposure\n- Session anomalies\n- Encoded/obfuscated attacks (Base64, URL, Unicode)\n\n--------------------------------------------------------------------------------\n\n## Security Modes\n\nChoose the right tier for your application latency requirements:\n\n```python\nShield.fast()       # ~1ms  - High throughput (pattern matching only)\nShield.balanced()   # ~2ms  - Production default (patterns + session tracking)\nShield.strict()     # ~7ms  - Sensitive apps (+ 1 ML model + PII detection)\nShield.secure()     # ~12ms - Maximum security (3 ML models ensemble)\n```\n\n--------------------------------------------------------------------------------\n\n## Upgrading to v3.0.0\n\nVersion 3.0.0 introduces a massive update with the new bidirectional **Output Filter**.\n\n### Output Engine (Data Leakage Prevention)\nPrevent sensitive data, PII, and proprietary knowledge from leaking through LLM generations securely before they reach the user.\n\n- **4-Layer Scanning Pipeline:** Defends against data leakage using Bloom Filters, Aho-Corasick exact matching, Honeypot traps, and Embedding-based Semantic Similarity checks.\n- **Semantic Leakage Detection:** Natively utilizes `sentence-transformers` to detect when the LLM's output is highly semantically similar to your proprietary system prompts or private databases.\n- **Contextual PII Redaction:** A heavily-optimized detection system to proactively redact sensitive information securely.\n\n```python\nfrom promptshield import OutputFilter\n\nfilter = OutputFilter(\n    system_prompt=\"You are a secret agent...\",\n    enforce_pii=True,\n    enforce_embeddings=True\n)\n\nsafe_text, was_redacted = filter.scan_output(\"My name is John Doe.\")\n```\n\n### Performance \u0026 Hardening\n- Complete thread-safety for multi-tenant high-concurrency environments.\n- Strict HMAC-SHA256 authenticated webhooks.\n- Lazy-loading implementation for heavy dependencies (`numpy`, `sentence-transformers`) for lightning-fast cold starts.\n\n--------------------------------------------------------------------------------\n\n## Developer Experience\n\n### YAML Configuration\nLaunch shields declaratively without changing application code.\n```python\nshield = Shield.from_config(\"promptshield.yml\")\n```\n\n### Slack and Teams Webhooks\nInstantly trigger webhooks whenever high-severity threats are blocked natively.\n```python\nshield = Shield.balanced(webhook_url=\"https://hooks.slack.com/...\")\n```\n\n### Async and FastAPI Support\nNative middleware integration for modern web frameworks.\n```python\nfrom promptshield import Shield\nfrom promptshield.integrations.fastapi import PromptShieldMiddleware\n\napp.add_middleware(PromptShieldMiddleware, shield=Shield.balanced())\n```\n\n--------------------------------------------------------------------------------\n\n## Benchmark Results\n\nTrained on the highly curated [neuralchemy/Prompt-injection-dataset](https://huggingface.co/datasets/neuralchemy/Prompt-injection-dataset):\n\n| Model | F1 | ROC-AUC | FPR | Latency |\n|-------|-----|---------|------|---------|\n| Random Forest | **0.969** | **0.994** | 6.9% | \u003c1ms |\n| Logistic Regression | 0.964 | 0.995 | 6.4% | \u003c1ms |\n| Gradient Boosting | 0.961 | 0.994 | 7.9% | \u003c1ms |\n| LinearSVC | 0.959 | 0.995 | 10.3% | \u003c1ms |\n| DeBERTa-v3-small | 0.959 | 0.950 | 8.5% | ~50ms |\n\nPre-trained models available on Hugging Face: \n- [prompt-injection-detector](https://huggingface.co/neuralchemy/prompt-injection-detector)\n- [prompt-injection-deberta](https://huggingface.co/neuralchemy/prompt-injection-deberta)\n\n--------------------------------------------------------------------------------\n\n## Documentation\n\nFull API reference, guides, and integration details are available in the **[GitHub repository](https://github.com/m4vic/promptshields)**.\n\n--------------------------------------------------------------------------------\n\n## License\n\nMIT License — see [LICENSE](LICENSE)\n\n**Built by [Sanskar Jajoo / NeurAlchemy](https://github.com/m4vic)** — AI Security and LLM Safety Research\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4vic%2Fpromptshields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm4vic%2Fpromptshields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4vic%2Fpromptshields/lists"}