[Feat] LiteLLM Tag/Policy Management (#9813)
All checks were successful
Read Version from pyproject.toml / read-version (push) Successful in 15s
Helm unit test / unit-test (push) Successful in 21s

* rendering tags on UI

* use /models for building tags

* CRUD endpoints for Tag management

* fix tag management

* working api for LIST tags

* working tag management

* refactor UI components

* fixes ui tag management

* clean up ui tag management

* fix tag management ui

* fix show allowed llms

* e2e tag controls

* stash change for rendering tags on UI

* ui working tag selector on Test Key page

* fixes for tag management

* clean up tag info

* fix code quality

* test for tag management

* ui clarify what tag routing is
This commit is contained in:
Ishaan Jaff 2025-04-07 21:54:24 -07:00 committed by GitHub
parent ac9f03beae
commit ff3a6830a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1595 additions and 9 deletions

View file

@ -3,6 +3,7 @@
*/
import { all_admin_roles } from "@/utils/roles";
import { message } from "antd";
import { TagNewRequest, TagUpdateRequest, TagDeleteRequest, TagInfoRequest, TagListResponse, TagInfoResponse } from "./tag_management/types";
const isLocal = process.env.NODE_ENV === "development";
export const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
@ -4155,4 +4156,157 @@ export const callMCPTool = async (accessToken: string, toolName: string, toolArg
console.error("Failed to call MCP tool:", error);
throw error;
}
};
export const tagCreateCall = async (
accessToken: string,
formValues: TagNewRequest
): Promise<void> => {
try {
let url = proxyBaseUrl
? `${proxyBaseUrl}/tag/new`
: `/tag/new`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify(formValues),
});
if (!response.ok) {
const errorData = await response.text();
await handleError(errorData);
return;
}
return await response.json();
} catch (error) {
console.error("Error creating tag:", error);
throw error;
}
};
export const tagUpdateCall = async (
accessToken: string,
formValues: TagUpdateRequest
): Promise<void> => {
try {
let url = proxyBaseUrl
? `${proxyBaseUrl}/tag/update`
: `/tag/update`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify(formValues),
});
if (!response.ok) {
const errorData = await response.text();
await handleError(errorData);
return;
}
return await response.json();
} catch (error) {
console.error("Error updating tag:", error);
throw error;
}
};
export const tagInfoCall = async (
accessToken: string,
tagNames: string[]
): Promise<TagInfoResponse> => {
try {
let url = proxyBaseUrl
? `${proxyBaseUrl}/tag/info`
: `/tag/info`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({ names: tagNames }),
});
if (!response.ok) {
const errorData = await response.text();
await handleError(errorData);
return {};
}
const data = await response.json();
return data as TagInfoResponse;
} catch (error) {
console.error("Error getting tag info:", error);
throw error;
}
};
export const tagListCall = async (accessToken: string): Promise<TagListResponse> => {
try {
let url = proxyBaseUrl
? `${proxyBaseUrl}/tag/list`
: `/tag/list`;
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
if (!response.ok) {
const errorData = await response.text();
await handleError(errorData);
return {};
}
const data = await response.json();
return data as TagListResponse;
} catch (error) {
console.error("Error listing tags:", error);
throw error;
}
};
export const tagDeleteCall = async (
accessToken: string,
tagName: string
): Promise<void> => {
try {
let url = proxyBaseUrl
? `${proxyBaseUrl}/tag/delete`
: `/tag/delete`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({ name: tagName }),
});
if (!response.ok) {
const errorData = await response.text();
await handleError(errorData);
return;
}
return await response.json();
} catch (error) {
console.error("Error deleting tag:", error);
throw error;
}
};