prompt-groomer / README.md
Xinghao91's picture
Upload 3 files
a7be5fe verified

A newer version of the Streamlit SDK is available: 1.52.1

Upgrade
metadata
title: Prompt Groomer Demo
emoji: 🧹
colorFrom: blue
colorTo: green
sdk: streamlit
sdk_version: 1.28.0
app_file: app.py
pinned: false

🧹 Prompt Groomer - Interactive Demo

Live demonstration of prompt-groomer library capabilities.

Stop paying for invisible tokens. Optimize your LLM inputs to save costs, improve context usage, and enhance security.

✨ Features

  • 🎯 Interactive Playground - Experiment with different optimization strategies
  • πŸ’° Real-time Token Savings - See exactly how many tokens and dollars you save
  • πŸ”§ Configurable Operations - Toggle between 7 different operations
  • πŸ“Š Visual Metrics - Cost analysis and performance tracking
  • 🎭 Preset Examples - 6 real-world scenarios (e-commerce, support, docs, RAG, etc.)
  • ⚑ Quick Presets - Minimal, Standard, Aggressive, or Custom strategies

πŸš€ Quick Start

  1. Choose a preset example from the dropdown (or enter your own text)
  2. Select a strategy in the sidebar (Minimal, Standard, Aggressive, or Custom)
  3. Configure operations to match your use case
  4. See results with real-time token counting and cost savings

πŸ“¦ Installation

Try it live here, then install for your project:

pip install prompt-groomer

πŸ’» Example Usage

from prompt_groomer import (
    StripHTML,
    NormalizeWhitespace,
    TruncateTokens
)

# Use pipe operator to chain operations
pipeline = (
    StripHTML()
    | NormalizeWhitespace()
    | TruncateTokens(max_tokens=1000)
)

cleaned = pipeline.run(dirty_text)

πŸ”— Links

πŸ“Š Proven Effectiveness

Benchmarked on 30 real-world test cases:

  • 4-15% token reduction on average
  • 96-99% quality maintained (verified)
  • Up to ~$54/month saved at scale (1M tokens/month, GPT-4)

πŸ› οΈ Operations Available

🧼 Cleaner

  • Strip HTML tags
  • Normalize whitespace
  • Fix Unicode issues

πŸ—œοΈ Compressor

  • Deduplicate similar content
  • Truncate to token limits

πŸ”’ Scrubber

  • Redact PII (email, phone, IP, credit cards, SSN, URLs)

πŸ“Š Analyzer

  • Count tokens
  • Calculate cost savings

Made with ❀️ by Jacob Huang