From 58ab0a3f03a7e48ac02375f292d42bd1d2073655 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Dec 2023 12:54:20 -0800 Subject: [PATCH] fix(router.py): fix cache init --- litellm/router.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index 881d89debfb..203cc419ef9 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -116,13 +116,21 @@ class Router: 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): cache_type = "redis" - cache_config = { - 'url': redis_url, - 'host': redis_host, - 'port': redis_port, - 'password': redis_password, - **cache_kwargs - } + + if redis_url is not None: + cache_config['url'] = redis_url + + if redis_host is not None: + 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) if cache_responses: litellm.cache = litellm.Cache(type=cache_type, **cache_config)