Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(auto_router): inline error for missing LLM classifier model

Abhimanyu Kapur0e90f61e48a8
diff --git a/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.test.tsx b/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.test.tsx
index 0613b0c02ae..a34a8709918 100644
--- a/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.test.tsx
@@ -226,6 +226,28 @@ describe("ComplexityRouterConfig", () => {
expect(screen.queryByText("This tier is required")).not.toBeInTheDocument();
});
+ it("shows an inline error on the classifier model select when llm is selected without a model", () => {
+ const llmValue: ComplexityRouterConfigValue = {
+ ...defaultValue,
+ classifier_type: "llm",
+ classifier_llm_config: { model: "", timeout_ms: 3000 },
+ };
+ renderWithProviders(<ComplexityRouterConfig {...baseProps} value={llmValue} showValidationErrors={true} />);
+ fireEvent.click(screen.getByText("Advanced: Classification Method"));
+ expect(screen.getByText("A classifier model is required")).toBeInTheDocument();
+ });
+
+ it("does not show the classifier model error once a classifier model is set", () => {
+ const llmValue: ComplexityRouterConfigValue = {
+ ...defaultValue,
+ classifier_type: "llm",
+ classifier_llm_config: { model: "gpt-3.5-turbo", timeout_ms: 3000 },
+ };
+ renderWithProviders(<ComplexityRouterConfig {...baseProps} value={llmValue} showValidationErrors={true} />);
+ fireEvent.click(screen.getByText("Advanced: Classification Method"));
+ expect(screen.queryByText("A classifier model is required")).not.toBeInTheDocument();
+ });
+
it("shows a validation error only under unfilled tiers when showValidationErrors is true", () => {
renderWithProviders(
<ComplexityRouterConfig
diff --git a/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.tsx b/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.tsx
index 18c575c7c4c..50168056eaa 100644
--- a/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.tsx
@@ -95,6 +95,9 @@ const ComplexityRouterConfig: React.FC<ComplexityRouterConfigProps> = ({
label: model.model_group,
}));
+ const classifierModelMissing =
+ showValidationErrors && value.classifier_type === "llm" && !value.classifier_llm_config?.model;
+
const handleTierChange = (tier: keyof ComplexityTiers, model: string) => {
onChange({
...value,
@@ -233,7 +236,13 @@ const ComplexityRouterConfig: React.FC<ComplexityRouterConfigProps> = ({
showSearch
style={{ width: "100%" }}
options={modelOptions}
+ status={classifierModelMissing ? "error" : undefined}
/>
+ {classifierModelMissing && (
+ <Text type="danger" style={{ fontSize: 12 }}>
+ A classifier model is required
+ </Text>
+ )}
</div>
<div>
<Text strong style={{ display: "block", marginBottom: 4 }}>