Skip to main content

Semantic caching layer for LLM applications — stop paying for the same call twice.

Project description

ThriftLM

Stop paying for the same LLM call twice just because users phrased it differently.

ThriftLM is a drop-in semantic caching layer for LLM applications. It embeds each query with SBERT, checks a vector store for semantically similar past queries, and returns the cached response when similarity is above threshold — no LLM call required.

Install

pip install thriftlm

Quickstart

from semantic_cache import SemanticCache

cache = SemanticCache(api_key="sc_xxx")
response = cache.get_or_call(query, llm_fn=my_langchain_chain.invoke)

That's it. No architecture changes — just wrap the existing LLM call.

Self-hosting

cp .env.example .env  # fill in SUPABASE_URL, SUPABASE_KEY, REDIS_URL
docker compose up

Set THRIFTLM_URL=http://localhost:8000 in your app to point at the local instance.

Docs

thriftlm.dev/docs

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

thriftlm-0.1.1.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

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

thriftlm-0.1.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file thriftlm-0.1.1.tar.gz.

File metadata

  • Download URL: thriftlm-0.1.1.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for thriftlm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 83cc784fb95cf953de26ab5da9c4b87a404994c855260a1ec3c26197963ba841
MD5 50e2be8f285101482c2b6c705c58f18e
BLAKE2b-256 fb88588b91a19d0d5d0a8ed82d56d8202e7f9f60f19be3c3481372611435c6ca

See more details on using hashes here.

File details

Details for the file thriftlm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: thriftlm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for thriftlm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 20570233f9adefd0a671b1edd1cc15af6789e02461cc9d68680a356680cec4bd
MD5 8d22f0e219f3975c00474d4963f07f09
BLAKE2b-256 89c04d4350bafd987cd78b128bf8448adabbe287213262c9727187aa6c03f197

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