mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-13 19:06:53 +00:00
Merge pull request #19058 from BerriAI/litellm_ui_add_model_ant
[Feature] UI - Model: Anthropic Models QOL
This commit is contained in:
@@ -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(
|
||||
<Form
|
||||
initialValues={{
|
||||
model: ["gpt-4"],
|
||||
model_mappings: [
|
||||
{
|
||||
public_name: "gpt-4",
|
||||
litellm_model: "gpt-4",
|
||||
},
|
||||
],
|
||||
}}
|
||||
>
|
||||
<ConditionalPublicModelName />
|
||||
</Form>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("Model Mappings")).toBeInTheDocument();
|
||||
expect(screen.getByText("Public Model Name")).toBeInTheDocument();
|
||||
expect(screen.getByText("LiteLLM Model Name")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -129,8 +129,31 @@ const ConditionalPublicModelName: React.FC = () => {
|
||||
<TextInput
|
||||
value={text}
|
||||
onChange={(e) => {
|
||||
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);
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user