fix adminGlobalActivityExceptions

This commit is contained in:
Ishaan Jaff 2024-05-30 18:08:20 -07:00
parent 4fe8da7cd3
commit 14a5df71d1
2 changed files with 107 additions and 0 deletions

View file

@ -49,6 +49,8 @@ import {
getCallbacksCall,
setCallbacksCall,
modelSettingsCall,
adminGlobalActivityExceptions,
adminGlobalActivityExceptionsPerDeployment,
} from "./networking";
import { BarChart, AreaChart } from "@tremor/react";
import {
@ -109,6 +111,13 @@ interface RetryPolicyObject {
[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.)"]
interface ProviderFields {
@ -301,6 +310,8 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
useState<RetryPolicyObject | null>(null);
const [defaultRetry, setDefaultRetry] = useState<number>(0);
const [globalExceptionData, setGlobalExceptionData] = useState<GlobalExceptionActivityData[]>([]);
function formatCreatedAt(createdAt: string | null) {
if (createdAt) {
const date = new Date(createdAt);
@ -643,6 +654,13 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({
dateValue.to?.toISOString()
);
const dailExceptions = await adminGlobalActivityExceptions(
accessToken,
dateValue.from?.toISOString(),
dateValue.to?.toISOString()
);
console.log("slowResponses:", slowResponses);
setSlowResponsesData(slowResponses);

View file

@ -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) => {
try {
let url = proxyBaseUrl