mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(ui): offer no models when an org team's ceiling never arrives
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
2d3b63fb5a
commit
df87a49f8b
2 changed files with 38 additions and 22 deletions
|
|
@ -517,27 +517,35 @@ describe("ModelSelect", () => {
|
|||
expectOffered("All Proxy Models");
|
||||
});
|
||||
|
||||
it("should keep hiding All Proxy Models when neither the team nor the org reports a ceiling", async () => {
|
||||
const user = userEvent.setup();
|
||||
mockUseOrganization.mockReturnValue({ data: undefined, isLoading: false } as any);
|
||||
mockUseTeam.mockReturnValue({
|
||||
data: { team_id: "team-1", organization_models: null },
|
||||
isLoading: false,
|
||||
} as any);
|
||||
it("should offer no models for an org team when neither the team nor the org reports a ceiling", async () => {
|
||||
const testCases = [
|
||||
{ name: "/team/info withheld the ceiling", team: { team_id: "team-1", organization_models: null } },
|
||||
{ name: "/team/info failed after the list seeded the team", team: { team_id: "team-1", models: [] } },
|
||||
];
|
||||
|
||||
renderWithProviders(
|
||||
<ModelSelect
|
||||
onChange={mockOnChange}
|
||||
context="team"
|
||||
teamID="team-1"
|
||||
organizationID="org-1"
|
||||
options={{ includeSpecialOptions: true }}
|
||||
/>,
|
||||
);
|
||||
for (const testCase of testCases) {
|
||||
const user = userEvent.setup();
|
||||
mockUseOrganization.mockReturnValue({ data: undefined, isLoading: false } as any);
|
||||
mockUseTeam.mockReturnValue({ data: testCase.team, isLoading: false, isFetching: false } as any);
|
||||
|
||||
await openModelList(user);
|
||||
expectNotOffered("All Proxy Models");
|
||||
expectOffered("No Default Models");
|
||||
const { unmount } = renderWithProviders(
|
||||
<ModelSelect
|
||||
onChange={mockOnChange}
|
||||
context="team"
|
||||
teamID="team-1"
|
||||
organizationID="org-1"
|
||||
options={{ includeSpecialOptions: true }}
|
||||
/>,
|
||||
);
|
||||
|
||||
await openModelList(user);
|
||||
expectNotOffered("All Proxy Models");
|
||||
expectOffered("No Default Models");
|
||||
expectNotOffered("gpt-4");
|
||||
expectNotOffered("claude-3");
|
||||
|
||||
unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it("should use custom dataTestId when provided", async () => {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ type ModelOptionGroup = {
|
|||
|
||||
type FilterContextArgs = {
|
||||
allProxyModels: string[];
|
||||
organizationID?: string;
|
||||
organizationModels?: string[];
|
||||
userModels?: string[];
|
||||
options?: ModelSelectProps["options"];
|
||||
|
|
@ -88,8 +89,9 @@ const contextFilters: Record<ModelSelectProps["context"], (args: FilterContextAr
|
|||
return [];
|
||||
},
|
||||
|
||||
team: ({ allProxyModels, organizationModels }) => {
|
||||
if (!organizationModels || isUncappedModelCeiling(organizationModels)) return allProxyModels;
|
||||
team: ({ allProxyModels, organizationID, organizationModels }) => {
|
||||
if (organizationModels === undefined) return organizationID ? [] : allProxyModels;
|
||||
if (isUncappedModelCeiling(organizationModels)) return allProxyModels;
|
||||
return allProxyModels.filter((model) => organizationModels.includes(model));
|
||||
},
|
||||
|
||||
|
|
@ -115,7 +117,13 @@ const filterModels = (
|
|||
const filterFn = contextFilters[ctx.context];
|
||||
if (!filterFn) return [];
|
||||
|
||||
return filterFn({ allProxyModels: deduplicatedProxyModels, ...extra, options: ctx.options });
|
||||
const filterArgs: FilterContextArgs = {
|
||||
allProxyModels: deduplicatedProxyModels,
|
||||
organizationID: ctx.organizationID,
|
||||
...extra,
|
||||
options: ctx.options,
|
||||
};
|
||||
return filterFn(filterArgs);
|
||||
};
|
||||
|
||||
export const ModelSelect = (props: ModelSelectProps) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue