feat - set custom routing strategy

This commit is contained in:
Ishaan Jaff 2024-06-20 13:49:44 -07:00
parent 3d90b25005
commit b6066d1ece
3 changed files with 45 additions and 1 deletions

View file

@ -69,6 +69,7 @@ from litellm.types.router import (
AlertingConfig,
AllowedFailsPolicy,
AssistantsTypedDict,
CustomRoutingStrategy,
Deployment,
DeploymentTypedDict,
LiteLLM_Params,
@ -4814,6 +4815,18 @@ class Router:
except Exception as e:
pass
def set_custom_routing_strategy(self, CustomRoutingStrategy: CustomRoutingStrategy):
setattr(
self,
"get_available_deployment",
CustomRoutingStrategy.get_available_deployment,
)
setattr(
self,
"async_get_available_deployment",
CustomRoutingStrategy.async_get_available_deployment,
)
def flush_cache(self):
litellm.cache = None
self.cache.flush_cache()