Skip to content

junaidify/promptkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promptkit 🧠

A lightweight Python toolkit for cleaning and preparing text before sending it to any LLM (GPT, Claude, Gemini, etc.)

Every AI developer copy-pastes these utilities across projects. Now you don't have to.

Installation

pip install promptkit

Functions

Function What it does
clean(text) Removes extra spaces, repeated punctuation
truncate_tokens(text, max_words) Trims text to stay within token limits
remove_pii(text) Masks emails, phone numbers, URLs
format_prompt(template, **kwargs) Safely fills prompt templates
word_count(text) Returns word count of a string

Usage

from promptkit import clean, truncate_tokens, remove_pii, format_prompt, word_count

# Clean messy input
clean("  Hello!!!   World???  ")
# → "Hello! World?"

# Truncate to token budget
truncate_tokens("one two three four five", max_words=3)
# → "one two three..."

# Remove sensitive info before sending to external APIs
remove_pii("My email is john@gmail.com and number is 9876543210")
# → "My email is [EMAIL] and number is [PHONE]"

# Fill prompt templates safely
format_prompt("Summarize: {text}", text="Hello world")
# → "Summarize: Hello world"

# Quick word count
word_count("Hello world foo bar")
# → 4

Why promptkit?

  • ✅ Zero dependencies — pure Python
  • ✅ Works with any LLM — OpenAI, Anthropic, Google, local models
  • ✅ PII removal keeps your users' data safe
  • ✅ Token truncation saves API costs

License

MIT — free to use, modify, and distribute.

About

A lightweight toolkit for cleaning and preparing text for LLMs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages