(docs) writing custo add

This commit is contained in:
ishaan-jaff 2024-02-24 18:54:46 -08:00
parent c8daf61592
commit 7c19783d32

View file

@ -248,6 +248,27 @@ cache.get_cache_key = custom_get_cache_key # set get_cache_key function for your
litellm.cache = cache # set litellm.cache to your cache litellm.cache = cache # set litellm.cache to your cache
```
## How to write custom add/get cache functions
### 1. Init Cache
```python
from litellm.caching import Cache
cache = Cache()
```
### 2. Define custom add/get cache functions
```python
def add_cache(self, result, *args, **kwargs):
your logic
def get_cache(self, *args, **kwargs):
your logic
```
### 3. Point cache add/get functions to your add/get functions
```python
cache.add_cache = add_cache
cache.get_cache = get_cache
``` ```
## Cache Initialization Parameters ## Cache Initialization Parameters