diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index 63431d13b3..6ce413c703 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -1,20 +1,26 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState } from "react"; import { modelHubCall } from "./networking"; -import { Card, Text, Title, Grid, Button, Badge, Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, } from "@tremor/react"; +import { + Card, + Text, + Title, + Grid, + Button, + Badge, + Tab, + TabGroup, + TabList, + TabPanel, + TabPanels, +} from "@tremor/react"; -import { RightOutlined, CopyOutlined } from '@ant-design/icons'; +import { RightOutlined, CopyOutlined } from "@ant-design/icons"; -import { Modal, Tooltip } from 'antd'; +import { Modal, Tooltip } from "antd"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; - - interface ModelHubProps { userID: string | null; userRole: string | null; @@ -22,25 +28,20 @@ interface ModelHubProps { accessToken: string | null; keys: any; // Replace with the appropriate type for 'keys' prop premiumUser: boolean; - } interface ModelInfo { - model_group: string; - mode: string; - supports_function_calling: boolean; - supports_vision: boolean; - max_input_tokens?: number; - max_output_tokens?: number; - - // Add other properties if needed - - } - + model_group: string; + mode: string; + supports_function_calling: boolean; + supports_vision: boolean; + max_input_tokens?: number; + max_output_tokens?: number; + // Add other properties if needed +} const ModelHub: React.FC = ({ - userID, userRole, @@ -52,200 +53,141 @@ const ModelHub: React.FC = ({ keys, premiumUser, - }) => { - - const [modelHubData, setModelHubData] = useState(null); + const [modelHubData, setModelHubData] = useState(null); const [isModalVisible, setIsModalVisible] = useState(false); - const [selectedModel, setSelectedModel] = useState(null); - + const [selectedModel, setSelectedModel] = useState(null); useEffect(() => { - if (!accessToken || !token || !userRole || !userID) { return; } - - const fetchData = async () => { - try { - const _modelHubData = await modelHubCall(accessToken, userID, userRole); console.log("ModelHubData:", _modelHubData); setModelHubData(_modelHubData.data); - } catch (error) { - console.error("There was an error fetching the model data", error); - } - }; - - fetchData(); - }, [accessToken, token, userRole, userID]); - - const showModal = (model: ModelInfo) => { - setSelectedModel(model); setIsModalVisible(true); - }; - - const handleOk = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const handleCancel = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text); - }; - - return ( -
+
+
-
- -
- - - -
- - -
- - Model Hub - - +
+ Model Hub +
- - +
+ {modelHubData && + modelHubData.map((model: ModelInfo) => ( + +
+                  {model.model_group}
+                  
+                     copyToClipboard(model.model_group)}
+                      style={{ cursor: "pointer", marginRight: "10px" }}
+                    />
+                  
+                
- - {modelHubData && modelHubData.map((model: ModelInfo) => ( - - - - - -
-                
-
-                {model.model_group}
-                
-
-                     copyToClipboard(model.model_group)} style={{ cursor: 'pointer', marginRight: '10px' }} />
-
-                    
-
-              
- -
- - Mode: {model.mode} - Supports Function Calling: {model?.supports_function_calling == true ? "Yes" : "No"} - Supports Vision: {model?.supports_vision == true ? "Yes" : "No"} - Max Input Tokens: {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} - Max Output Tokens: {model?.max_output_tokens ? model?.max_output_tokens : "N/A"} - -
- - - -
- - ))} +
+ Mode: {model.mode} + + Supports Function Calling:{" "} + {model?.supports_function_calling == true ? "Yes" : "No"} + + + Supports Vision:{" "} + {model?.supports_vision == true ? "Yes" : "No"} + + + Max Input Tokens:{" "} + {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} + + + Max Output Tokens:{" "} + {model?.max_output_tokens + ? model?.max_output_tokens + : "N/A"} + +
+ +
+ ))}
-
- {selectedModel && ( -
+

+ Model Name: {selectedModel.model_group} +

-

Model Name: {selectedModel.model_group}

- - - OpenAI Python SDK - LlamaIndex - Langchain Py - - - - - {` + + OpenAI Python SDK + LlamaIndex + Langchain Py + + + + + {` import openai client = openai.OpenAI( api_key="your_api_key", @@ -264,11 +206,11 @@ response = client.chat.completions.create( print(response) `} - - - - - {` + + + + + {` import os, dotenv from llama_index.llms import AzureOpenAI @@ -300,11 +242,11 @@ response = query_engine.query("What did the author do growing up?") print(response) `} - - - - - {` + + + + + {` from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate, @@ -332,27 +274,19 @@ response = chat(messages) print(response) `} - - - - + + + + {/*

Additional Params: {JSON.stringify(selectedModel.litellm_params)}

*/} {/* Add other model details here */} -
- )} -
-
- ); - }; - - -export default ModelHub; \ No newline at end of file +export default ModelHub;