feat - update router settings on Admin UI

This commit is contained in:
Ishaan Jaff 2024-04-16 15:36:26 -07:00
parent a710480629
commit 59b154f152
3 changed files with 29 additions and 3 deletions

View file

@ -2587,6 +2587,9 @@ class ProxyConfig:
general_settings["alerting"] = _general_settings["alerting"] general_settings["alerting"] = _general_settings["alerting"]
proxy_logging_obj.alerting = general_settings["alerting"] proxy_logging_obj.alerting = general_settings["alerting"]
# router settings
_router_settings = config_data.get("router_settings", {})
llm_router.set_settings(**_router_settings)
except Exception as e: except Exception as e:
verbose_proxy_logger.error( verbose_proxy_logger.error(
"{}\nTraceback:{}".format(str(e), traceback.format_exc()) "{}\nTraceback:{}".format(str(e), traceback.format_exc())
@ -8196,8 +8199,8 @@ async def update_config(config_info: ConfigYAML):
_updated_router_settings = config_info.router_settings _updated_router_settings = config_info.router_settings
config["router_settings"] = { config["router_settings"] = {
**_updated_router_settings,
**config["router_settings"], **config["router_settings"],
**_updated_router_settings,
} }
# Save the updated config # Save the updated config

View file

@ -2336,6 +2336,10 @@ class Router:
return None return None
def get_settings(self): def get_settings(self):
"""
Get router settings method, returns a dictionary of the settings and their values.
For example get the set values for routing_strategy_args, routing_strategy, allowed_fails, cooldown_time, num_retries, timeout, max_retries, retry_after
"""
_all_vars = vars(self) _all_vars = vars(self)
_settings_to_return = {} _settings_to_return = {}
vars_to_include = [ vars_to_include = [
@ -2354,6 +2358,25 @@ class Router:
_settings_to_return[var] = _all_vars[var] _settings_to_return[var] = _all_vars[var]
return _settings_to_return return _settings_to_return
def set_settings(self, **kwargs):
# only the following settings are allowed to be configured
_allowed_settings = [
"routing_strategy_args",
"routing_strategy",
"allowed_fails",
"cooldown_time",
"num_retries",
"timeout",
"max_retries",
"retry_after",
]
for var in kwargs:
if var in _allowed_settings:
setattr(self, var, kwargs[var])
else:
raise Exception(f"In router.set_settings, {var} is not a valid setting")
def _get_client(self, deployment, kwargs, client_type=None): def _get_client(self, deployment, kwargs, client_type=None):
""" """
Returns the appropriate client based on the given deployment, kwargs, and client_type. Returns the appropriate client based on the given deployment, kwargs, and client_type.

View file

@ -79,10 +79,10 @@ const GeneralSettings: React.FC<GeneralSettingsPageProps> = ({
try { try {
setCallbacksCall(accessToken, payload); setCallbacksCall(accessToken, payload);
} catch (error) { } catch (error) {
message.error("Failed to update callback: " + error, 20); message.error("Failed to update router settings: " + error, 20);
} }
message.success("Callback updated successfully"); message.success("router settings updated successfully");
}; };