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 thriftlm 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
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thriftlm-0.1.2.tar.gz.
File metadata
- Download URL: thriftlm-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c24ca97043052bad4adac2cab7ab6f68250300a42e103a924d272e885c2becd0
|
|
| MD5 |
b5f34949040de1bd5f0568207cb128f1
|
|
| BLAKE2b-256 |
2ef08f964f334808bed38d48a724523490c48163334c0a089381de236795ca6e
|
File details
Details for the file thriftlm-0.1.2-py3-none-any.whl.
File metadata
- Download URL: thriftlm-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dcd19e1b4ccba4c220016f0793d93b3182e63acbabfb72aee0e588f1716fcc7
|
|
| MD5 |
a2541eba9a67a1e2d52e3fcc82f94b9b
|
|
| BLAKE2b-256 |
bb5d2ab46a4889e9618c3d62bec0809982e682516da320aa5a2767b19b0a066a
|