Skip to main content

Simple CLI tool for AI text rewriting with Ollama

Project description

🔥 Redukon

Reduce Your Tokens. Keep Your Intent.

PyPI Python License Stars


✨ What is Redukon?

Redukon is a token-saving prompt rewriter that uses local small AI models to optimize your prompts — reducing token count while keeping the core intent intact.

No API keys needed. Runs entirely offline with Ollama.

💡 Perfect for:

  • Saving money on API calls
  • Fitting more context into LLM windows
  • Making prompts more efficient
  • Building into your own apps via API

🚀 Quick Start

# Install from PyPI
pip install redukon

# Or install latest from GitHub
pip install -e https://github.com/CharlesArea/Redukon.git

# One-time setup (installs Ollama + picks a model)
redukon onboard

📖 CLI Usage

redukon onboard

Interactive setup wizard:

  1. Checks if Ollama is installed
  2. Installs Ollama if needed
  3. Choose your model:
    Model Size Best For
    qwen2.5:0.5b 397MB Speed & minimal resources
    llama3.2:1b 1.9GB Balanced
    phi3:3.8b 2.3GB Better quality

redukon rewrite

Rewrite your prompts from command line:

# Basic
redukon rewrite -i "Please write a comprehensive Python function..."

# From file
redukon rewrite -i @long-prompt.txt -o optimized.txt

# Custom temperature (lower = more focused)
redukon rewrite -i "prompt" --temp 0.3

redukon serve

Start the API server:

# Default port 8000
redukon serve

# Custom port
redukon serve --port 9000
redukon serve --host 127.0.0.1 --port 8080

🌐 API Usage

Start Server

redukon serve

Endpoints

Endpoint Method Description
/rewrite POST Rewrite a prompt
/health GET Health check

Example Request

curl -X POST http://localhost:8000/rewrite \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Please write a comprehensive Python function that takes a list of integers...",
    "model": "qwen2.5:0.5b",
    "temperature": 0.3
  }'

Example Response

{
  "optimized_prompt": "Write a Python function that filters even numbers from a list...",
  "original_tokens": 87,
  "optimized_tokens": 42,
  "saved_tokens": 45,
  "saved_percent": 52
}

API Parameters

Parameter Type Required Description
prompt string Yes The prompt to optimize
model string No Model name (default: from config)
temperature float No Temperature 0.0-1.0 (default: 0.3)

📝 Logging

API requests are logged to log/api-YYYY-MM-DD.log:

[2026-03-10 12:00:00] [REQUEST] input_length=250, model=qwen2.5:0.5b
[2026-03-10 12:00:05] [RESPONSE] output_length=120, original_tokens=62, optimized_tokens=30, saved_tokens=32, saved_percent=51%
[2026-03-10 12:00:05] [ERROR] Generation failed: Ollama not running

⚡ Example

Before (87 tokens) After (42 tokens)
"Please write a comprehensive Python function that takes a list of integers as input and returns a new list containing only the even numbers from the original list. The function should handle edge cases like empty lists, lists with no even numbers, and lists with negative numbers. Please include proper type hints, docstrings, and error handling." "Write a Python function that filters even numbers from a list. Include type hints, error handling, and docstrings."

📉 Savings: ~52%


🔧 Options

Flag Description Default
-i, --input Prompt or @file.txt Required
-o, --output Output file Print to stdout
-m, --model Override model From config
-t, --temp Temperature (0.0-1.0) 0.3

🛠️ Requirements

  • Python 3.10+
  • Ollama (installed automatically during onboard)

📝 License

MIT © 2026 CharlesArea


Made with ❤️ for the AI community

GitHubPyPIReport Bug

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

redukon-3.2.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file redukon-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: redukon-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for redukon-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8d25806c367ec6e41bd9200a59d641a20c3fef0477bfef29a464909ad07ff95
MD5 19e82b72eea48802814e55d9d8a27e19
BLAKE2b-256 5dcdb8702ed6e4921cd1d9ea6c2cff5dbecb5b16137bb649efcca0fccbcd6c51

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