mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
Allow team admins to add/update/delete models on UI + show api base and model id on request logs (#9572)
* feat(view_logs.tsx): show model id + api base in request logs easier debugging * fix(index.tsx): fix length of api base easier viewing * refactor(leftnav.tsx): show models tab to team admin * feat(model_dashboard.tsx): add explainer for what the 'models' page is for team admin helps them understand how they can use it * feat(model_management_endpoints.py): restrict model add by team to just team admin allow team admin to add models via non-team keys (e.g. ui token) * test(test_add_update_models.py): update unit testing for new behaviour * fix(model_dashboard.tsx): show user the models * feat(proxy_server.py): add new query param 'user_models_only' to `/v2/model/info` Allows user to retrieve just the models they've added Used in UI to show internal users just the models they've added * feat(model_dashboard.tsx): allow team admins to view their own models * fix: allow ui user to fetch model cost map * feat(add_model_tab.tsx): require team admins to specify team when onboarding models * fix(_types.py): add `/v1/model/info` to info route `/model/info` was already there * fix(model_info_view.tsx): allow user to edit a model they created * fix(model_management_endpoints.py): allow team admin to update team model * feat(model_managament_endpoints.py): allow team admin to delete team models * fix(model_management_endpoints.py): don't require team id to be set when adding a model * fix(proxy_server.py): fix linting error * fix: fix ui linting error * fix(model_management_endpoints.py): ensure consistent auth checks on all model calls * test: remove old test - function no longer exists in same form * test: add updated mock testing
This commit is contained in:
parent
a5fbe50f04
commit
ed8c63b51e
11 changed files with 483 additions and 144 deletions
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* Helper file for calls being made to proxy
|
||||
*/
|
||||
import { all_admin_roles } from "@/utils/roles";
|
||||
import { message } from "antd";
|
||||
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
|
@ -131,9 +132,9 @@ export const modelCreateCall = async (
|
|||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
const errorData = await response.text();
|
||||
const errorMsg =
|
||||
errorData.error?.message?.error ||
|
||||
errorData||
|
||||
"Network response was not ok";
|
||||
message.error(errorMsg);
|
||||
throw new Error(errorMsg);
|
||||
|
@ -183,9 +184,8 @@ export const modelSettingsCall = async (accessToken: String) => {
|
|||
//message.info("Received model 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 get callbacks:", error);
|
||||
throw error;
|
||||
} catch (error: any) {
|
||||
console.error("Failed to get model settings:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1213,8 +1213,12 @@ export const modelInfoCall = async (
|
|||
* Get all models on proxy
|
||||
*/
|
||||
try {
|
||||
console.log("modelInfoCall:", accessToken, userID, userRole);
|
||||
let url = proxyBaseUrl ? `${proxyBaseUrl}/v2/model/info` : `/v2/model/info`;
|
||||
|
||||
if (!all_admin_roles.includes(userRole as string)) { // only show users models they've added
|
||||
url += `?user_models_only=true`;
|
||||
}
|
||||
//message.info("Requesting model data");
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue