mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
(feat) test slack alerts
This commit is contained in:
parent
cbd0851257
commit
768c3d8491
2 changed files with 51 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ import {
|
|||
Select,
|
||||
message,
|
||||
} from "antd";
|
||||
import { keyCreateCall } from "./networking";
|
||||
import { keyCreateCall, slackBudgetAlertsHealthCheck } from "./networking";
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
|
|
@ -68,6 +68,20 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
const sendSlackAlert = async () => {
|
||||
try {
|
||||
console.log("Sending Slack alert...");
|
||||
message.info("Sending Test Slack alert...");
|
||||
const response = await slackBudgetAlertsHealthCheck(accessToken);
|
||||
console.log("slackBudgetAlertsHealthCheck Response:", response);
|
||||
message.success("Test Slack Alert worked - check your Slack!");
|
||||
console.log("Testing Slack alert successful");
|
||||
} catch (error) {
|
||||
console.error("Error sending Slack alert:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button className="mx-auto" onClick={() => setIsModalVisible(true)}>
|
||||
|
|
@ -183,7 +197,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
<Text>API Key: {apiKey}</Text>
|
||||
<Title className="mt-6">Budgets</Title>
|
||||
<Text>Soft Limit Budget: ${softBudget}</Text>
|
||||
<Button className="mt-3">
|
||||
<Button className="mt-3" onClick={sendSlackAlert}>
|
||||
Test Alert
|
||||
</Button>
|
||||
|
||||
|
|
|
|||
|
|
@ -810,3 +810,38 @@ export const PredictedSpendLogsCall = async (
|
|||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const slackBudgetAlertsHealthCheck = async (accessToken: String) => {
|
||||
try {
|
||||
let url = proxyBaseUrl
|
||||
? `${proxyBaseUrl}/health/services?service=slack_budget_alerts`
|
||||
: `health/services?service=slack_budget_alerts`;
|
||||
|
||||
console.log("Checking Slack Budget Alerts service health");
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
console.error("Health Check failed:", errorData);
|
||||
throw new Error("Health Check failed");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log("Service Health Response:", data);
|
||||
|
||||
// You can add additional logic here based on the response if needed
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Failed to perform health check:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue