mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
style(ui): format complexity router files
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
f70683ae92
commit
4117d9f786
8 changed files with 37 additions and 36 deletions
|
|
@ -130,7 +130,9 @@ const ComplexityRouterAdvancedSections: React.FC<ComplexityRouterAdvancedSection
|
|||
{
|
||||
key: "plan-mode",
|
||||
label: <strong className="text-foreground font-semibold">Advanced: Plan-Mode Override</strong>,
|
||||
children: <PlanModeOverrideControls value={value} onChange={onChange} planModeTierOptions={planModeTierOptions} />,
|
||||
children: (
|
||||
<PlanModeOverrideControls value={value} onChange={onChange} planModeTierOptions={planModeTierOptions} />
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "housekeeping",
|
||||
|
|
@ -195,9 +197,7 @@ const ComplexityRouterAdvancedSections: React.FC<ComplexityRouterAdvancedSection
|
|||
rules={keywordTierRules}
|
||||
onChange={onKeywordTierRulesChange}
|
||||
tierLabels={value.tier_labels}
|
||||
tierNames={
|
||||
customTierSet || forecast ? tierRows.map(activeTierName).filter(Boolean) : undefined
|
||||
}
|
||||
tierNames={customTierSet || forecast ? tierRows.map(activeTierName).filter(Boolean) : undefined}
|
||||
/>
|
||||
)}
|
||||
{onKeywordTierRulesChange && onSemanticMatchingEnabledChange && <Separator className="my-4" />}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,6 @@ describe("ComplexityRouterConfig", () => {
|
|||
const capabilityValue = { ...defaultValue, classifier_type: "capability" as const };
|
||||
rerender(<ComplexityRouterConfig {...baseProps} value={capabilityValue} />);
|
||||
expect(screen.queryByText("Advanced: Heuristic Keyword Overrides")).not.toBeInTheDocument();
|
||||
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
|
@ -127,11 +126,7 @@ describe("ComplexityRouterConfig", () => {
|
|||
it.each([true, false])("shows reminder marker validation only when requested: %s", (showValidationErrors) => {
|
||||
const value = { ...defaultValue, reminder_markers: [{ open: "", close: "x" }] };
|
||||
renderWithProviders(
|
||||
<ComplexityRouterConfig
|
||||
{...baseProps}
|
||||
value={value}
|
||||
showValidationErrors={showValidationErrors}
|
||||
/>,
|
||||
<ComplexityRouterConfig {...baseProps} value={value} showValidationErrors={showValidationErrors} />,
|
||||
);
|
||||
fireEvent.click(screen.getByText("Advanced: Reminder Markers"));
|
||||
const validation = screen.queryByText(/needs both/i);
|
||||
|
|
@ -144,10 +139,7 @@ describe("ComplexityRouterConfig", () => {
|
|||
|
||||
it("disables housekeeping sentinels when cheapest-tier routing is off", () => {
|
||||
renderWithProviders(
|
||||
<ComplexityRouterConfig
|
||||
{...baseProps}
|
||||
value={{ ...defaultValue, route_housekeeping_to_cheapest_tier: false }}
|
||||
/>,
|
||||
<ComplexityRouterConfig {...baseProps} value={{ ...defaultValue, route_housekeeping_to_cheapest_tier: false }} />,
|
||||
);
|
||||
fireEvent.click(screen.getByText("Advanced: Housekeeping Routing"));
|
||||
const sentinelInput = screen.getByRole("combobox", { name: "e.g., conversation title" });
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ const HeuristicKeywordOverrides: React.FC<{
|
|||
}> = ({ value, onChange }) => (
|
||||
<div className="space-y-3">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Each list replaces the built-in keyword list of the same name for the heuristic scorer. Leave a list empty to
|
||||
keep the built-in one. To add technical terms without replacing the list, use custom technical keywords under
|
||||
Each list replaces the built-in keyword list of the same name for the heuristic scorer. Leave a list empty to keep
|
||||
the built-in one. To add technical terms without replacing the list, use custom technical keywords under
|
||||
Classification Method.
|
||||
</p>
|
||||
{fields.map(([key, label]) => {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ const ReminderMarkers: React.FC<{
|
|||
const update = (index: number, patch: Partial<ReminderMarkerPair>) =>
|
||||
onChange({
|
||||
...value,
|
||||
reminder_markers: markers.map((marker, markerIndex) => (markerIndex === index ? { ...marker, ...patch } : marker)),
|
||||
reminder_markers: markers.map((marker, markerIndex) =>
|
||||
markerIndex === index ? { ...marker, ...patch } : marker,
|
||||
),
|
||||
});
|
||||
const remove = (index: number) => {
|
||||
const next = markers.filter((_, markerIndex) => markerIndex !== index);
|
||||
|
|
@ -24,9 +26,9 @@ const ReminderMarkers: React.FC<{
|
|||
return (
|
||||
<div>
|
||||
<p className="mb-4 text-sm text-muted-foreground">
|
||||
Delimiter pairs that wrap harness-injected reminder blocks, which are stripped before classification. Setting any
|
||||
pair replaces the built-in pairs, so list every pair your harness emits. Matching is case-insensitive and values
|
||||
are saved lowercased.
|
||||
Delimiter pairs that wrap harness-injected reminder blocks, which are stripped before classification. Setting
|
||||
any pair replaces the built-in pairs, so list every pair your harness emits. Matching is case-insensitive and
|
||||
values are saved lowercased.
|
||||
</p>
|
||||
<div className="space-y-3">
|
||||
{markers.map((marker, index) => (
|
||||
|
|
@ -53,7 +55,12 @@ const ReminderMarkers: React.FC<{
|
|||
onChange={(event) => update(index, { close: event.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<Button variant="ghost" size="icon" aria-label={`Remove reminder marker pair ${index + 1}`} onClick={() => remove(index)}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={`Remove reminder marker pair ${index + 1}`}
|
||||
onClick={() => remove(index)}
|
||||
>
|
||||
<Trash2 />
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ const ResponseFormatControls: React.FC<{
|
|||
<strong className="font-semibold">Cap max_tokens at the tier model's output ceiling</strong>
|
||||
</div>
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
Replace the caller's max_tokens with the routed tier model's output ceiling so one client value fits every
|
||||
tier. Off forwards the caller's value unchanged.
|
||||
Replace the caller's max_tokens with the routed tier model's output ceiling so one client value fits
|
||||
every tier. Off forwards the caller's value unchanged.
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -752,9 +752,7 @@ export const buildComplexityRouterConfig = ({
|
|||
plan_mode_patterns: cleanList(planModePatterns),
|
||||
housekeeping_patterns: cleanList(housekeepingPatterns),
|
||||
};
|
||||
const cleanedLists = Object.fromEntries(
|
||||
Object.entries(cleanedListValues).filter(([, list]) => list !== undefined),
|
||||
);
|
||||
const cleanedLists = Object.fromEntries(Object.entries(cleanedListValues).filter(([, list]) => list !== undefined));
|
||||
const hasValidCustomClassifierTimeout =
|
||||
classifierType === "custom" &&
|
||||
classifierPluginTimeoutMs !== undefined &&
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import AutoRouterClassifierTabs from "../add_model/AutoRouterClassifierTabs";
|
||||
import { usesClassifierContext } from "../add_model/classifier_types";
|
||||
export type { StoredComplexityRouterConfig } from "../add_model/build_complexity_router_config";
|
||||
import {
|
||||
getForecastConfigError,
|
||||
isForecastClassifier,
|
||||
} from "../add_model/forecast_classifier_config";
|
||||
import { getForecastConfigError, isForecastClassifier } from "../add_model/forecast_classifier_config";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
complexityRouterSchema,
|
||||
|
|
@ -457,7 +454,13 @@ const EditAutoRouterModal: React.FC<EditAutoRouterModalProps> = ({
|
|||
// Dual write: complexity_router_config.default_model (the pin marker hydratePinnedDefaultModel
|
||||
// reads back) and complexity_router_default_model (what the backend routes on) must always be
|
||||
// written together from the same value. Same pairing in add_auto_router_tab.tsx.
|
||||
const keywordMatching = { keywordTierRules, escalationKeywords, semanticMatchingEnabled, embeddingModel, matchThreshold };
|
||||
const keywordMatching = {
|
||||
keywordTierRules,
|
||||
escalationKeywords,
|
||||
semanticMatchingEnabled,
|
||||
embeddingModel,
|
||||
matchThreshold,
|
||||
};
|
||||
const updatedConfig = buildUpdatedComplexityRouterConfig(
|
||||
modelData.litellm_params?.complexity_router_config,
|
||||
complexityRouterConfig,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ import {
|
|||
resolveComplexityDefaultModel,
|
||||
} from "../add_model/tier_rows";
|
||||
|
||||
const isReminderMarkerPair = (
|
||||
input: unknown,
|
||||
): input is { open: string; close: string } => {
|
||||
const isReminderMarkerPair = (input: unknown): input is { open: string; close: string } => {
|
||||
if (typeof input !== "object" || input === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -176,9 +174,12 @@ export const hydrateComplexityRouterConfig = (
|
|||
? parsedConfig.reminder_markers.filter(isReminderMarkerPair)
|
||||
: undefined,
|
||||
max_tokens_from_tier_model:
|
||||
typeof parsedConfig.max_tokens_from_tier_model === "boolean" ? parsedConfig.max_tokens_from_tier_model : undefined,
|
||||
typeof parsedConfig.max_tokens_from_tier_model === "boolean"
|
||||
? parsedConfig.max_tokens_from_tier_model
|
||||
: undefined,
|
||||
classifier_plugin_timeout_ms:
|
||||
typeof parsedConfig.classifier_plugin_timeout_ms === "number" && Number.isFinite(parsedConfig.classifier_plugin_timeout_ms)
|
||||
typeof parsedConfig.classifier_plugin_timeout_ms === "number" &&
|
||||
Number.isFinite(parsedConfig.classifier_plugin_timeout_ms)
|
||||
? parsedConfig.classifier_plugin_timeout_ms
|
||||
: undefined,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue