Skip to main content

Lightweight prompt context minification engine wrapper for SiftPrompt.

Project description

sift-core

SiftPrompt Python SDK: The ultra-lightweight prompt optimization matrix compiler. Strip syntactic noise, conversational fluff, and redundancy from your LLM prompts to save up to 40%+ on your token bills without sacrificing semantic accuracy.

PyPI Version License: MIT Python Versions


Features

  • Intelligent Compression: Automatically targets conversational filler, over-engineered phrasing, and corporate boilerplate.
  • Fail-Safe Circuit Breaker: Zero-dependency, defensive engineering. If your network or the gateway drops, the SDK automatically fails open under 50ms, returning your raw prompt so your application never crashes.
  • Multi-Mode Support: Choose between balanced, aggressive, and exact optimization matrices.
  • Deterministic Local Guardrails: Instantly catches empty strings or dead whitespace locally without wasting API network credits.

Installation

Install the official package from PyPI using pip:

pip install sift-core

Configuration

We recommend using .env.local files to manage your API keys.

  1. Install the helper: pip install python-dotenv
  2. Create a .env.local file in your root:
    SIFT_RAPIDAPI_KEY=your_key_here
    

Quick Start

Python

import os
from sift_core import SiftCompiler

# Initialize the compiler with your RapidAPI key
sift = SiftCompiler(api_key="YOUR_SIFT_RAPIDAPI_KEY")

# A conversational prompt heavy with fluff
verbose_prompt = (
    "Hey there AI, I hope you are having an absolutely wonderful day today! "
    "I am working on a small personal project and I was really wondering if you could "
    "do me a huge favor. Can you please act as a world-class, expert senior copywriter "
    "for me right now? Please look over the text very carefully. Thank you so much!"
)

# Execute the compression pass
result = sift.minify(verbose_prompt, mode="aggressive")

print(f"Optimization Rate: {result.metrics['percentage_saved']}% tokens saved")
print("--------------------------------------------------")
print(f"Minified Output:\n\"{result.optimized_text}\"")

Optimization Profiles

Profile Behavior Ideal Target
balanced Standard pruning Multi-turn conversational contexts
aggressive High-density stripping Verbose corporate boilerplate, pleasantries, and fluff
exact Literal matching Structured code blocks, JSON schemas, structural variables

Enterprise Resilience (Fail-Open)

This SDK is engineered defensively for mission-critical pipelines, data science workflows, and autonomous AI agents.

It encapsulates network dispatches inside short-circuit timeouts.

If the underlying API layer undergoes throttling (429), structural validation denials (403), or total network blackouts, the wrapper catches the anomaly cleanly and returns your original uncompressed text sequence seamlessly with an explicit:

{
  "percentage_saved": 0
}

metric payload.

Your application's core LLM loop will never crash.

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

sift_core-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

sift_core-1.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file sift_core-1.0.0.tar.gz.

File metadata

  • Download URL: sift_core-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for sift_core-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a54a8f80efcbd394716fcd60300a6f9c879248b652ab3d4bb80cfd2e80bd401c
MD5 2a225a5606407c03782807b334ab449a
BLAKE2b-256 079452d77440baa23b0a9eb29219165e76a5386b60b2900beb4fbf25ea20b749

See more details on using hashes here.

File details

Details for the file sift_core-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sift_core-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for sift_core-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ab60a7c99c0ebe963de758b58452a7a2880afc9bb7fdb73ba43b2f9c8b619c9
MD5 63bdeeef72aaec863bede79a85168ca4
BLAKE2b-256 2190f84c4129e779e4a3cb363b489b608e78626c59111fd6bf7becead374bddb

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