A lightweight Python package for first-level prompt safety checking using substring matching
Project description
noaiguarde 🛡️
A lightweight Python package for first-level prompt safety checking using simple substring matching.
Installation
pip install noaiguarde
Or with uv:
uv add noaiguarde
Quick Start
from noaiguarde import check_prompt
# Safe prompts return True
check_prompt("Hello, how are you?") # True
check_prompt("What's the weather today?") # True
# Unsafe prompts return False
check_prompt("I hate you") # False
check_prompt("Let's attack the server") # False
How It Works
noaiguarde performs case-insensitive substring matching against a bundled word list. If any word from the list is found within the prompt, it returns False (unsafe). Otherwise, it returns True (safe).
This is designed as a first-level filter - a quick, lightweight check before sending prompts to more sophisticated AI moderation systems.
API Reference
check_prompt(prompt: str) -> bool
Check if a prompt is safe.
Parameters:
prompt(str): The text prompt to check.
Returns:
Trueif the prompt is safe (no bad words found).Falseif the prompt contains any bad words.
Example:
from noaiguarde import check_prompt
if check_prompt(user_input):
# Safe to proceed
send_to_ai(user_input)
else:
# Block or flag the input
handle_unsafe_input(user_input)
Use Cases
- 🔒 Pre-flight checks before sending prompts to AI APIs
- 🚫 Content filtering in chatbots and user interfaces
- ⚡ Quick screening before expensive AI moderation calls
- 🛡️ Defense in depth as part of a multi-layer safety strategy
Limitations
- Substring matching only: May produce false positives (e.g., "skill" contains "kill")
- English only: The bundled word list is in English
- Not a complete solution: Use alongside more sophisticated AI safety tools
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noaiguarde-0.1.0.tar.gz.
File metadata
- Download URL: noaiguarde-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81b278ad44400dbdaab92af870eab313e0855f44a86c4be47a2720a1583a0345
|
|
| MD5 |
9e3bc275cdb4525d3a07e97b58fc5946
|
|
| BLAKE2b-256 |
7595d175b1c3672a55d334f0e490636409baddd537a923f6064f16b3d1739dbb
|
File details
Details for the file noaiguarde-0.1.0-py3-none-any.whl.
File metadata
- Download URL: noaiguarde-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad5da12d0c5fd407cbefbcde98bde52e162915c9820c7377a3483c11718cf20d
|
|
| MD5 |
6bb895ceefae17630a9a408d18ef11ca
|
|
| BLAKE2b-256 |
d19007953adb60846c75c935233622abfc814888ef505a5ed4a4865000b153b7
|