LiteLLM Minor Fixes & Improvements (09/19/2024) (#5793)

* fix(model_prices_and_context_window.json): add cost tracking for more vertex llama3.1 model

8b and 70b models

* fix(proxy/utils.py): handle data being none on pre-call hooks

* fix(proxy/): create views on initial proxy startup

fixes base case, where user starts proxy for first time

 Fixes https://github.com/BerriAI/litellm/issues/5756

* build(config.yml): fix vertex version for test

* feat(ui/): support enabling/disabling slack alerting

Allows admin to turn on/off slack alerting through ui

* feat(rerank/main.py): support langfuse logging

* fix(proxy/utils.py): fix linting errors

* fix(langfuse.py): log clean metadata

* test(tests): replace deprecated openai model
This commit is contained in:
Krish Dholakia 2024-09-20 08:19:52 -07:00 committed by GitHub
parent 696fc387d2
commit 3933fba41f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 645 additions and 94 deletions

View file

@ -41,7 +41,6 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
alertingSettingsItem[]
>([]);
console.log("INSIDE ALERTING SETTINGS");
useEffect(() => {
// get values
if (!accessToken) {
@ -59,6 +58,8 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
? { ...setting, field_value: newValue }
: setting
);
console.log(`updatedSettings: ${JSON.stringify(updatedSettings)}`)
setAlertingSettings(updatedSettings);
};
@ -67,6 +68,7 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
return;
}
console.log(`formValues: ${formValues}`)
let fieldValue = formValues;
if (fieldValue == null || fieldValue == undefined) {
@ -74,14 +76,25 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
}
const initialFormValues: Record<string, any> = {};
alertingSettings.forEach((setting) => {
initialFormValues[setting.field_name] = setting.field_value;
});
// Merge initialFormValues with actual formValues
const mergedFormValues = { ...formValues, ...initialFormValues };
console.log(`mergedFormValues: ${JSON.stringify(mergedFormValues)}`)
const { slack_alerting, ...alertingArgs } = mergedFormValues;
console.log(`slack_alerting: ${slack_alerting}, alertingArgs: ${JSON.stringify(alertingArgs)}`)
try {
updateConfigFieldSetting(accessToken, "alerting_args", mergedFormValues);
updateConfigFieldSetting(accessToken, "alerting_args", alertingArgs);
if (typeof slack_alerting === "boolean") {
if (slack_alerting == true) {
updateConfigFieldSetting(accessToken, "alerting", ["slack"]);
} else {
updateConfigFieldSetting(accessToken, "alerting", []);
}
}
// update value in state
message.success("Wait 10s for proxy to update.");
} catch (error) {
@ -107,7 +120,6 @@ const AlertingSettings: React.FC<AlertingSettingsProps> = ({
}
: setting
);
console.log("INSIDE HANDLE RESET FIELD");
setAlertingSettings(updatedSettings);
} catch (error) {
// do something

View file

@ -1,7 +1,7 @@
import React from "react";
import { Form, Input, InputNumber, Row, Col, Button as Button2 } from "antd";
import { TrashIcon, CheckCircleIcon } from "@heroicons/react/outline";
import { Button, Badge, Icon, Text, TableRow, TableCell } from "@tremor/react";
import { Button, Badge, Icon, Text, TableRow, TableCell, Switch } from "@tremor/react";
import Paragraph from "antd/es/typography/Paragraph";
interface AlertingSetting {
field_name: string;
@ -30,10 +30,15 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
const [form] = Form.useForm();
const onFinish = () => {
console.log(`INSIDE ONFINISH`)
const formData = form.getFieldsValue();
const isEmpty = Object.values(formData).some(
(value) => value === "" || value === null || value === undefined
);
const isEmpty = Object.entries(formData).every(([key, value]) => {
if (typeof value === 'boolean') {
return false; // Boolean values are never considered empty
}
return value === '' || value === null || value === undefined;
});
console.log(`formData: ${JSON.stringify(formData)}, isEmpty: ${isEmpty}`)
if (!isEmpty) {
handleSubmit(formData);
} else {
@ -68,6 +73,11 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
value={value.field_value}
onChange={(e) => handleInputChange(value.field_name, e)}
/>
) : value.field_type === "Boolean" ? (
<Switch
checked={value.field_value}
onChange={(checked) => handleInputChange(value.field_name, checked)}
/>
) : (
<Input
value={value.field_value}
@ -86,7 +96,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
</TableCell>
)
) : (
<Form.Item name={value.field_name} className="mb-0">
<Form.Item name={value.field_name} className="mb-0" valuePropName={value.field_type === "Boolean" ? "checked" : "value"}>
<TableCell>
{value.field_type === "Integer" ? (
<InputNumber
@ -95,7 +105,17 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
onChange={(e) => handleInputChange(value.field_name, e)}
className="p-0"
/>
) : (
) : value.field_type === "Boolean" ? (
<Switch
checked={value.field_value}
onChange={(checked) => {
handleInputChange(value.field_name, checked);
form.setFieldsValue({ [value.field_name]: checked });
}}
/>
) :(
<Input
value={value.field_value}
onChange={(e) => handleInputChange(value.field_name, e)}