diff --git a/litellm/litellm_core_utils/credential_accessor.py b/litellm/litellm_core_utils/credential_accessor.py index f7a2c90ee2..d87dcc116b 100644 --- a/litellm/litellm_core_utils/credential_accessor.py +++ b/litellm/litellm_core_utils/credential_accessor.py @@ -21,8 +21,10 @@ class CredentialAccessor: def upsert_credentials(credentials: List[CredentialItem]): """Add a credential to the list of credentials.""" + credential_names = [cred.credential_name for cred in litellm.credential_list] + for credential in credentials: - if credential.credential_name in litellm.credential_list: + if credential.credential_name in credential_names: # Find and replace the existing credential in the list for i, existing_cred in enumerate(litellm.credential_list): if existing_cred.credential_name == credential.credential_name: diff --git a/litellm/proxy/credential_endpoints/endpoints.py b/litellm/proxy/credential_endpoints/endpoints.py index 468e51e431..045ebccbda 100644 --- a/litellm/proxy/credential_endpoints/endpoints.py +++ b/litellm/proxy/credential_endpoints/endpoints.py @@ -85,7 +85,7 @@ async def get_credentials( masked_credentials = [ { "credential_name": credential.credential_name, - "credential_values": credential.credential_values, + "credential_info": credential.credential_info, } for credential in litellm.credential_list ] diff --git a/ui/litellm-dashboard/src/components/model_add/credentials.tsx b/ui/litellm-dashboard/src/components/model_add/credentials.tsx index d15b1e86c5..4af5daa3db 100644 --- a/ui/litellm-dashboard/src/components/model_add/credentials.tsx +++ b/ui/litellm-dashboard/src/components/model_add/credentials.tsx @@ -13,7 +13,7 @@ import { } from "@tremor/react"; import { UploadProps } from "antd/es/upload"; import { PlusIcon } from "@heroicons/react/solid"; -import { getCredentialsList, credentialCreateCall } from "@/components/networking"; // Assume this is your networking function +import { credentialListCall, credentialCreateCall } from "@/components/networking"; // Assume this is your networking function import AddCredentialsTab from "./add_credentials_tab"; import { Form, message } from "antd"; interface CredentialsPanelProps { @@ -27,16 +27,11 @@ interface CredentialsResponse { interface CredentialItem { credential_name: string | null; - provider: string; - credential_values: { - api_key?: string; - api_base?: string; - }; + credential_values: object; credential_info: { + custom_llm_provider?: string; description?: string; - type: string; - required: boolean; - default?: string; + required?: boolean; }; } @@ -78,7 +73,7 @@ const CredentialsPanel: React.FC = ({ accessToken, upload const fetchCredentials = async () => { try { - const response: CredentialsResponse = await getCredentialsList(accessToken); + const response: CredentialsResponse = await credentialListCall(accessToken); console.log(`credentials: ${JSON.stringify(response)}`); setCredentialsList(response.credentials); } catch (error) { @@ -127,7 +122,6 @@ const CredentialsPanel: React.FC = ({ accessToken, upload Credential Name Provider Description - Required @@ -142,18 +136,9 @@ const CredentialsPanel: React.FC = ({ accessToken, upload {credential.credential_name} - {renderProviderBadge(credential.provider)} - - {credential.credential_info.description || '-'} - -
- {credential.credential_info.required ? 'Required' : 'Optional'} -
+ {renderProviderBadge(credential.credential_info?.custom_llm_provider as string || '-')}
+ {credential.credential_info?.description || '-'}
)) )} diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index a9883beed0..505441debb 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -2572,6 +2572,40 @@ export const credentialCreateCall = async ( } }; +export const credentialListCall = async ( + accessToken: String, +) => { + /** + * Get all available teams on proxy + */ + try { + let url = proxyBaseUrl ? `${proxyBaseUrl}/credentials` : `/credentials`; + console.log("in credentialListCall"); + + const response = await fetch(url, { + method: "GET", + headers: { + [globalLitellmHeaderName]: `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + }); + + if (!response.ok) { + const errorData = await response.text(); + handleError(errorData); + throw new Error("Network response was not ok"); + } + + const data = await response.json(); + console.log("/credentials API Response:", data); + return data; + // Handle success - you might want to update some state or UI based on the created key + } catch (error) { + console.error("Failed to create key:", error); + throw error; + } +}; + export const keyUpdateCall = async ( accessToken: string, formValues: Record // Assuming formValues is an object