mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
feat(ui/): allow admin to reuse existing model credentials
Prevents need to go to backend llm provider for getting credentials
This commit is contained in:
parent
f089b1e23f
commit
9362fc1759
4 changed files with 598 additions and 159 deletions
|
@ -2652,6 +2652,42 @@ export const credentialListCall = async (
|
|||
}
|
||||
};
|
||||
|
||||
export const credentialGetCall = async (accessToken: String, credentialName: String | null, modelId: String | null) => {
|
||||
try {
|
||||
let url = proxyBaseUrl ? `${proxyBaseUrl}/credentials` : `/credentials`;
|
||||
|
||||
if (credentialName) {
|
||||
url += `/by_name/${credentialName}`;
|
||||
} else if (modelId) {
|
||||
url += `/by_model/${modelId}`;
|
||||
}
|
||||
|
||||
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 credentialDeleteCall = async (accessToken: String, credentialName: String) => {
|
||||
try {
|
||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/credentials/${credentialName}` : `/credentials/${credentialName}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue