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.0.tar.gz (43.7 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.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thriftlm-0.1.0.tar.gz
  • Upload date:
  • Size: 43.7 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.0.tar.gz
Algorithm Hash digest
SHA256 c91dcd148f3f184c505e359ad02abbcb5b5507e4690136b6c239acd5e0359ed4
MD5 05dcb3e9aa0cc86cf8af62e84b6843ba
BLAKE2b-256 1da96f7b47fe8cf8d3bb912f34b65ee13fa0a8b814a9102d39cc5dfb2e8de53f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thriftlm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a7b69c5934e7af435f32110bf7cd60b6aafa0d3866e7f01568e96265ba940ec
MD5 96f64306b17f1045d120a592aeb77a43
BLAKE2b-256 a352fd6c8a0711d45b4c26ab171ba9b18fd94ff083cd2ea6b0e5e8ba4e2f2638

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