feat(credentials/): working e2e flow for add / update models on LiteLLM UI

This commit is contained in:
Krrish Dholakia 2025-03-12 21:13:00 -07:00
parent e1a33a22b4
commit db3871366a
5 changed files with 132 additions and 27 deletions

View file

@ -2648,6 +2648,51 @@ export const credentialDeleteCall = async (accessToken: String, credentialName:
}
};
export const credentialUpdateCall = async (
accessToken: string,
credentialName: string,
formValues: Record<string, any> // Assuming formValues is an object
) => {
try {
console.log("Form Values in credentialUpdateCall:", formValues); // Log the form values before making the API call
if (formValues.metadata) {
console.log("formValues.metadata:", formValues.metadata);
// if there's an exception JSON.parse, show it in the message
try {
formValues.metadata = JSON.parse(formValues.metadata);
} catch (error) {
throw new Error("Failed to parse metadata: " + error);
}
}
const url = proxyBaseUrl ? `${proxyBaseUrl}/credentials/${credentialName}` : `/credentials/${credentialName}`;
const response = await fetch(url, {
method: "PUT",
headers: {
[globalLitellmHeaderName]: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
...formValues, // Include formValues in the request body
}),
});
if (!response.ok) {
const errorData = await response.text();
handleError(errorData);
console.error("Error response from the server:", errorData);
throw new Error("Network response was not ok");
}
const data = await response.json();
console.log("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,