mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix(ui): key prompt table rows by environment and dedupe key prompt options
This commit is contained in:
parent
9cc0f0220a
commit
6f94554713
4 changed files with 21 additions and 3 deletions
|
|
@ -74,7 +74,9 @@ const PromptTable: React.FC<PromptTableProps> = ({
|
|||
<DataTable
|
||||
data={promptsList}
|
||||
columns={columns}
|
||||
getRowId={(prompt, index) => prompt.prompt_id || String(index)}
|
||||
getRowId={(prompt, index) =>
|
||||
prompt.prompt_id ? `${prompt.prompt_id}::${prompt.environment || "development"}` : String(index)
|
||||
}
|
||||
sortingMode="client"
|
||||
sorting={sorting}
|
||||
onSortingChange={setSorting}
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
|
|||
const fetchPrompts = async () => {
|
||||
try {
|
||||
const response = await getPromptsList(accessToken);
|
||||
setPromptsList(response.prompts.map((prompt) => prompt.prompt_id));
|
||||
setPromptsList(Array.from(new Set(response.prompts.map((prompt) => prompt.prompt_id))));
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch prompts:", error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -425,6 +425,22 @@ describe("KeyEditView", () => {
|
|||
expect(screen.getByText("Policies")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("lists a prompt existing in several environments once in the dropdown", async () => {
|
||||
vi.mocked(getPromptsList).mockResolvedValueOnce({
|
||||
prompts: [
|
||||
{ prompt_id: "envgreet", litellm_params: {}, prompt_info: { prompt_type: "db" }, environment: "development" },
|
||||
{ prompt_id: "envgreet", litellm_params: {}, prompt_info: { prompt_type: "db" }, environment: "production" },
|
||||
],
|
||||
});
|
||||
|
||||
renderAs("Admin");
|
||||
|
||||
const prompts = await screen.findByLabelText(/Prompts/);
|
||||
await userEvent.type(prompts, "envgreet");
|
||||
|
||||
expect(await screen.findAllByRole("option", { name: "envgreet" })).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("should omit both fields and fire neither admin-only request for an internal user", async () => {
|
||||
renderAs("Internal User");
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ export function KeyEditView({
|
|||
if (!accessToken) return;
|
||||
try {
|
||||
const response = await getPromptsList(accessToken);
|
||||
setPromptsList(response.prompts.map((prompt) => prompt.prompt_id));
|
||||
setPromptsList(Array.from(new Set(response.prompts.map((prompt) => prompt.prompt_id))));
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch prompts:", error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue