An intelligent caching and LLM routing package using Mem0AI and zero-shot classification.
Project description
Smart Cache Package
Smart Cache Package is a pip‑installable Python library that provides an intelligent caching and LLM routing solution. It leverages:
- Mem0AI for storing and retrieving past interactions.
- Hugging Face's zero-shot classification to automatically assign categories to queries.
- Built‑in integration with popular LLM providers (e.g. OpenAI, Anthropic) and support for custom LLM callables.
Features
-
Caching and Reuse:
Caches previous query–answer pairs to avoid unnecessary LLM calls. -
Near‑Duplicate Search:
Searches Mem0 for near‑duplicate queries. If a query similar enough is found (based on a configurable threshold), it is returned from cache or Mem0 without calling the LLM. -
Context Building:
If no exact or near‑duplicate answer exists, the package builds a context from related stored interactions to provide richer prompts for the LLM. -
Built-in LLM Routing:
Supports multiple LLM providers:- OpenAI: Uses
OPENAI_API_KEYfrom the environment. - Anthropic: Uses
ANTHROPIC_API_KEY(placeholder; extend as needed). - Custom: Allows users to provide their own LLM callable.
- OpenAI: Uses
-
Debugging and Source Reporting:
When desired,get_answer()can return an extra flag indicating the source of the answer (e.g. "Local Cache", "Mem0 Near-Duplicate", "LLM Call").
Installation
You can install the package via pip (once published):
pip install smart_cache_package
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
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 smart_cache_package-0.1.1.tar.gz.
File metadata
- Download URL: smart_cache_package-0.1.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15daa9bee84c0d944e487b502bc6a16d410fa5c80788a29c8b5581802f50000f
|
|
| MD5 |
46c306a92a935838b039b52bc10fe448
|
|
| BLAKE2b-256 |
d097f0ed7403f9f6eabae8596474b21dc2ab8442efd35fb5265737c67af8a5d7
|
File details
Details for the file smart_cache_package-0.1.1-py3-none-any.whl.
File metadata
- Download URL: smart_cache_package-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a4a39deb712c6885ca40f5eb4d3485380d5624de6e9ae10416db86a6e394bb1
|
|
| MD5 |
107411bd70c291c8266e4c8034214e94
|
|
| BLAKE2b-256 |
d999f73eb6fd2cdde4dfb4e2eb9675c1fcb0e4fd46b61a3db31175102e8f9804
|