diff --git a/ui/litellm-dashboard/src/components/delete_model_button.tsx b/ui/litellm-dashboard/src/components/delete_model_button.tsx new file mode 100644 index 0000000000..ee23cdb1b4 --- /dev/null +++ b/ui/litellm-dashboard/src/components/delete_model_button.tsx @@ -0,0 +1,71 @@ +"use client"; + +import React, { useState } from "react"; +import { Grid, Col, Icon } from "@tremor/react"; +import { Title } from "@tremor/react"; +import { + Modal, + message, +} from "antd"; +import { modelDeleteCall } from "./networking"; +import { TrashIcon } from "@heroicons/react/outline"; + +interface DeleteModelProps { + modelID: string; + accessToken: string; +} + +const DeleteModelButton: React.FC = ({ + modelID, + accessToken, +}) => { + const [isModalVisible, setIsModalVisible] = useState(false); + + const handleDelete = async () => { + try { + message.info("Making API Call"); + setIsModalVisible(true); + const response = await modelDeleteCall(accessToken, modelID); + + console.log("model delete Response:", response); + message.success(`Model ${modelID} deleted successfully`); + setIsModalVisible(false); + } catch (error) { + console.error("Error deleting the model:", error); + } + }; + + return ( +
+ setIsModalVisible(true)} + icon={TrashIcon} + size="sm" + /> + + setIsModalVisible(false)} + > + + + Delete Model + +

+ Are you sure you want to delete this model? This action is irreversible. +

+ + +

+ Model ID: {modelID} +

+ +
+
+
+ ); +}; + +export default DeleteModelButton; \ No newline at end of file diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 1cd86c6139..c54ce10104 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -35,6 +35,7 @@ import RequestAccess from "./request_model_access"; import { Typography } from "antd"; import TextArea from "antd/es/input/TextArea"; import { InformationCircleIcon, PencilAltIcon, PencilIcon, StatusOnlineIcon, TrashIcon } from "@heroicons/react/outline"; +import DeleteModelButton from "./delete_model_button"; const { Title: Title2, Link } = Typography; interface ModelDashboardProps { @@ -223,11 +224,6 @@ const ModelDashboard: React.FC = ({ ); } - const handleDelete = async (model_id: string) => { - await modelDeleteCall(accessToken, model_id) - }; - - const setProviderModelsFn = (provider: string) => { console.log(`received provider string: ${provider}`) const providerEnumValue = Providers[provider as keyof typeof Providers]; @@ -406,7 +402,9 @@ const ModelDashboard: React.FC = ({ {model.input_cost} {model.output_cost} {model.max_tokens} - handleDelete(model.model_info.id)}/> + + + ))}