Skip to main content

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.

Python 3.12+ License: MIT PyPI version

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:

  • True if the prompt is safe (no bad words found).
  • False if 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noaiguarde-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

noaiguarde-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

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

Hashes for noaiguarde-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81b278ad44400dbdaab92af870eab313e0855f44a86c4be47a2720a1583a0345
MD5 9e3bc275cdb4525d3a07e97b58fc5946
BLAKE2b-256 7595d175b1c3672a55d334f0e490636409baddd537a923f6064f16b3d1739dbb

See more details on using hashes here.

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

Hashes for noaiguarde-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad5da12d0c5fd407cbefbcde98bde52e162915c9820c7377a3483c11718cf20d
MD5 6bb895ceefae17630a9a408d18ef11ca
BLAKE2b-256 d19007953adb60846c75c935233622abfc814888ef505a5ed4a4865000b153b7

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