Skip to content

Commit a2688c7

Browse files
authored
Merge pull request #17567 from BerriAI/litellm_ui_chat_endpoint_search
[Fix] Filtering for Chat UI Endpoint Selector
2 parents 38ae12e + 924cd62 commit a2688c7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

ui/litellm-dashboard/src/components/playground/chat_ui/EndpointSelector.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { render, waitFor } from "@testing-library/react";
2-
import { describe, it, expect } from "vitest";
1+
import { render, screen, waitFor } from "@testing-library/react";
2+
import userEvent from "@testing-library/user-event";
3+
import { describe, expect, it } from "vitest";
34
import EndpointSelector from "./EndpointSelector";
45
import { ENDPOINT_OPTIONS } from "./chatConstants";
56

@@ -12,4 +13,18 @@ describe("EndpointSelector", () => {
1213
});
1314
});
1415
});
16+
17+
it("should filter and show audio endpoints when user inputs 'audio'", async () => {
18+
const user = userEvent.setup();
19+
render(<EndpointSelector endpointType={ENDPOINT_OPTIONS[0].value} onEndpointChange={() => {}} />);
20+
21+
const combobox = screen.getByRole("combobox");
22+
await user.click(combobox);
23+
24+
const input = await screen.findByRole("combobox");
25+
await user.type(input, "audio");
26+
27+
expect(await screen.findByText("/v1/audio/speech")).toBeInTheDocument();
28+
expect(await screen.findByText("/v1/audio/transcriptions")).toBeInTheDocument();
29+
});
1530
});

ui/litellm-dashboard/src/components/playground/chat_ui/EndpointSelector.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const EndpointSelector: React.FC<EndpointSelectorProps> = ({ endpointType, onEnd
1818
onChange={onEndpointChange}
1919
options={ENDPOINT_OPTIONS}
2020
className="rounded-md"
21+
filterOption={(input, option) =>
22+
(option?.label ?? "").toLowerCase().includes(input.toLowerCase()) ||
23+
(option?.value ?? "").toLowerCase().includes(input.toLowerCase())
24+
}
2125
/>
2226
</div>
2327
);

0 commit comments

Comments
 (0)