From 017a958469bf9c85a25052114c49c33cbc8f814b Mon Sep 17 00:00:00 2001 From: Jaswanth Karani Date: Thu, 6 Feb 2025 08:18:37 +0530 Subject: [PATCH] fixed issues #8126 and #8127 (#8275) --- .../src/components/add_model/handle_add_model_submit.tsx | 4 +++- ui/litellm-dashboard/src/components/delete_model_button.tsx | 3 +++ ui/litellm-dashboard/src/components/model_dashboard.tsx | 3 ++- ui/litellm-dashboard/src/components/networking.tsx | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx index 56f1fe742e0b..f64f6366cdcd 100644 --- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx +++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx @@ -6,7 +6,8 @@ import { modelCreateCall, Model } from "../networking"; export const handleAddModelSubmit = async ( formValues: Record, accessToken: string, - form: any + form: any, + callback?: ()=>void ) => { try { console.log("handling submit for formValues:", formValues); @@ -137,6 +138,7 @@ export const handleAddModelSubmit = async ( }; const response: any = await modelCreateCall(accessToken, new_model); + callback && callback() console.log(`response for model create call: ${response["data"]}`); }); diff --git a/ui/litellm-dashboard/src/components/delete_model_button.tsx b/ui/litellm-dashboard/src/components/delete_model_button.tsx index ee23cdb1b4c6..db7548744573 100644 --- a/ui/litellm-dashboard/src/components/delete_model_button.tsx +++ b/ui/litellm-dashboard/src/components/delete_model_button.tsx @@ -13,11 +13,13 @@ import { TrashIcon } from "@heroicons/react/outline"; interface DeleteModelProps { modelID: string; accessToken: string; + callback?: ()=>void; } const DeleteModelButton: React.FC = ({ modelID, accessToken, + callback }) => { const [isModalVisible, setIsModalVisible] = useState(false); @@ -30,6 +32,7 @@ const DeleteModelButton: React.FC = ({ console.log("model delete Response:", response); message.success(`Model ${modelID} deleted successfully`); setIsModalVisible(false); + callback && setTimeout(callback, 4000) //added timeout of 4 seconds as deleted model is taking time to reflect in get models } catch (error) { console.error("Error deleting the model:", error); } diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index a5dce262dfcf..2cd9ab425bf3 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1031,7 +1031,7 @@ const ModelDashboard: React.FC = ({ form .validateFields() .then((values) => { - handleAddModelSubmit(values, accessToken, form); + handleAddModelSubmit(values, accessToken, form, handleRefreshClick); // form.resetFields(); }) .catch((error) => { @@ -1450,6 +1450,7 @@ const ModelDashboard: React.FC = ({ diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 28e1b734222f..e9f543a87b45 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -98,7 +98,7 @@ export const modelCreateCall = async ( const data = await response.json(); console.log("API Response:", data); message.success( - "Model created successfully. Wait 60s and refresh on 'All Models' page" + "Model created successfully" ); return data; } catch (error) { @@ -168,7 +168,6 @@ export const modelDeleteCall = async ( const data = await response.json(); console.log("API Response:", data); - message.success("Model deleted successfully. Restart server to see this."); return data; } catch (error) { console.error("Failed to create key:", error);