mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
fix(router.py): fix cache init
This commit is contained in:
parent
5829227d86
commit
58ab0a3f03
1 changed files with 15 additions and 7 deletions
|
@ -116,13 +116,21 @@ class Router:
|
||||||
cache_config = {}
|
cache_config = {}
|
||||||
if redis_url is not None or (redis_host is not None and redis_port is not None and redis_password is not None):
|
if redis_url is not None or (redis_host is not None and redis_port is not None and redis_password is not None):
|
||||||
cache_type = "redis"
|
cache_type = "redis"
|
||||||
cache_config = {
|
|
||||||
'url': redis_url,
|
if redis_url is not None:
|
||||||
'host': redis_host,
|
cache_config['url'] = redis_url
|
||||||
'port': redis_port,
|
|
||||||
'password': redis_password,
|
if redis_host is not None:
|
||||||
**cache_kwargs
|
cache_config['host'] = redis_host
|
||||||
}
|
|
||||||
|
if redis_port is not None:
|
||||||
|
cache_config['port'] = redis_port
|
||||||
|
|
||||||
|
if redis_password is not None:
|
||||||
|
cache_config['password'] = redis_password
|
||||||
|
|
||||||
|
# Add additional key-value pairs from cache_kwargs
|
||||||
|
cache_config.update(cache_kwargs)
|
||||||
redis_cache = RedisCache(**cache_config)
|
redis_cache = RedisCache(**cache_config)
|
||||||
if cache_responses:
|
if cache_responses:
|
||||||
litellm.cache = litellm.Cache(type=cache_type, **cache_config)
|
litellm.cache = litellm.Cache(type=cache_type, **cache_config)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue