feat: refactor add models tab on UI to enable setting credentials

This commit is contained in:
Krrish Dholakia 2025-03-12 20:32:01 -07:00
parent 52926408cd
commit d604f52884
6 changed files with 192 additions and 40 deletions

View file

@ -36,6 +36,21 @@ export interface Organization {
members: any[] | null;
}
export interface CredentialItem {
credential_name: string;
credential_values: object;
credential_info: {
custom_llm_provider?: string;
description?: string;
required?: boolean;
};
}
export interface CredentialsResponse {
credentials: CredentialItem[];
}
const baseUrl = "/"; // Assuming the base URL is the root
@ -2606,6 +2621,34 @@ export const credentialListCall = async (
}
};
export const credentialDeleteCall = async (accessToken: String, credentialName: String) => {
try {
const url = proxyBaseUrl ? `${proxyBaseUrl}/credentials/${credentialName}` : `/credentials/${credentialName}`;
console.log("in credentialDeleteCall:", credentialName);
const response = await fetch(url, {
method: "DELETE",
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(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 delete key:", error);
throw error;
}
};
export const keyUpdateCall = async (
accessToken: string,
formValues: Record<string, any> // Assuming formValues is an object