From d0dca16feeda1c331b2208a482724c155f220258 Mon Sep 17 00:00:00 2001 From: balibabu Date: Tue, 1 Apr 2025 11:53:48 +0800 Subject: [PATCH] Feat: Allows users to search for models in the model selection drop-down box #3221 (#6708) ### What problem does this PR solve? Feat: Allows users to search for models in the model selection drop-down box #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/operate-dropdown/index.tsx | 17 ++++++---- web/src/interfaces/database/knowledge.ts | 1 + web/src/interfaces/database/llm.ts | 2 ++ .../system-model-setting-modal/index.tsx | 31 ++++++++++++++++--- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/web/src/components/operate-dropdown/index.tsx b/web/src/components/operate-dropdown/index.tsx index 40877fc5a..f243ad2b7 100644 --- a/web/src/components/operate-dropdown/index.tsx +++ b/web/src/components/operate-dropdown/index.tsx @@ -13,6 +13,7 @@ interface IProps { items?: MenuProps['items']; height?: number; needsDeletionValidation?: boolean; + showDeleteItems?: boolean; } const OperateDropdown = ({ @@ -23,6 +24,7 @@ const OperateDropdown = ({ items: otherItems = [], height = 24, needsDeletionValidation = true, + showDeleteItems = true, }: React.PropsWithChildren) => { const { t } = useTranslation(); const showDeleteConfirm = useShowDeleteConfirm(); @@ -44,8 +46,10 @@ const OperateDropdown = ({ }; const items: MenuProps['items'] = useMemo(() => { - return [ - { + const items = []; + + if (showDeleteItems) { + items.push({ key: '1', label: ( @@ -53,10 +57,11 @@ const OperateDropdown = ({ ), - }, - ...otherItems, - ]; - }, [t, otherItems]); + }); + } + + return [...items, ...otherItems]; + }, [showDeleteItems, otherItems, t]); return ( ; diff --git a/web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx b/web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx index 21466307f..f67755dbe 100644 --- a/web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx +++ b/web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx @@ -64,6 +64,7 @@ const SystemModelSettingModal = ({ ...allOptions[LlmModelType.Image2text], ]} allowClear + showSearch /> - - - - -