Skip to content

Commit 2e8b167

Browse files
Add embeddings cache (#318)
Initial design and refactor here. - Includes some clean up for the internals of the OG `SemanticCache`. - Refactors the core of the cache classes to use `BaseCache` for both `EmbeddingsCache` and `SemanticCache`. - Updates documentation, working tests, and user guides. NOTE: Will hold off on integrating with our vectorizers for a separate PR. This one is already long.
1 parent a1ed87f commit 2e8b167

31 files changed

+4124
-964
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ We're excited to announce the support for **RedisVL Extensions**. These modules
238238
Increase application throughput and reduce the cost of using LLM models in production by leveraging previously generated knowledge with the [`SemanticCache`](https://docs.redisvl.com/en/stable/api/cache.html#semanticcache).
239239
240240
```python
241-
from redisvl.extensions.llmcache import SemanticCache
241+
from redisvl.extensions.cache.llm import SemanticCache
242242
243243
# init cache with TTL and semantic distance threshold
244244
llmcache = SemanticCache(

docs/api/cache.rst

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,26 @@ SemanticCache
77

88
.. _semantic_cache_api:
99

10-
.. currentmodule:: redisvl.extensions.llmcache
10+
.. currentmodule:: redisvl.extensions.cache.llm
1111

1212
.. autoclass:: SemanticCache
1313
:show-inheritance:
1414
:members:
1515
:inherited-members:
16+
17+
18+
****************
19+
Embeddings Cache
20+
****************
21+
22+
EmbeddingsCache
23+
===============
24+
25+
.. _embeddings_cache_api:
26+
27+
.. currentmodule:: redisvl.extensions.cache.embeddings
28+
29+
.. autoclass:: EmbeddingsCache
30+
:show-inheritance:
31+
:members:
32+
:inherited-members:

docs/user_guide/03_llmcache.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
}
8989
],
9090
"source": [
91-
"from redisvl.extensions.llmcache import SemanticCache\n",
91+
"from redisvl.extensions.cache.llm import SemanticCache\n",
9292
"\n",
9393
"llmcache = SemanticCache(\n",
9494
" name=\"llmcache\", # underlying search index name\n",

docs/user_guide/04_vectorizers.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@
609609
"metadata": {},
610610
"outputs": [],
611611
"source": [
612-
"from redisvl.extensions.llmcache import SemanticCache\n",
612+
"from redisvl.extensions.cache.llm import SemanticCache\n",
613613
"\n",
614614
"cache = SemanticCache(name=\"custom_cache\", vectorizer=custom_vectorizer)\n",
615615
"\n",

docs/user_guide/09_threshold_optimization.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"from redisvl.extensions.llmcache import SemanticCache\n",
27+
"from redisvl.extensions.cache.llm import SemanticCache\n",
2828
"\n",
2929
"sem_cache = SemanticCache(\n",
3030
" name=\"sem_cache\", # underlying search index name\n",

0 commit comments

Comments
 (0)