From c1a215b955d8f4fa342aa72bc691ea21db51d85e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 21:00:03 -0700 Subject: [PATCH 1/8] fix set router retry policy on ui --- .../src/components/model_dashboard.tsx | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index b223e912818..722f2f8b467 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -83,6 +83,17 @@ const provider_map: Record = { }; + +const retry_policy_map: Record = { + "BadRequestError (400)": "BadRequestErrorRetries", + "AuthenticationError (401)": "AuthenticationErrorRetries", + "TimeoutError (408)": "TimeoutErrorRetries", + "RateLimitError (429)": "RateLimitErrorRetries", + "ContentPolicyViolationError (400)": "ContentPolicyViolationErrorRetries" +}; + + + const handleSubmit = async (formValues: Record, accessToken: string, form: any) => { try { /** @@ -795,6 +806,7 @@ const handleEditSubmit = async (formValues: Record) => { Add Model
/health Models
Model Analytics + Model Retry Settings
@@ -816,7 +828,7 @@ const handleEditSubmit = async (formValues: Record) => {
- Filter by Public Model Name + Filter by Public Model Name setSelectedModelGroup(value)} + > + {availableModelGroups.map((group, idx) => ( + setSelectedModelGroup(group)} + > + {group} + + ))} + +
+ + + Retry Policy for {selectedModelGroup} + + { + retry_policy_map && Object.keys(retry_policy_map).map((key, idx) => ( +
+ + {key} + + + + +
+ )) + } +
+
From e62d8e9bc9945ad8ab78a484ff30430baef0f374 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 21:24:07 -0700 Subject: [PATCH 2/8] stash ui changes --- .../src/components/model_dashboard.tsx | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 722f2f8b467..9b8b3c34553 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1248,23 +1248,19 @@ const handleEditSubmit = async (formValues: Record) => { ))}
- + Retry Policy for {selectedModelGroup} - { - retry_policy_map && Object.keys(retry_policy_map).map((key, idx) => ( -
- - {key} - + How many retries should be attempted based on the Exception + {retry_policy_map && + Object.keys(retry_policy_map).map((key, idx) => ( +
+ {key} + +
+ ))} -
- -
- )) - } -
From 43b50b7151f313828ff9050309d75b6dc460b3fe Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 21:39:23 -0700 Subject: [PATCH 3/8] ui - show retry policy for errors --- .../src/components/model_dashboard.tsx | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 9b8b3c34553..744d1ec2143 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1254,12 +1254,21 @@ const handleEditSubmit = async (formValues: Record) => { How many retries should be attempted based on the Exception {retry_policy_map && - Object.keys(retry_policy_map).map((key, idx) => ( -
- {key} - -
- ))} + + + {Object.keys(retry_policy_map).map((key, idx) => ( + + + + + ))} + +
+ {key} + + +
+} From 3175be6303b305250770be050793ff0b10e93488 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 21:51:25 -0700 Subject: [PATCH 4/8] get correct settings on router --- litellm/router.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/router.py b/litellm/router.py index 9c56445d32b..39e3875b735 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -2666,6 +2666,7 @@ class Router: "retry_after", "fallbacks", "context_window_fallbacks", + "model_group_retry_policy", ] for var in vars_to_include: @@ -2691,6 +2692,7 @@ class Router: "retry_after", "fallbacks", "context_window_fallbacks", + "model_group_retry_policy", ] _int_settings = [ From 281e92d0a819d1cccd2fc676a27dbc44290a51a5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 21:58:36 -0700 Subject: [PATCH 5/8] ui - show default retries --- .../src/components/model_dashboard.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 744d1ec2143..4b446b6de7a 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -18,7 +18,7 @@ import { } from "@tremor/react"; import { TabPanel, TabPanels, TabGroup, TabList, Tab, TextInput, Icon, DateRangePicker } from "@tremor/react"; import { Select, SelectItem, MultiSelect, MultiSelectItem, DateRangePickerValue } from "@tremor/react"; -import { modelInfoCall, userGetRequesedtModelsCall, modelCreateCall, Model, modelCostMap, modelDeleteCall, healthCheckCall, modelUpdateCall, modelMetricsCall, modelExceptionsCall, modelMetricsSlowResponsesCall } from "./networking"; +import { modelInfoCall, userGetRequesedtModelsCall, modelCreateCall, Model, modelCostMap, modelDeleteCall, healthCheckCall, modelUpdateCall, modelMetricsCall, modelExceptionsCall, modelMetricsSlowResponsesCall, getCallbacksCall } from "./networking"; import { BarChart, AreaChart } from "@tremor/react"; import { Button as Button2, @@ -222,6 +222,10 @@ const ModelDashboard: React.FC = ({ to: new Date(), }); + const [modelGroupRetryPolicy, setModelGroupRetryPolicy] = useState>({}); + const [defaultRetry, setDefaultRetry] = useState(0); + + const EditModelModal: React.FC = ({ visible, onCancel, model, onSubmit }) => { const [form] = Form.useForm(); let litellm_params_to_edit: Record = {} @@ -525,6 +529,22 @@ const handleEditSubmit = async (formValues: Record) => { setSlowResponsesData(slowResponses); + const routerSettingsInfo = await getCallbacksCall(accessToken, userID, userRole); + + let router_settings = routerSettingsInfo.router_settings; + + console.log("routerSettingsInfo:", router_settings) + + let model_group_retry_policy = router_settings.model_group_retry_policy; + let default_retries = router_settings.num_retries; + + console.log("model_group_retry_policy:", model_group_retry_policy) + console.log("default_retries:", default_retries) + setModelGroupRetryPolicy(model_group_retry_policy); + setDefaultRetry(default_retries); + + + } catch (error) { console.error("There was an error fetching the model data", error); } @@ -1262,7 +1282,12 @@ const handleEditSubmit = async (formValues: Record) => { {key} - + + ))} From 87bd499d11ab3ab41fae602f1e954f2b9b8afd6e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 22:00:57 -0700 Subject: [PATCH 6/8] add save button on admin ui --- ui/litellm-dashboard/src/components/model_dashboard.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 4b446b6de7a..39ec6565bfc 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1294,6 +1294,9 @@ const handleEditSubmit = async (formValues: Record) => { } + From 1b9c799a93fe85149e4e6cbb1ae0ad55e925dfc3 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 22:06:43 -0700 Subject: [PATCH 7/8] ui - show retry on Admin UI --- ui/litellm-dashboard/src/components/model_dashboard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 39ec6565bfc..8c766989d94 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1285,7 +1285,7 @@ const handleEditSubmit = async (formValues: Record) => { From c762e60ae50c19fb5c434e7cb17697447e4a6f4a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 6 May 2024 07:53:55 -0700 Subject: [PATCH 8/8] stash ui changes --- .../src/components/model_dashboard.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 8c766989d94..43ca9fdff34 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1276,22 +1276,22 @@ const handleEditSubmit = async (formValues: Record) => { {retry_policy_map && - {Object.keys(retry_policy_map).map((key, idx) => ( - - - - - ))} - + {Object.keys(retry_policy_map).map((key, idx) => ( + + + + + ))} +
- {key} - - - -
+ {key} + + +
}