mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
feat(ui): require embedding model when adding a semantic router
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
6a213de9f4
commit
843e25b4b1
2 changed files with 25 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ vi.mock("../networking", () => ({
|
|||
}));
|
||||
|
||||
vi.mock("@/components/llm_calls/fetch_models", () => ({
|
||||
fetchAvailableModels: vi.fn().mockResolvedValue([]),
|
||||
fetchAvailableModels: vi.fn().mockResolvedValue([{ model_group: "gpt-4o", mode: "chat" }]),
|
||||
}));
|
||||
|
||||
vi.mock("./handle_add_auto_router_submit", () => ({
|
||||
|
|
@ -37,4 +37,20 @@ describe("AddAutoRouterTab", () => {
|
|||
expect(screen.getAllByText("This tier is required")).toHaveLength(4);
|
||||
expect(NotificationManager.fromBackend).toHaveBeenCalledWith("Please enter an Auto Router Name");
|
||||
});
|
||||
|
||||
it("blocks the semantic router submit until an embedding model is selected", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithProviders(<Harness />);
|
||||
|
||||
await user.click(screen.getByRole("radio", { name: /semantic router/i }));
|
||||
await user.type(screen.getByPlaceholderText(/smart_router/i), "sem_router");
|
||||
|
||||
const defaultModelSelect = await screen.findByRole("combobox", { name: /default model/i });
|
||||
await user.click(defaultModelSelect);
|
||||
await user.click(await screen.findByTitle("gpt-4o"));
|
||||
|
||||
await user.click(screen.getByRole("button", { name: /add auto router/i }));
|
||||
|
||||
expect(NotificationManager.fromBackend).toHaveBeenCalledWith("Please select an Embedding Model");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -157,6 +157,11 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({ form, handleOk, acc
|
|||
return;
|
||||
}
|
||||
|
||||
if (!form.getFieldValue("auto_router_embedding_model")) {
|
||||
NotificationManager.fromBackend("Please select an Embedding Model");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!routerConfig || !routerConfig.routes || routerConfig.routes.length === 0) {
|
||||
NotificationManager.fromBackend("Please configure at least one route for the auto router");
|
||||
return;
|
||||
|
|
@ -346,18 +351,18 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({ form, handleOk, acc
|
|||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
rules={[{ required: true, message: "Embedding model is required" }]}
|
||||
label="Embedding Model"
|
||||
name="auto_router_embedding_model"
|
||||
tooltip="Optional: embedding model to use for semantic routing decisions"
|
||||
tooltip="Embedding model to use for semantic routing decisions"
|
||||
labelCol={{ span: 10 }}
|
||||
labelAlign="left"
|
||||
>
|
||||
<AntdSelect
|
||||
placeholder="Select an embedding model (optional)"
|
||||
placeholder="Select an embedding model"
|
||||
options={modelGroupOptions}
|
||||
style={{ width: "100%" }}
|
||||
showSearch
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue