mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
fix adminGlobalActivityExceptions
This commit is contained in:
parent
4fe8da7cd3
commit
14a5df71d1
2 changed files with 107 additions and 0 deletions
|
@ -49,6 +49,8 @@ import {
|
||||||
getCallbacksCall,
|
getCallbacksCall,
|
||||||
setCallbacksCall,
|
setCallbacksCall,
|
||||||
modelSettingsCall,
|
modelSettingsCall,
|
||||||
|
adminGlobalActivityExceptions,
|
||||||
|
adminGlobalActivityExceptionsPerDeployment,
|
||||||
} from "./networking";
|
} from "./networking";
|
||||||
import { BarChart, AreaChart } from "@tremor/react";
|
import { BarChart, AreaChart } from "@tremor/react";
|
||||||
import {
|
import {
|
||||||
|
@ -109,6 +111,13 @@ interface RetryPolicyObject {
|
||||||
[key: string]: { [retryPolicyKey: string]: number } | undefined;
|
[key: string]: { [retryPolicyKey: string]: number } | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface GlobalExceptionActivityData {
|
||||||
|
sum_num_exceptions: number;
|
||||||
|
daily_data: { date: string; num_exceptions: number; }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//["OpenAI", "Azure OpenAI", "Anthropic", "Gemini (Google AI Studio)", "Amazon Bedrock", "OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"]
|
//["OpenAI", "Azure OpenAI", "Anthropic", "Gemini (Google AI Studio)", "Amazon Bedrock", "OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"]
|
||||||
|
|
||||||
interface ProviderFields {
|
interface ProviderFields {
|
||||||
|
@ -301,6 +310,8 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
|
||||||
useState<RetryPolicyObject | null>(null);
|
useState<RetryPolicyObject | null>(null);
|
||||||
const [defaultRetry, setDefaultRetry] = useState<number>(0);
|
const [defaultRetry, setDefaultRetry] = useState<number>(0);
|
||||||
|
|
||||||
|
const [globalExceptionData, setGlobalExceptionData] = useState<GlobalExceptionActivityData[]>([]);
|
||||||
|
|
||||||
function formatCreatedAt(createdAt: string | null) {
|
function formatCreatedAt(createdAt: string | null) {
|
||||||
if (createdAt) {
|
if (createdAt) {
|
||||||
const date = new Date(createdAt);
|
const date = new Date(createdAt);
|
||||||
|
@ -643,6 +654,13 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
|
||||||
dateValue.to?.toISOString()
|
dateValue.to?.toISOString()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const dailExceptions = await adminGlobalActivityExceptions(
|
||||||
|
accessToken,
|
||||||
|
dateValue.from?.toISOString(),
|
||||||
|
dateValue.to?.toISOString()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
console.log("slowResponses:", slowResponses);
|
console.log("slowResponses:", slowResponses);
|
||||||
|
|
||||||
setSlowResponsesData(slowResponses);
|
setSlowResponsesData(slowResponses);
|
||||||
|
|
|
@ -1195,6 +1195,95 @@ export const adminGlobalActivityPerModel = async (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const adminGlobalActivityExceptions = async (
|
||||||
|
accessToken: String,
|
||||||
|
startTime: String | undefined,
|
||||||
|
endTime: String | undefined,
|
||||||
|
modelGroup: String,
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
let url = proxyBaseUrl
|
||||||
|
? `${proxyBaseUrl}/global/activity/exceptions`
|
||||||
|
: `/global/activity/exceptions`;
|
||||||
|
|
||||||
|
if (startTime && endTime) {
|
||||||
|
url += `?start_date=${startTime}&end_date=${endTime}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelGroup) {
|
||||||
|
url += `&model_group=${modelGroup}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestOptions: {
|
||||||
|
method: string;
|
||||||
|
headers: {
|
||||||
|
Authorization: string;
|
||||||
|
};
|
||||||
|
} = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(url, requestOptions);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.text();
|
||||||
|
throw new Error("Network response was not ok");
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
console.log(data);
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch spend data:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const adminGlobalActivityExceptionsPerDeployment = async (
|
||||||
|
accessToken: String,
|
||||||
|
startTime: String | undefined,
|
||||||
|
endTime: String | undefined
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
let url = proxyBaseUrl
|
||||||
|
? `${proxyBaseUrl}/global/activity/exceptions/deployment`
|
||||||
|
: `/global/activity/exceptions/deployment`;
|
||||||
|
|
||||||
|
if (startTime && endTime) {
|
||||||
|
url += `?start_date=${startTime}&end_date=${endTime}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestOptions: {
|
||||||
|
method: string;
|
||||||
|
headers: {
|
||||||
|
Authorization: string;
|
||||||
|
};
|
||||||
|
} = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(url, requestOptions);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.text();
|
||||||
|
throw new Error("Network response was not ok");
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
console.log(data);
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch spend data:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const adminTopModelsCall = async (accessToken: String) => {
|
export const adminTopModelsCall = async (accessToken: String) => {
|
||||||
try {
|
try {
|
||||||
let url = proxyBaseUrl
|
let url = proxyBaseUrl
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue