forked from phoenix/litellm-mirror
LiteLLM Minor Fixes & Improvements (10/08/2024) (#6119)
* refactor(cost_calculator.py): move error line to debug - https://github.com/BerriAI/litellm/issues/5683#issuecomment-2398599498 * fix(migrate-hidden-params-to-read-from-standard-logging-payload): Fixes https://github.com/BerriAI/litellm/issues/5546#issuecomment-2399994026 * fix(types/utils.py): mark weight as a litellm param Fixes https://github.com/BerriAI/litellm/issues/5781 * feat(internal_user_endpoints.py): fix /user/info + show user max budget as default max budget Fixes https://github.com/BerriAI/litellm/issues/6117 * feat: support returning team member budget in `/user/info` Sets user max budget in team as max budget on ui Closes https://github.com/BerriAI/litellm/issues/6117 * bug fix for optional parameter passing to replicate (#6067) Signed-off-by: Mandana Vaziri <mvaziri@us.ibm.com> * fix(o1_transformation.py): handle o1 temperature=0 o1 doesn't support temp=0, allow admin to drop this param * test: fix test --------- Signed-off-by: Mandana Vaziri <mvaziri@us.ibm.com> Co-authored-by: Mandana Vaziri <mvaziri@us.ibm.com>
This commit is contained in:
parent
ac6fb0cbef
commit
9695c1af10
21 changed files with 260 additions and 86 deletions
|
@ -1,18 +1,20 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import { Select, SelectItem, Text, Title } from "@tremor/react";
|
||||
import { ProxySettings } from "./user_dashboard";
|
||||
import { ProxySettings, UserInfo } from "./user_dashboard";
|
||||
|
||||
interface DashboardTeamProps {
|
||||
teams: Object[] | null;
|
||||
setSelectedTeam: React.Dispatch<React.SetStateAction<any | null>>;
|
||||
userRole: string | null;
|
||||
proxySettings: ProxySettings | null;
|
||||
userInfo: UserInfo | null;
|
||||
}
|
||||
|
||||
type TeamInterface = {
|
||||
models: any[];
|
||||
team_id: null;
|
||||
team_alias: String
|
||||
team_alias: String;
|
||||
max_budget: number | null;
|
||||
}
|
||||
|
||||
const DashboardTeam: React.FC<DashboardTeamProps> = ({
|
||||
|
@ -20,11 +22,14 @@ const DashboardTeam: React.FC<DashboardTeamProps> = ({
|
|||
setSelectedTeam,
|
||||
userRole,
|
||||
proxySettings,
|
||||
userInfo,
|
||||
}) => {
|
||||
console.log(`userInfo: ${JSON.stringify(userInfo)}`)
|
||||
const defaultTeam: TeamInterface = {
|
||||
models: [],
|
||||
models: userInfo?.models || [],
|
||||
team_id: null,
|
||||
team_alias: "Default Team"
|
||||
team_alias: "Default Team",
|
||||
max_budget: userInfo?.max_budget || null,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,11 +23,6 @@ if (isLocal != true) {
|
|||
console.log("isLocal:", isLocal);
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
|
||||
type UserSpendData = {
|
||||
spend: number;
|
||||
max_budget?: number | null;
|
||||
};
|
||||
|
||||
export interface ProxySettings {
|
||||
PROXY_BASE_URL: string | null;
|
||||
PROXY_LOGOUT_URL: string | null;
|
||||
|
@ -35,6 +30,13 @@ export interface ProxySettings {
|
|||
SSO_ENABLED: boolean;
|
||||
}
|
||||
|
||||
|
||||
export type UserInfo = {
|
||||
models: string[];
|
||||
max_budget?: number | null;
|
||||
spend: number;
|
||||
}
|
||||
|
||||
function getCookie(name: string) {
|
||||
console.log("COOKIES", document.cookie)
|
||||
const cookieValue = document.cookie
|
||||
|
@ -74,7 +76,7 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
|
|||
setKeys,
|
||||
premiumUser,
|
||||
}) => {
|
||||
const [userSpendData, setUserSpendData] = useState<UserSpendData | null>(
|
||||
const [userSpendData, setUserSpendData] = useState<UserInfo | null>(
|
||||
null
|
||||
);
|
||||
|
||||
|
@ -186,14 +188,9 @@ 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"]);
|
||||
console.log(`userSpendData: ${JSON.stringify(userSpendData)}`)
|
||||
setKeys(response["keys"]); // Assuming this is the correct path to your data
|
||||
setTeams(response["teams"]);
|
||||
const teamsArray = [...response["teams"]];
|
||||
|
@ -352,6 +349,7 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
|
|||
setSelectedTeam={setSelectedTeam}
|
||||
userRole={userRole}
|
||||
proxySettings={proxySettings}
|
||||
userInfo={userSpendData}
|
||||
/>
|
||||
</Col>
|
||||
</Grid>
|
||||
|
|
|
@ -52,7 +52,35 @@ const ViewUserSpend: React.FC<ViewUserSpendProps> = ({ userID, userRole, accessT
|
|||
if (selectedTeam.team_alias === "Default Team") {
|
||||
setMaxBudget(userMaxBudget);
|
||||
} else {
|
||||
let setMaxBudgetFlag = false;
|
||||
if (selectedTeam.team_memberships) {
|
||||
/**
|
||||
* What 'team_memberships' looks like:
|
||||
* "team_memberships": [
|
||||
* {
|
||||
* "user_id": "2c315de3-e7ce-4269-b73e-b039a06187b1",
|
||||
* "team_id": "test-team_515e6f42-ded2-4f0d-8919-0a1f43c5a45f",
|
||||
* "budget_id": "0880769f-716a-4149-ab19-7f7651ad4db5",
|
||||
* "litellm_budget_table": {
|
||||
"soft_budget": null,
|
||||
"max_budget": 20.0,
|
||||
"max_parallel_requests": null,
|
||||
"tpm_limit": null,
|
||||
"rpm_limit": null,
|
||||
"model_max_budget": null,
|
||||
"budget_duration": null
|
||||
}
|
||||
*/
|
||||
for (const member of selectedTeam.team_memberships) {
|
||||
if (member.user_id === userID && "max_budget" in member.litellm_budget_table && member.litellm_budget_table.max_budget !== null) {
|
||||
setMaxBudget(member.litellm_budget_table.max_budget);
|
||||
setMaxBudgetFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!setMaxBudgetFlag) {
|
||||
setMaxBudget(selectedTeam.max_budget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [selectedTeam, userMaxBudget]);
|
||||
|
|
|
@ -73,6 +73,11 @@ const ViewUserTeam: React.FC<ViewUserTeamProps> = ({ userID, userRole, selectedT
|
|||
<>
|
||||
<div className="mb-5">
|
||||
<p className="text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold">{selectedTeam?.team_alias}</p>
|
||||
{
|
||||
selectedTeam?.team_id && (
|
||||
<p className="text-xs text-gray-400 dark:text-gray-400 font-semibold">Team ID: {selectedTeam?.team_id}</p>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue