mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
minor fix
- bump redisvl version - default embedding cache namespace
This commit is contained in:
parent
1be0e0c40b
commit
c2a7453cda
2 changed files with 10 additions and 4 deletions
|
|
@ -211,7 +211,7 @@ response2 = completion(
|
|||
|
||||
Install redisvl client
|
||||
```shell
|
||||
pip install redisvl==0.4.1
|
||||
pip install redisvl==0.12.1
|
||||
```
|
||||
|
||||
For the hosted version you can setup your own Redis DB here: https://redis.io/try-free/
|
||||
|
|
@ -234,6 +234,9 @@ litellm.cache = Cache(
|
|||
similarity_threshold=0.8, # similarity threshold for cache hits, 0 == no similarity, 1 = exact matches, 0.5 == 50% similarity
|
||||
ttl=120,
|
||||
redis_semantic_cache_embedding_model="text-embedding-ada-002", # this model is passed to litellm.embedding(), any litellm.embedding() model is supported here
|
||||
embedding_cache_enabled=True, # enable caching of embeddings
|
||||
embedding_cache_ttl=120, # ttl for embeddings cache
|
||||
embedding_cache_name="litellm-embeddings-cache", # name for embeddings cache default is litellm_redis_semantic_embeddings_cache
|
||||
)
|
||||
response1 = completion(
|
||||
model="gpt-3.5-turbo",
|
||||
|
|
@ -603,6 +606,9 @@ def __init__(
|
|||
similarity_threshold: Optional[float] = None,
|
||||
redis_semantic_cache_embedding_model: str = "text-embedding-ada-002",
|
||||
redis_semantic_cache_index_name: Optional[str] = None,
|
||||
embedding_cache_enabled: bool = False,
|
||||
embedding_cache_ttl: Optional[int] = None,
|
||||
embedding_cache_name: Optional[str] = None,
|
||||
|
||||
# s3 Bucket, boto3 configuration
|
||||
s3_bucket_name: Optional[str] = None,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class RedisSemanticCache(BaseCache):
|
|||
"""
|
||||
|
||||
DEFAULT_REDIS_INDEX_NAME: str = "litellm_semantic_cache_index"
|
||||
DEFAULT_REDIS_EMBEDDINGS_CACHE_NAME: str = "litellm_redis_semantic_embeddings_cache"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -98,9 +99,8 @@ class RedisSemanticCache(BaseCache):
|
|||
# Embeddings cache configuration
|
||||
self.embedding_cache_enabled: bool = embedding_cache_enabled
|
||||
self.embedding_cache_ttl: Optional[int] = embedding_cache_ttl
|
||||
self.embedding_cache_name: str = (
|
||||
embedding_cache_name or "litellm_redis_semantic_embeddings_cache"
|
||||
)
|
||||
if embedding_cache_name is None:
|
||||
self.embedding_cache_name = self.DEFAULT_REDIS_EMBEDDINGS_CACHE_NAME
|
||||
self._embeddings_cache: Optional[EmbeddingsCache] = None
|
||||
|
||||
# Set up Redis connection
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue