From 91eee78a8cb57d64113d1a8141cb9a02407cf060 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 24 Jul 2025 20:19:22 -0700 Subject: [PATCH] Revert "EditAutoRouterTabProps" This reverts commit 2835d3a3743e6411b9914a0b01381050e2273ad7. --- .../edit_model/edit_auto_router_tab.tsx | 293 ------------------ 1 file changed, 293 deletions(-) delete mode 100644 ui/litellm-dashboard/src/components/edit_model/edit_auto_router_tab.tsx diff --git a/ui/litellm-dashboard/src/components/edit_model/edit_auto_router_tab.tsx b/ui/litellm-dashboard/src/components/edit_model/edit_auto_router_tab.tsx deleted file mode 100644 index 3d33472bc6..0000000000 --- a/ui/litellm-dashboard/src/components/edit_model/edit_auto_router_tab.tsx +++ /dev/null @@ -1,293 +0,0 @@ -import React, { useState, useEffect } from "react"; -import { Card, Form, Button, Tooltip, Typography, Select as AntdSelect, message } from "antd"; -import type { FormInstance } from "antd"; -import { Text, TextInput } from "@tremor/react"; -import { modelAvailableCall } from "../networking"; -import { all_admin_roles } from "@/utils/roles"; -import { fetchAvailableModels, ModelGroup } from "../chat_ui/llm_calls/fetch_models"; -import RouterConfigBuilder from "../add_model/router_config_builder"; - -const { Title } = Typography; - -interface EditAutoRouterTabProps { - form: FormInstance; - localModelData: any; - accessToken: string; - userRole: string; - isEditing: boolean; - setIsDirty: (dirty: boolean) => void; -} - -const EditAutoRouterTab: React.FC = ({ - form, - localModelData, - accessToken, - userRole, - isEditing, - setIsDirty, -}) => { - const [modelAccessGroups, setModelAccessGroups] = useState([]); - const [modelInfo, setModelInfo] = useState([]); - const [showCustomDefaultModel, setShowCustomDefaultModel] = useState(false); - const [showCustomEmbeddingModel, setShowCustomEmbeddingModel] = useState(false); - const [routerConfig, setRouterConfig] = useState(null); - - const isAdmin = all_admin_roles.includes(userRole); - - useEffect(() => { - const fetchModelAccessGroups = async () => { - const response = await modelAvailableCall(accessToken, "", "", false, null, true, true); - setModelAccessGroups(response["data"].map((model: any) => model["id"])); - }; - fetchModelAccessGroups(); - }, [accessToken]); - - useEffect(() => { - const loadModels = async () => { - try { - const uniqueModels = await fetchAvailableModels(accessToken); - console.log("Fetched models for auto router edit:", uniqueModels); - setModelInfo(uniqueModels); - } catch (error) { - console.error("Error fetching model info for auto router edit:", error); - } - }; - loadModels(); - }, [accessToken]); - - // Initialize form values and router config when localModelData changes - useEffect(() => { - if (localModelData) { - const autoRouterConfig = localModelData.litellm_params?.auto_router_config; - let parsedConfig = null; - - if (autoRouterConfig) { - try { - // Parse the JSON string to object - parsedConfig = typeof autoRouterConfig === 'string' - ? JSON.parse(autoRouterConfig) - : autoRouterConfig; - setRouterConfig(parsedConfig); - } catch (error) { - console.error("Error parsing auto router config:", error); - } - } - - // Check if using custom models - const defaultModel = localModelData.litellm_params?.auto_router_default_model; - const embeddingModel = localModelData.litellm_params?.auto_router_embedding_model; - - setShowCustomDefaultModel(defaultModel && !modelInfo.some(m => m.model_group === defaultModel)); - setShowCustomEmbeddingModel(embeddingModel && !modelInfo.some(m => m.model_group === embeddingModel)); - } - }, [localModelData, modelInfo]); - - const handleRouterConfigChange = (config: any) => { - setRouterConfig(config); - form.setFieldValue('auto_router_config', config); - setIsDirty(true); - }; - - return ( -
-
- Auto Router Configuration - - Configure the auto routing logic that automatically selects the best model based on user input patterns and semantic matching. - -
- -
- {/* Auto Router Name */} -
- Auto Router Name - {isEditing ? ( - - setIsDirty(true)} - /> - - ) : ( -
- {localModelData.model_name || "Not Set"} -
- )} -
- - {/* Router Configuration Builder */} - {isEditing ? ( -
- -
- ) : ( -
- Router Configuration -
- {routerConfig ? ( -
- Routes: {routerConfig.routes?.length || 0} - {routerConfig.routes?.map((route: any, index: number) => ( -
-
Model: {route.name}
-
Description: {route.description}
-
Utterances: {route.utterances?.length || 0} examples
-
Score Threshold: {route.score_threshold}
-
- ))} -
- ) : ( - "No router configuration" - )} -
-
- )} - - {/* Default Model */} -
- Default Model - {isEditing ? ( - <> - - { - setShowCustomDefaultModel(value === 'custom'); - setIsDirty(true); - }} - options={[ - ...Array.from(new Set(modelInfo.map(option => option.model_group))) - .map((model_group) => ({ - value: model_group, - label: model_group, - })), - { value: 'custom', label: 'Enter custom model name' } - ]} - style={{ width: "100%" }} - showSearch={true} - /> - - {showCustomDefaultModel && ( - - { - form.setFieldValue('auto_router_default_model', e.target.value); - setIsDirty(true); - }} - /> - - )} - - ) : ( -
- {localModelData.litellm_params?.auto_router_default_model || "Not Set"} -
- )} -
- - {/* Embedding Model */} -
- Embedding Model - {isEditing ? ( - <> - - { - setShowCustomEmbeddingModel(value === 'custom'); - setIsDirty(true); - }} - options={[ - ...Array.from(new Set(modelInfo.map(option => option.model_group))) - .map((model_group) => ({ - value: model_group, - label: model_group, - })), - { value: 'custom', label: 'Enter custom model name' } - ]} - style={{ width: "100%" }} - showSearch={true} - allowClear - /> - - {showCustomEmbeddingModel && ( - - { - form.setFieldValue('auto_router_embedding_model', e.target.value); - setIsDirty(true); - }} - /> - - )} - - ) : ( -
- {localModelData.litellm_params?.auto_router_embedding_model || "Not Set"} -
- )} -
- - {/* Model Access Groups - Admin only */} - {isAdmin && ( -
- Model Access Groups - {isEditing ? ( - - ({ - value: group, - label: group - }))} - maxTagCount="responsive" - allowClear - onChange={() => setIsDirty(true)} - /> - - ) : ( -
- {localModelData.model_info?.access_groups ? ( - Array.isArray(localModelData.model_info.access_groups) ? ( - localModelData.model_info.access_groups.length > 0 ? ( -
- {localModelData.model_info.access_groups.map( - (group: string, index: number) => ( - - {group} - - ) - )} -
- ) : ( - "No groups assigned" - ) - ) : ( - localModelData.model_info.access_groups - ) - ) : ( - "Not Set" - )} -
- )} -
- )} -
-
- ); -}; - -export default EditAutoRouterTab; \ No newline at end of file