mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(ci): satisfy ruff format, prettier, and eslint max-lines gates
- ruff format on auto_router_compression.py (a long comprehension wrapped across three lines instead of one) - prettier on buildAutoRouterCompression.ts and the two test files it touched - ComplexityRouterConfig.tsx crossed the 800-line eslint max-lines ceiling once the compression accordion entry landed. Extracted TierRowSelect into its own file (already self-contained, used only within this file and PlanModeOverrideControls) and simplified CompressionControls' props to a single state/onChange pair instead of six individual callbacks, moving the per-field derivation into the component that already owns this state shape
This commit is contained in:
parent
d0a8006737
commit
e273cf301f
6 changed files with 47 additions and 60 deletions
|
|
@ -93,9 +93,7 @@ def policy_for_model(
|
|||
)
|
||||
requested: Final = frozenset(request_tags)
|
||||
tag_matched: Final = tuple(
|
||||
params
|
||||
for params in markers
|
||||
if (tags := params.get("tags")) and requested.issuperset(frozenset(tags))
|
||||
params for params in markers if (tags := params.get("tags")) and requested.issuperset(frozenset(tags))
|
||||
)
|
||||
for params in (*tag_matched, *markers):
|
||||
policy = policy_from_litellm_params(params)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { SimpleTooltip } from "@/components/ui/tooltip";
|
||||
import { MultiSelect } from "@/components/shared/MultiSelect";
|
||||
import { SearchSelect } from "@/components/shared/SearchSelect";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { ChevronRight, Info, Plus, Trash2, X } from "lucide-react";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
|
||||
import { AffinityControls } from "./AffinityControls";
|
||||
import TierRowSelect from "./TierRowSelect";
|
||||
import { ModalityRoutingControls } from "./ModalityRoutingControls";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
|
|
@ -370,27 +370,6 @@ const TierRowEditFields: React.FC<{
|
|||
</>
|
||||
);
|
||||
|
||||
const TierRowSelect: React.FC<{
|
||||
label: string;
|
||||
options: { value: string; label: string }[];
|
||||
value: string | null;
|
||||
onValueChange: (rowId: string) => void;
|
||||
placeholder?: string;
|
||||
}> = ({ label, options, value, onValueChange, placeholder }) => (
|
||||
<Select items={options} value={value} onValueChange={(rowId: string | null) => rowId && onValueChange(rowId)}>
|
||||
<SelectTrigger aria-label={label} className="w-full">
|
||||
<SelectValue placeholder={placeholder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
|
||||
export type AdaptiveEligible = "all" | "classified_tier";
|
||||
|
||||
export type ComplexityTierLabels = Partial<Record<keyof ComplexityTiers, string>>;
|
||||
|
|
@ -889,22 +868,7 @@ const ComplexityRouterConfig: React.FC<ComplexityRouterConfigProps> = ({
|
|||
key: "compression",
|
||||
label: <strong className="text-foreground font-semibold">Advanced: Compression</strong>,
|
||||
children: (
|
||||
<CompressionControls
|
||||
routing={autoRouterCompression.routing}
|
||||
onRoutingChange={(routing) =>
|
||||
onAutoRouterCompressionChange({
|
||||
...autoRouterCompression,
|
||||
routing,
|
||||
sameAsRouting: routing === undefined ? true : autoRouterCompression.sameAsRouting,
|
||||
})
|
||||
}
|
||||
sameAsRouting={autoRouterCompression.sameAsRouting}
|
||||
onSameAsRoutingChange={(sameAsRouting) =>
|
||||
onAutoRouterCompressionChange({ ...autoRouterCompression, sameAsRouting })
|
||||
}
|
||||
model={autoRouterCompression.model}
|
||||
onModelChange={(model) => onAutoRouterCompressionChange({ ...autoRouterCompression, model })}
|
||||
/>
|
||||
<CompressionControls value={autoRouterCompression} onChange={onAutoRouterCompressionChange} />
|
||||
),
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,27 +5,26 @@ import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
|||
import { Info } from "lucide-react";
|
||||
import React from "react";
|
||||
import { useGuardrails } from "@/app/(dashboard)/hooks/guardrails/useGuardrails";
|
||||
import { isCompressionGuardrailProvider, NO_COMPRESSION } from "./buildAutoRouterCompression";
|
||||
import {
|
||||
AutoRouterCompressionState,
|
||||
isCompressionGuardrailProvider,
|
||||
NO_COMPRESSION,
|
||||
} from "./buildAutoRouterCompression";
|
||||
|
||||
interface CompressionControlsProps {
|
||||
routing: string | undefined;
|
||||
onRoutingChange: (value: string | undefined) => void;
|
||||
sameAsRouting: boolean;
|
||||
onSameAsRoutingChange: (same: boolean) => void;
|
||||
model: string | undefined;
|
||||
onModelChange: (value: string | undefined) => void;
|
||||
value: AutoRouterCompressionState;
|
||||
onChange: (state: AutoRouterCompressionState) => void;
|
||||
}
|
||||
|
||||
const NONE_OPTION: SearchSelectOption = { label: "None (no compression)", value: NO_COMPRESSION };
|
||||
|
||||
const CompressionControls: React.FC<CompressionControlsProps> = ({
|
||||
routing,
|
||||
onRoutingChange,
|
||||
sameAsRouting,
|
||||
onSameAsRoutingChange,
|
||||
model,
|
||||
onModelChange,
|
||||
}) => {
|
||||
const CompressionControls: React.FC<CompressionControlsProps> = ({ value, onChange }) => {
|
||||
const { routing, sameAsRouting, model } = value;
|
||||
const onRoutingChange = (newRouting: string | undefined) =>
|
||||
onChange({ ...value, routing: newRouting, sameAsRouting: newRouting === undefined ? true : sameAsRouting });
|
||||
const onSameAsRoutingChange = (newSameAsRouting: boolean) => onChange({ ...value, sameAsRouting: newSameAsRouting });
|
||||
const onModelChange = (newModel: string | undefined) => onChange({ ...value, model: newModel });
|
||||
|
||||
const { data } = useGuardrails();
|
||||
const compressionOptions: SearchSelectOption[] = (data?.guardrails ?? [])
|
||||
.filter((g) => isCompressionGuardrailProvider(g.litellm_params?.guardrail))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import React from "react";
|
||||
|
||||
const TierRowSelect: React.FC<{
|
||||
label: string;
|
||||
options: { value: string; label: string }[];
|
||||
value: string | null;
|
||||
onValueChange: (rowId: string) => void;
|
||||
placeholder?: string;
|
||||
}> = ({ label, options, value, onValueChange, placeholder }) => (
|
||||
<Select items={options} value={value} onValueChange={(rowId: string | null) => rowId && onValueChange(rowId)}>
|
||||
<SelectTrigger aria-label={label} className="w-full">
|
||||
<SelectValue placeholder={placeholder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
|
||||
export default TierRowSelect;
|
||||
|
|
@ -42,7 +42,7 @@ export const buildAutoRouterCompressionParams = (
|
|||
if (state.routing === undefined) return {};
|
||||
return {
|
||||
auto_router_routing_compression: state.routing,
|
||||
auto_router_model_compression: state.sameAsRouting ? state.routing : (state.model ?? NO_COMPRESSION),
|
||||
auto_router_model_compression: state.sameAsRouting ? state.routing : state.model ?? NO_COMPRESSION,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1040,9 +1040,10 @@ describe("EditAutoRouterModal prompt compression", () => {
|
|||
return payload?.litellm_params;
|
||||
};
|
||||
|
||||
const renderWithStoredCompression = (
|
||||
compression?: { auto_router_routing_compression?: string; auto_router_model_compression?: string },
|
||||
) =>
|
||||
const renderWithStoredCompression = (compression?: {
|
||||
auto_router_routing_compression?: string;
|
||||
auto_router_model_compression?: string;
|
||||
}) =>
|
||||
renderWithProviders(
|
||||
<EditAutoRouterModal
|
||||
isVisible
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue