mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
(ui) show spend when budget not set
This commit is contained in:
parent
a8473042d1
commit
3d890ff396
2 changed files with 42 additions and 2 deletions
|
@ -206,6 +206,40 @@ export const userInfoCall = async (
|
|||
}
|
||||
};
|
||||
|
||||
export const getTotalSpendCall = async (
|
||||
accessToken: String,
|
||||
) => {
|
||||
/**
|
||||
* Get all models on proxy
|
||||
*/
|
||||
try {
|
||||
let url = proxyBaseUrl ? `${proxyBaseUrl}/global/spend` : `/global/spend`;
|
||||
|
||||
//message.info("Requesting model data");
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
message.error(errorData);
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
//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 create key:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const modelInfoCall = async (
|
||||
accessToken: String,
|
||||
userID: String,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { userInfoCall, modelAvailableCall } from "./networking";
|
||||
import { userInfoCall, modelAvailableCall, getTotalSpendCall } from "./networking";
|
||||
import { Grid, Col, Card, Text } from "@tremor/react";
|
||||
import CreateKey from "./create_key_button";
|
||||
import ViewKeyTable from "./view_key_table";
|
||||
|
@ -129,7 +129,13 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
|
|||
response
|
||||
)}; team values: ${Object.entries(response.teams)}`
|
||||
);
|
||||
if (userRole == "Admin") {
|
||||
const globalSpend = await getTotalSpendCall(accessToken);
|
||||
setUserSpendData(globalSpend);
|
||||
console.log("globalSpend:", globalSpend);
|
||||
} else {
|
||||
setUserSpendData(response["user_info"]);
|
||||
}
|
||||
setKeys(response["keys"]); // Assuming this is the correct path to your data
|
||||
setTeams(response["teams"]);
|
||||
setSelectedTeam(response["teams"] ? response["teams"][0] : null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue