Skip to main content

Zero-dependency standalone Prose Tax token optimization utility for the Sovereign Systems SDK

Project description

sovereign-sieve

Zero-dependency standalone Prose Tax token optimization utility.

sovereign-sieve extracts the payload-cleansing mechanics from the Sovereign Systems SDK into a pure, synchronous micro-library with no web framework or ML library dependencies. Use it in scripts, batch pipelines, and offline data-processing workers to strip conversational boilerplate and measure immediate token savings — all on local silicon.


Installation

pip install sovereign-sieve

Or, within a uv workspace:

uv add sovereign-sieve

Quick Start

pure_sieve — drop-in string cleaner

from sovereign_sieve import pure_sieve

raw = "Hello! Please just help me analyze this dataset."
clean = pure_sieve(raw)
print(clean)
# → "! help me analyze this dataset."

sieve_with_metrics — cleaner + FinOps telemetry

from sovereign_sieve import sieve_with_metrics

result = sieve_with_metrics(
    "Hi! I hope this helps. Please just run the pipeline."
)
print(result.text)
# → "! helps. run the pipeline."

print(result.raw_token_count)        # estimated tokens before sieve
print(result.optimized_token_count)  # estimated tokens after sieve
print(result.tax_savings_percentage) # e.g. 66.6667 (%)

Offline batch pipeline

from sovereign_sieve import pure_sieve

records = load_jsonl("prompts.jsonl")
cleaned = [pure_sieve(r["text"]) for r in records]
save_jsonl("prompts_clean.jsonl", cleaned)

What gets stripped

Category Examples stripped Examples preserved
Greeting tokens hi, hello, hey, greetings hi-fi, hello-world
Hedging adverbs please, just, simply, actually, basically, probably just-in-time, simply-typed
Affirmation filler of course, certainly, absolutely, sure (standalone) make sure to, be sure to, certainly-not
Preamble phrases I hope this, I hope that, I hope you trailing sentence content preserved
Degenerate markdown ****, _____ (4+ bare markers) **bold**, *italic*, ***bold-italic***
Duplicate headings consecutive identical ## Heading\n## Heading headings differing in case or level

SieveOutput fields

from sovereign_sieve import SieveOutput

result: SieveOutput = sieve_with_metrics("Hello! Please help me now.")
result.text                  # str  — minimized payload
result.raw_token_count       # int  — byte-density token estimate before sieve
result.optimized_token_count # int  — byte-density token estimate after sieve
result.tax_savings_percentage # float — reduction percentage, 4 decimal places

Token counts use the UTF-8 byte-density heuristic (÷ 4), matching the average density of the cl100k_base tokenizer across mixed English/code content. No external tokenizer is invoked.


Key manager usage (sovereign-core)

For cryptographic signing of sieved payloads, use SovereignGateway from sovereign-core:

import asyncio
from sovereign_core.gateway import SovereignGateway

async def main():
    gateway = SovereignGateway(signing_key=".keys/sovereign_identity.pem")
    result = await gateway.sieve_and_sign("Hello! Please just help me.")
    print(result.content)          # minimized text
    print(result.receipt["signature"])  # Ed25519 signature

asyncio.run(main())

License

MIT

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

sovereign_sieve-1.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

sovereign_sieve-1.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file sovereign_sieve-1.1.0.tar.gz.

File metadata

  • Download URL: sovereign_sieve-1.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for sovereign_sieve-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a024c289a7aca3823ad3823ada339173283c23ae2e95bbecc42a33202bf06ff3
MD5 cf695db3d17eab169279ce77b9e8d910
BLAKE2b-256 0e133e64205e0aa0a2d2f2238257c691a46104b70eaf17eed5807f1fa0f2fb65

See more details on using hashes here.

File details

Details for the file sovereign_sieve-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sovereign_sieve-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b421a0654048136f4dd5f539fefeb1affdf558fdf293fc8640610400a17df508
MD5 7665f99b96f4f5b36687c1833891830d
BLAKE2b-256 05771872f264311cc1410d954deff7e419dad9621dfb7add2ce3b99d1e069e0e

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