Skip to main content

SemCache (Python SDK)

Zero-cost, low-latency tiered semantic caching SDK for LLMs running local embeddings.

Installation

pip install semcache

Quick Start

from semcache import SemCache, FileStore

# Initialize cache with local file storage
cache = SemCache(
    store=FileStore(".semcache/db.json"),
    fuzzy_threshold=0.95,
    semantic_threshold=0.85
)

# Set an entry (simulate LLM response time of 1500ms)
cache.set(
    query="What is the capital of France?",
    response="The capital of France is Paris.",
    latency_ms=1500,
    token_usage={"prompt_tokens": 7, "completion_tokens": 7}
)

# Query semantic matching (instant hit in ~20ms, $0 API cost)
result = cache.get("tell me the capital city of France")
if result:
    entry, tier, similarity = result
    print(f"Hit Tier: {tier} (Similarity: {similarity:.4f})")
    print(f"Response: {entry.response}")

Release files for semc 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semc 1.0.0
File Size Uploaded
semc-1.0.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for semc 1.0.0
File Interpreter ABI Platform
semc-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / semc-1.0.0.tar.gz

Download URL semc-1.0.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
501c2dcb7d97eba497c2d79bde88c815fd9f56db185285270095977c7dfd7e06
BLAKE2b-256 checksum
How to use checksums
4322a81e301c38f2f85f00f71b6dece4464d71c9580ba3cbb6452f5010021af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.1

Release files / semc-1.0.0-py3-none-any.whl

Download URL semc-1.0.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
422e79c4b6d757ca2fd83ada319f7b2b269f890dda8e0020485d4fedca419301
BLAKE2b-256 checksum
How to use checksums
b7892eaa1745567501be00a57335f7ecdf32824545ea8db477710ce3c064dd41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page