mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
add router settings to request settings + add router accordion to key_edit_view
This commit is contained in:
parent
09cd7e383e
commit
c66baab6e1
3 changed files with 33 additions and 1 deletions
|
|
@ -368,6 +368,7 @@ async def route_request( # noqa: PLR0915 - Complex routing function, refactorin
|
|||
"num_retries",
|
||||
"timeout",
|
||||
"model_group_retry_policy",
|
||||
"routing_strategy",
|
||||
]
|
||||
|
||||
# Merge override settings into data (only if not already set in request)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ export interface KeyResponse {
|
|||
};
|
||||
access_group_ids?: string[];
|
||||
budget_limits?: Array<{ budget_duration: string; max_budget: number; reset_at?: string }>;
|
||||
router_settings?: Record<string, any>;
|
||||
auto_rotate?: boolean;
|
||||
rotation_interval?: string;
|
||||
last_rotation_at?: string;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { useProjects } from "@/app/(dashboard)/hooks/projects/useProjects";
|
|||
import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings";
|
||||
import PolicySelector from "@/components/policies/PolicySelector";
|
||||
import { InfoCircleOutlined } from "@ant-design/icons";
|
||||
import { TextInput, Button as TremorButton } from "@tremor/react";
|
||||
import { TextInput, Button as TremorButton, Accordion, AccordionHeader, AccordionBody } from "@tremor/react";
|
||||
import { Form, Input, Select, Switch, Tooltip } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import { rolesWithWriteAccess } from "../../utils/roles";
|
||||
|
|
@ -15,6 +15,7 @@ import KeyLifecycleSettings from "../common_components/KeyLifecycleSettings";
|
|||
import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
|
||||
import RateLimitTypeFormItem from "../common_components/RateLimitTypeFormItem";
|
||||
import OrganizationDropdown from "../common_components/OrganizationDropdown";
|
||||
import RouterSettingsAccordion, { RouterSettingsAccordionValue } from "../common_components/RouterSettingsAccordion";
|
||||
import { extractLoggingSettings, formatMetadataForDisplay, stripTagsFromMetadata } from "../key_info_utils";
|
||||
import { BudgetWindowEntry, BudgetWindowsEditor } from "../key_team_helpers/BudgetWindowsEditor";
|
||||
import { KeyResponse } from "../key_team_helpers/key_list";
|
||||
|
|
@ -108,6 +109,9 @@ export function KeyEditView({
|
|||
const [budgetLimits, setBudgetLimits] = useState<BudgetWindowEntry[]>(
|
||||
Array.isArray(keyData.budget_limits) ? keyData.budget_limits : []
|
||||
);
|
||||
const [routerSettings, setRouterSettings] = useState<RouterSettingsAccordionValue | null>(
|
||||
keyData.router_settings ? { router_settings: keyData.router_settings } : null
|
||||
);
|
||||
const { data: organizations, isLoading: isOrganizationsLoading } = useOrganizations();
|
||||
const { data: projects } = useProjects();
|
||||
const { data: uiSettingsData } = useUISettings();
|
||||
|
|
@ -283,6 +287,16 @@ export function KeyEditView({
|
|||
const validWindows = budgetLimits.filter((w) => w.budget_duration && w.max_budget !== null && w.max_budget !== undefined);
|
||||
values.budget_limits = validWindows.length > 0 ? validWindows : undefined;
|
||||
|
||||
// Add router_settings if any are defined
|
||||
if (routerSettings?.router_settings) {
|
||||
const hasValues = Object.values(routerSettings.router_settings).some(
|
||||
(value) => value !== null && value !== undefined && value !== "",
|
||||
);
|
||||
if (hasValues) {
|
||||
values.router_settings = routerSettings.router_settings;
|
||||
}
|
||||
}
|
||||
|
||||
await onSubmit(values);
|
||||
} finally {
|
||||
setIsKeySaving(false);
|
||||
|
|
@ -448,6 +462,22 @@ export function KeyEditView({
|
|||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Accordion className="mb-4">
|
||||
<AccordionHeader>
|
||||
<b>Router Settings</b>
|
||||
</AccordionHeader>
|
||||
<AccordionBody>
|
||||
<div className="mt-4 w-full">
|
||||
<RouterSettingsAccordion
|
||||
accessToken={accessToken || ""}
|
||||
value={routerSettings || undefined}
|
||||
onChange={setRouterSettings}
|
||||
modelData={undefined}
|
||||
/>
|
||||
</div>
|
||||
</AccordionBody>
|
||||
</Accordion>
|
||||
|
||||
<Form.Item label="TPM Limit" name="tpm_limit">
|
||||
<NumericalInput min={0} />
|
||||
</Form.Item>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue