mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Add all /key/generate
api params to UI + add metadata fields on team AND org add/update (#8667)
* feat(create_key_button.tsx): initial commit using openapi.json to ensure all values via api are supported on ui for `/key/generate` Closes https://github.com/BerriAI/litellm/issues/7763 * style(create_key_button.tsx): put openapi settings inside 'advanced setting' accordion * fix(check_openapi_schema.tsx): style improvements for advanced settings * style(create_key_button.tsx): add tooltip explaining what the settings mean * fix(team_info.tsx): render metadata field on team update allow updating a team's metadata * fix(networking.tsx): add 'metadata' field to create team form * refactor: cleanup dead codeblock * fix(organization_endpoints.py): fix metadata param support on `/organization/new` * feat(organization_endpoints.py): support updating metadata for organization on api + ui * test: mark flaky test
This commit is contained in:
parent
40d1576292
commit
cc77138b37
11 changed files with 392 additions and 209 deletions
|
@ -4,7 +4,7 @@
|
|||
import { message } from "antd";
|
||||
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
export const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
@ -69,6 +69,12 @@ export function setGlobalLitellmHeaderName(headerName: string = "Authorization")
|
|||
globalLitellmHeaderName = headerName;
|
||||
}
|
||||
|
||||
export const getOpenAPISchema = async () => {
|
||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/openapi.json` : `/openapi.json`;
|
||||
const response = await fetch(url);
|
||||
const jsonData = await response.json();
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
export const modelCostMap = async (
|
||||
accessToken: string,
|
||||
|
@ -882,6 +888,17 @@ export const organizationCreateCall = async (
|
|||
try {
|
||||
console.log("Form Values in organizationCreateCall:", 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) {
|
||||
console.error("Failed to parse metadata:", error);
|
||||
throw new Error("Failed to parse metadata: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/organization/new` : `/organization/new`;
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
|
@ -911,6 +928,42 @@ export const organizationCreateCall = async (
|
|||
}
|
||||
};
|
||||
|
||||
export const organizationUpdateCall = async (
|
||||
accessToken: string,
|
||||
formValues: Record<string, any> // Assuming formValues is an object
|
||||
) => {
|
||||
try {
|
||||
console.log("Form Values in organizationUpdateCall:", formValues); // Log the form values before making the API call
|
||||
|
||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/organization/update` : `/organization/update`;
|
||||
const response = await fetch(url, {
|
||||
method: "PATCH",
|
||||
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("Update Team 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 organizationDeleteCall = async (
|
||||
accessToken: string,
|
||||
organizationID: string
|
||||
|
@ -2377,6 +2430,15 @@ export const teamCreateCall = async (
|
|||
) => {
|
||||
try {
|
||||
console.log("Form Values in teamCreateCall:", 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}/team/new` : `/team/new`;
|
||||
const response = await fetch(url, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue