From 524c56a12b4d5f89a20de377ea299bf35b2217d8 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:52:30 +0800 Subject: [PATCH] feat(web): add hover card to embedding model selector in knowledge base form (#1772) * Initial plan * feat: Add hover card with model details to embedding model selector in KB form - Updated KBForm.tsx to fetch full EmbeddingModel objects instead of simplified entities - Added HoverCard component to show model details (icon, description, base URL, extra args) when hovering over embedding model options - Removed unused IEmbeddingModelEntity import and embeddingModelNameList state - Made the embedding model selector consistent with LLM model selector behavior Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> --- .../knowledge/components/kb-form/KBForm.tsx | 106 +++++++++++++++--- 1 file changed, 89 insertions(+), 17 deletions(-) diff --git a/web/src/app/home/knowledge/components/kb-form/KBForm.tsx b/web/src/app/home/knowledge/components/kb-form/KBForm.tsx index 0804ee12..6c9bdd8c 100644 --- a/web/src/app/home/knowledge/components/kb-form/KBForm.tsx +++ b/web/src/app/home/knowledge/components/kb-form/KBForm.tsx @@ -13,7 +13,6 @@ import { FormMessage, FormDescription, } from '@/components/ui/form'; -import { IEmbeddingModelEntity } from './ChooseEntity'; import { httpClient } from '@/app/infra/http/HttpClient'; import { Select, @@ -23,8 +22,13 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select'; -import { KnowledgeBase } from '@/app/infra/entities/api'; +import { KnowledgeBase, EmbeddingModel } from '@/app/infra/entities/api'; import { toast } from 'sonner'; +import { + HoverCard, + HoverCardContent, + HoverCardTrigger, +} from '@/components/ui/hover-card'; const getFormSchema = (t: (key: string) => string) => z.object({ @@ -63,9 +67,7 @@ export default function KBForm({ }, }); - const [embeddingModelNameList, setEmbeddingModelNameList] = useState< - IEmbeddingModelEntity[] - >([]); + const [embeddingModels, setEmbeddingModels] = useState([]); useEffect(() => { getEmbeddingModelNameList().then(() => { @@ -97,14 +99,7 @@ export default function KBForm({ const getEmbeddingModelNameList = async () => { const resp = await httpClient.getProviderEmbeddingModels(); - setEmbeddingModelNameList( - resp.models.map((item) => { - return { - label: item.name, - value: item.uuid, - }; - }), - ); + setEmbeddingModels(resp.models); }; const onSubmit = (data: z.infer) => { @@ -216,10 +211,87 @@ export default function KBForm({ - {embeddingModelNameList.map((item) => ( - - {item.label} - + {embeddingModels.map((model) => ( + + + + {model.name} + + + +
+
+ icon +

+ {model.name} +

+
+

+ {model.description} +

+ {model.requester_config && ( +
+ + + + + Base URL: + + {model.requester_config.base_url} +
+ )} + {model.extra_args && + Object.keys(model.extra_args).length > + 0 && ( +
+
+ {t('models.extraParameters')} +
+
+ {Object.entries( + model.extra_args as Record< + string, + unknown + >, + ).map(([key, value]) => ( +
+ + {key}: + + + {JSON.stringify(value)} + +
+ ))} +
+
+ )} +
+
+
))}