From f34371375fd01a7e118df4c5680e8dc06c03b469 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 13 Jan 2026 20:37:20 -0800 Subject: [PATCH] Anthrpoic QOL --- .../conditional_public_model_name.test.tsx | 28 +++++++++++++++++++ .../conditional_public_model_name.tsx | 25 ++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.test.tsx diff --git a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.test.tsx b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.test.tsx new file mode 100644 index 0000000000..81633bd7a8 --- /dev/null +++ b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.test.tsx @@ -0,0 +1,28 @@ +import { render, screen } from "@testing-library/react"; +import { Form } from "antd"; +import { describe, expect, it } from "vitest"; +import ConditionalPublicModelName from "./conditional_public_model_name"; + +describe("ConditionalPublicModelName", () => { + it("should render", () => { + render( +
+ + , + ); + + expect(screen.getByText("Model Mappings")).toBeInTheDocument(); + expect(screen.getByText("Public Model Name")).toBeInTheDocument(); + expect(screen.getByText("LiteLLM Model Name")).toBeInTheDocument(); + }); +}); diff --git a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx index b21a91dbe3..0a77c25213 100644 --- a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx +++ b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx @@ -129,8 +129,31 @@ const ConditionalPublicModelName: React.FC = () => { { + const newValue = e.target.value; const newMappings = [...form.getFieldValue("model_mappings")]; - newMappings[index].public_name = e.target.value; + + // Check conditions for Anthropic -1m suffix handling + const isAnthropic = selectedProvider === Providers.Anthropic; + const endsWith1m = newValue.endsWith("-1m"); + const litellmParams = form.getFieldValue("litellm_extra_params"); + const isLitellmParamsEmpty = !litellmParams || litellmParams.trim() === ""; + + let finalPublicName = newValue; + + if (isAnthropic && endsWith1m && isLitellmParamsEmpty) { + // Set litellm params with extra_headers + const litellmParamsValue = JSON.stringify( + { extra_headers: { "anthropic-beta": "context-1m-2025-08-07" } }, + null, + 2, + ); + form.setFieldValue("litellm_extra_params", litellmParamsValue); + + // Remove -1m suffix from public_name + finalPublicName = newValue.slice(0, -3); // Remove "-1m" (3 characters) + } + + newMappings[index].public_name = finalPublicName; form.setFieldValue("model_mappings", newMappings); }} />