Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit5214_custom_tiers

This commit is contained in:
Tin Chi Lo 2026-08-05 11:54:18 -07:00
commit 6781579107
2 changed files with 25 additions and 15 deletions

View file

@ -102,6 +102,21 @@ const tierConfigSummary = (tiers: ComplexityTiers): string => {
return parts.length > 0 ? parts.join(" · ") : "No tiers configured yet";
};
// Why the submit is unavailable, or null when it is available. The button reads this to disable
// itself and to say what is missing, so the two can never give different answers. Checks the
// config actually being built, not which preset (if any) it came from: a preset only ever
// prefills once (handlePresetChange), and everything after that is edited exactly like Custom.
const getSubmitBlockedReason = (
config: ComplexityRouterConfigValue,
keywordTierRules: KeywordTierRule[],
referencedModelsParams: Parameters<typeof getReferencedModelsError>[0],
availableModelSet: Set<string>,
): string | null =>
getMissingTiersError(config.tiers) ??
getTierLabelsError(config.tier_labels) ??
getKeywordTierRulesError(keywordTierRules) ??
getReferencedModelsError(referencedModelsParams, availableModelSet);
const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
handleOk,
accessToken,
@ -222,15 +237,12 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({
embeddingModel,
};
// Why the submit is unavailable, or null when it is available. The button reads this to disable
// itself and to say what is missing, so the two can never give different answers. Checks the
// config actually being built, not which preset (if any) it came from: a preset only ever
// prefills once (handlePresetChange), and everything after that is edited exactly like Custom.
const submitBlockedReason =
getMissingTiersError(complexityRouterConfig.tiers) ??
getTierLabelsError(complexityRouterConfig.tier_labels) ??
getKeywordTierRulesError(keywordTierRules) ??
getReferencedModelsError(referencedModelsParams, availableModelSet);
const submitBlockedReason = getSubmitBlockedReason(
complexityRouterConfig,
keywordTierRules,
referencedModelsParams,
availableModelSet,
);
const complexityRouterConfigParams: BuildComplexityRouterConfigParams = {
tiers: complexityRouterConfig.tiers,

View file

@ -437,9 +437,8 @@ describe("getTierLabelsError", () => {
});
it("accepts a full distinct rename", () => {
expect(
getTierLabelsError({ SIMPLE: "Cheap", MEDIUM: "Standard", COMPLEX: "Premium", REASONING: "Deep" }),
).toBeNull();
const fullRename = { SIMPLE: "Cheap", MEDIUM: "Standard", COMPLEX: "Premium", REASONING: "Deep" };
expect(getTierLabelsError(fullRename)).toBeNull();
});
it("rejects two tiers sharing a name, which would be ambiguous in the logs", () => {
@ -473,9 +472,8 @@ describe("hydrateTierLabels", () => {
});
it("drops non-string and blank values a hand-edited config could hold", () => {
expect(hydrateTierLabels({ SIMPLE: 7, MEDIUM: " ", COMPLEX: null, REASONING: "Deep" })).toEqual({
REASONING: "Deep",
});
const handEdited = { SIMPLE: 7, MEDIUM: " ", COMPLEX: null, REASONING: "Deep" };
expect(hydrateTierLabels(handEdited)).toEqual({ REASONING: "Deep" });
});
it("ignores keys that are not tiers", () => {