The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
create key table render fix (#10224)
Nandini Baggaab9705781f48
diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsxindex 2a3b7422ce1..70387046401 100644--- a/ui/litellm-dashboard/src/app/page.tsx+++ b/ui/litellm-dashboard/src/app/page.tsx@@ -103,7 +103,7 @@ export default function CreateKeyPage() {useState(false);const [userEmail, setUserEmail] = useState<null | string>(null);const [teams, setTeams] = useState<Team[] | null>(null);- const [keys, setKeys] = useState<null | any[]>(null);+ const [keys, setKeys] = useState<null | any[]>([]);const [organizations, setOrganizations] = useState<Organization[]>([]);const [userModels, setUserModels] = useState<string[]>([]);const [proxySettings, setProxySettings] = useState<ProxySettings>({@@ -115,6 +115,7 @@ export default function CreateKeyPage() {const searchParams = useSearchParams()!;const [modelData, setModelData] = useState<any>({ data: [] });const [token, setToken] = useState<string | null>(null);+ const [createClicked, setCreateClicked] = useState<boolean>(false);const [authLoading, setAuthLoading] = useState(true);const [userID, setUserID] = useState<string | null>(null);@@ -139,6 +140,10 @@ export default function CreateKeyPage() {const [accessToken, setAccessToken] = useState<string | null>(null);+ const addKey = (data: any) => {+ setKeys((prevData) => (prevData ? [...prevData, data] : [data]))+ setCreateClicked(() => !createClicked);+ }const redirectToLogin = authLoading === false && token === null && invitation_id === null;useEffect(() => {@@ -243,6 +248,8 @@ export default function CreateKeyPage() {setTeams={setTeams}setKeys={setKeys}organizations={organizations}+ addKey={addKey}+ createClicked={createClicked}/>) : (<div className="flex flex-col min-h-screen">@@ -277,6 +284,8 @@ export default function CreateKeyPage() {setTeams={setTeams}setKeys={setKeys}organizations={organizations}+ addKey={addKey}+ createClicked={createClicked}/>) : page == "models" ? (<ModelDashboarddiff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsxindex 41ea266d1b4..d484a81c13e 100644--- a/ui/litellm-dashboard/src/components/create_key_button.tsx+++ b/ui/litellm-dashboard/src/components/create_key_button.tsx@@ -52,8 +52,8 @@ interface CreateKeyProps {userRole: string | null;accessToken: string;data: any[] | null;- setData: React.Dispatch<React.SetStateAction<any[] | null>>;teams: Team[] | null;+ addKey: (data: any) => void;}interface User {@@ -149,7 +149,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({userRole,accessToken,data,- setData,+ addKey,}) => {const [form] = Form.useForm();const [isModalVisible, setIsModalVisible] = useState(false);@@ -267,13 +267,9 @@ const CreateKey: React.FC<CreateKeyProps> = ({console.log("key create Response:", response);- // Update the data state in this component- setData((prevData) => (prevData ? [...prevData, response] : [response]));-+ // Add the data to the state in the parent component// Also directly update the keys list in AllKeysTable without an API call- if (window.addNewKeyToList) {- window.addNewKeyToList(response);- }+ addKey(response)setApiKey(response["key"]);setSoftBudget(response["soft_budget"]);diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsxindex 533968361dc..6ae5f559a64 100644--- a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx+++ b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx@@ -87,7 +87,7 @@ selectedTeam?: Team;currentOrg: Organization | null;selectedKeyAlias: string | null;accessToken: string;-currentPage?: number;+createClicked: boolean;}interface PaginationData {@@ -111,7 +111,7 @@ const useKeyList = ({currentOrg,selectedKeyAlias,accessToken,- currentPage = 1,+ createClicked,}: UseKeyListProps): UseKeyListReturn => {const [keyData, setKeyData] = useState<KeyListResponse>({keys: [],@@ -163,7 +163,7 @@ const useKeyList = ({'selectedKeyAlias',selectedKeyAlias);- }, [selectedTeam, currentOrg, accessToken, selectedKeyAlias]);+ }, [selectedTeam, currentOrg, accessToken, selectedKeyAlias, createClicked]);const setKeys = (newKeysOrUpdater: KeyResponse[] | ((prevKeys: KeyResponse[]) => KeyResponse[])) => {setKeyData(prevData => {diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsxindex 4279c124d0a..6c1c6962d0d 100644--- a/ui/litellm-dashboard/src/components/user_dashboard.tsx+++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx@@ -66,6 +66,8 @@ interface UserDashboardProps {setKeys: React.Dispatch<React.SetStateAction<Object[] | null>>;premiumUser: boolean;organizations: Organization[] | null;+ addKey: (data: any) => void;+ createClicked: boolean}type TeamInterface = {@@ -85,7 +87,9 @@ const UserDashboard: React.FC<UserDashboardProps> = ({setTeams,setKeys,premiumUser,- organizations+ organizations,+ addKey,+ createClicked}) => {const [userSpendData, setUserSpendData] = useState<UserInfo | null>(null@@ -417,7 +421,7 @@ const UserDashboard: React.FC<UserDashboardProps> = ({userRole={userRole}accessToken={accessToken}data={keys}- setData={setKeys}+ addKey={addKey}/><ViewKeyTable@@ -435,6 +439,7 @@ const UserDashboard: React.FC<UserDashboardProps> = ({currentOrg={currentOrg}setCurrentOrg={setCurrentOrg}organizations={organizations}+ createClicked={createClicked}/></Col></Grid>diff --git a/ui/litellm-dashboard/src/components/view_key_table.tsx b/ui/litellm-dashboard/src/components/view_key_table.tsxindex c2d742f27ca..84b319a7076 100644--- a/ui/litellm-dashboard/src/components/view_key_table.tsx+++ b/ui/litellm-dashboard/src/components/view_key_table.tsx@@ -110,6 +110,7 @@ interface ViewKeyTableProps {setCurrentOrg: React.Dispatch<React.SetStateAction<Organization | null>>;selectedKeyAlias: string | null;setSelectedKeyAlias: Setter<string | null>;+ createClicked: boolean;}interface ItemData {@@ -159,7 +160,8 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({organizations,setCurrentOrg,selectedKeyAlias,- setSelectedKeyAlias+ setSelectedKeyAlias,+ createClicked}) => {const [isButtonClicked, setIsButtonClicked] = useState(false);const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);@@ -186,16 +188,9 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({currentOrg,selectedKeyAlias,accessToken,+ createClicked,});- // Make both refresh and addKey functions available globally- if (typeof window !== 'undefined') {- window.refreshKeysList = refresh;- window.addNewKeyToList = (newKey) => {- // Add the new key to the keys list without making an API call- setKeys((prevKeys) => [newKey, ...prevKeys]);- };- }const handlePageChange = (newPage: number) => {refresh({ page: newPage });