feat(fe): component for available apis

This commit is contained in:
Junyan Qin
2025-07-11 21:40:42 +08:00
parent 6d788cadbc
commit fe122281fd
5 changed files with 41 additions and 2 deletions

View File

@@ -212,6 +212,7 @@ export default function BotForm({
});
setAdapterNameToDynamicConfigMap(adapterNameToDynamicConfigMap);
}
async function getBotConfig(
botId: string,
): Promise<z.infer<typeof formSchema>> {

View File

@@ -24,6 +24,7 @@ import { z } from 'zod';
// import { httpClient } from '@/app/infra/http/HttpClient';
// import { KnowledgeBase } from '@/app/infra/entities/api';
import KBForm from '@/app/home/knowledge/components/kb-form/KBForm';
import KBDoc from '@/app/home/knowledge/components/kb-docs/KBDoc';
interface KBDetailDialogProps {
open: boolean;
@@ -48,6 +49,7 @@ export default function KBDetailDialog({
const { t } = useTranslation();
const [kbId, setKbId] = useState<string | undefined>(propKbId);
const [activeMenu, setActiveMenu] = useState('metadata');
const [fileId, setFileId] = useState<string | undefined>(undefined);
// const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
useEffect(() => {
@@ -177,7 +179,7 @@ export default function KBDetailDialog({
onNewKbCreated={onNewKbCreated}
/>
)}
{activeMenu === 'documents' && <div>documents</div>}
{activeMenu === 'documents' && <KBDoc kbId={kbId} />}
</div>
{activeMenu === 'metadata' && (
<DialogFooter className="px-6 py-4 border-t shrink-0">

View File

@@ -0,0 +1,5 @@
import { useEffect, useState } from 'react';
export default function KBDoc({ kbId }: { kbId: string }) {
return <div>Documents</div>;
}

View File

@@ -0,0 +1,9 @@
export default function DocumentCard({
kbId,
fileId,
}: {
kbId: string;
fileId: string;
}) {
return <div></div>;
}

View File

@@ -67,9 +67,31 @@ export default function KBForm({
>([]);
useEffect(() => {
getEmbeddingModelNameList();
getEmbeddingModelNameList().then(() => {
if (initKbId) {
getKbConfig(initKbId).then((val) => {
form.setValue('name', val.name);
form.setValue('description', val.description);
form.setValue('embeddingModelUUID', val.embeddingModelUUID);
});
}
});
}, []);
const getKbConfig = async (
kbId: string,
): Promise<z.infer<typeof formSchema>> => {
return new Promise((resolve, reject) => {
httpClient.getKnowledgeBase(kbId).then((res) => {
resolve({
name: res.base.name,
description: res.base.description,
embeddingModelUUID: res.base.embedding_model_uuid,
});
});
});
};
const getEmbeddingModelNameList = async () => {
const resp = await httpClient.getProviderEmbeddingModels();
setEmbeddingModelNameList(