Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

UI - fix adding vertex models with reusable credentials + fix pagination on keys table + fix showing org budgets on table (#10528)

Krish Dholakiab412d7023295
diff --git a/litellm/proxy/management_endpoints/organization_endpoints.py b/litellm/proxy/management_endpoints/organization_endpoints.py
index f0b0b645d29..799b5dbec77 100644
--- a/litellm/proxy/management_endpoints/organization_endpoints.py
+++ b/litellm/proxy/management_endpoints/organization_endpoints.py
@@ -320,7 +320,7 @@ async def list_organization(
# if proxy admin - get all orgs
if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN:
response = await prisma_client.db.litellm_organizationtable.find_many(
- include={"members": True, "teams": True}
+ include={"litellm_budget_table": True, "members": True, "teams": True}
)
# if internal user - get orgs they are a member of
else:
@@ -335,7 +335,7 @@ async def list_organization(
"in": [membership.organization_id for membership in org_memberships]
}
},
- include={"members": True, "teams": True},
+ include={"litellm_budget_table": True, "members": True, "teams": True},
)
response = org_objects
diff --git a/tests/test_organizations.py b/tests/test_organizations.py
index 565aba14d46..46281b4789d 100644
--- a/tests/test_organizations.py
+++ b/tests/test_organizations.py
@@ -180,6 +180,12 @@ async def list_organization(session, i):
if status != 200:
raise Exception(f"Request {i} did not return a 200 status code: {status}")
+ # Assert that budget info is returned for each organization
+ for org in response_json:
+ assert "litellm_budget_table" in org, "Missing budget info in organization response"
+ # Optionally also check that it's not null
+ assert org["litellm_budget_table"] is not None, "Budget info is None"
+
return response_json
diff --git a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
index 6d6fd4288fe..8b00795ac6a 100644
--- a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
@@ -348,12 +348,42 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({
uploadProps
}) => {
const selectedProviderEnum = Providers[selectedProvider as keyof typeof Providers] as Providers;
-
+ const form = Form.useFormInstance(); // Get form instance from context
+
// Simply use the fields as defined in PROVIDER_CREDENTIAL_FIELDS
const allFields = React.useMemo(() => {
return PROVIDER_CREDENTIAL_FIELDS[selectedProviderEnum] || [];
}, [selectedProviderEnum]);
+ const handleUpload = {
+ name: "file",
+ accept: ".json",
+ beforeUpload: (file: any) => {
+ if (file.type === "application/json") {
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ if (e.target) {
+ const jsonStr = e.target.result as string;
+ console.log(`Setting field value from JSON, length: ${jsonStr.length}`);
+ form.setFieldsValue({ vertex_credentials: jsonStr });
+ console.log("Form values after setting:", form.getFieldsValue());
+ }
+ };
+ reader.readAsText(file);
+ }
+ // Prevent upload
+ return false;
+ },
+ onChange(info: any) {
+ console.log("Upload onChange triggered in ProviderSpecificFields");
+ console.log("Current form values:", form.getFieldsValue());
+
+ if (info.file.status !== "uploading") {
+ console.log(info.file, info.fileList);
+ }
+ }
+ };
+
return (
<>
{allFields.map((field) => (
@@ -377,7 +407,21 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({
))}
</Select>
) : field.type === "upload" ? (
- <Upload {...uploadProps}>
+ <Upload
+ {...handleUpload}
+ onChange={(info) => {
+ // First call the original onChange
+ if (uploadProps?.onChange) {
+ uploadProps.onChange(info);
+ }
+
+ // Check the field value after a short delay
+ setTimeout(() => {
+ const value = form.getFieldValue(field.key);
+ console.log(`${field.key} value after upload:`, JSON.stringify(value));
+ }, 500);
+ }}
+ >
<Button2 icon={<UploadOutlined />}>Click to Upload</Button2>
</Upload>
) : (
diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
index 6ae5f559a64..02b4aad3755 100644
--- a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
+++ b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
@@ -131,6 +131,9 @@ const useKeyList = ({
}
setIsLoading(true);
+ const page = typeof params.page === 'number' ? params.page : 1;
+ const pageSize = typeof params.pageSize === 'number' ? params.pageSize : 100;
+
const data = await keyListCall(
accessToken,
null,
@@ -138,8 +141,8 @@ const useKeyList = ({
null,
null,
null,
- 1,
- 50,
+ page,
+ pageSize,
);
console.log("data", data);
setKeyData(data);
diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx
index eaa2a324b4e..bdac032f315 100644
--- a/ui/litellm-dashboard/src/components/model_dashboard.tsx
+++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx
@@ -445,8 +445,10 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
const reader = new FileReader();
reader.onload = (e) => {
if (e.target) {
- const jsonStr = e.target.result as string;
+ const jsonStr = e.target.result as string;
+ console.log(`Resetting vertex_credentials to JSON; jsonStr: ${jsonStr}`);
form.setFieldsValue({ vertex_credentials: jsonStr });
+ console.log("Form values right after setting:", form.getFieldsValue());
}
};
reader.readAsText(file);
@@ -455,6 +457,9 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
return false;
},
onChange(info) {
+ console.log("Upload onChange triggered with values:", info);
+ console.log("Current form values:", form.getFieldsValue());
+
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}