feat: dataset folder

This commit is contained in:
archer 2023-09-08 18:06:57 +08:00
parent 971c9cb291
commit 0b0f184dd1
No known key found for this signature in database
GPG Key ID: 569A5660D2379E28
22 changed files with 417 additions and 79 deletions

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1694141197423" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4891" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><path d="M855.04 385.024q19.456 2.048 38.912 10.24t33.792 23.04 21.504 37.376 2.048 54.272q-2.048 8.192-8.192 40.448t-14.336 74.24-18.432 86.528-19.456 76.288q-5.12 18.432-14.848 37.888t-25.088 35.328-36.864 26.112-51.2 10.24l-567.296 0q-21.504 0-44.544-9.216t-42.496-26.112-31.744-40.96-12.288-53.76l0-439.296q0-62.464 33.792-97.792t95.232-35.328l503.808 0q22.528 0 46.592 8.704t43.52 24.064 31.744 35.84 12.288 44.032l0 11.264-53.248 0q-40.96 0-95.744-0.512t-116.736-0.512-115.712-0.512-92.672-0.512l-47.104 0q-26.624 0-41.472 16.896t-23.04 44.544q-8.192 29.696-18.432 62.976t-18.432 61.952q-10.24 33.792-20.48 65.536-2.048 8.192-2.048 13.312 0 17.408 11.776 29.184t29.184 11.776q31.744 0 43.008-39.936l54.272-198.656q133.12 1.024 243.712 1.024l286.72 0z" fill="#FFCC66" p-id="4892"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,6 +2,10 @@
"App": "App",
"Cancel": "No",
"Confirm": "Yes",
"Create New": "Create",
"Dataset": "Dataset",
"Folder": "Folder",
"Name": "Name",
"Running": "Running",
"Select value is empty": "Select value is empty",
"UnKnow": "UnKnow",
@ -74,12 +78,14 @@
"Copy Successful": "Copy Successful",
"Course": "",
"Delete": "Delete",
"Delete Warning": "Warning",
"Filed is repeat": "Filed is repeated",
"Filed is repeated": "",
"Input": "Input",
"Output": "Output",
"export": "",
"Password inconsistency": "Password inconsistency"
"Password inconsistency": "Password inconsistency",
"Rename": "Rename",
"export": ""
},
"dataset": {
"Confirm to delete the data": "Confirm to delete the data?",
@ -148,6 +154,13 @@
"desc": "AI knowledge base question and answer platform based on LLM large model",
"slogan": "Let the AI know more about you"
},
"kb": {
"Create Folder": "Create Folder",
"Edit Folder": "Edit Folder",
"Folder Name": "Input folder name",
"deleteDatasetTips": "Are you sure to delete the knowledge base? Data cannot be recovered after deletion, please confirm!",
"deleteFolderTips": "Are you sure to delete this folder and all the knowledge bases it contains? Data cannot be recovered after deletion, please confirm!"
},
"navbar": {
"Account": "Account",
"Apps": "Apps",

View File

@ -2,6 +2,10 @@
"App": "应用",
"Cancel": "取消",
"Confirm": "确认",
"Create New": "新建",
"Dataset": "知识库",
"Folder": "文件夹",
"Name": "名称",
"Running": "运行中",
"Select value is empty": "选择的内容为空",
"UnKnow": "未知",
@ -74,12 +78,14 @@
"Copy Successful": "复制成功",
"Course": "",
"Delete": "删除",
"Delete Warning": "删除警告",
"Filed is repeat": "",
"Filed is repeated": "字段重复了",
"Input": "输入",
"Output": "输出",
"export": "",
"Password inconsistency": "两次密码不一致"
"Password inconsistency": "两次密码不一致",
"Rename": "重命名",
"export": ""
},
"dataset": {
"Confirm to delete the data": "确认删除该数据?",
@ -148,6 +154,13 @@
"desc": "基于 LLM 大模型的 AI 知识库问答平台",
"slogan": "让 AI 更懂你的知识"
},
"kb": {
"Create Folder": "创建文件夹",
"Edit Folder": "编辑文件夹",
"Folder Name": "输入文件夹名称",
"deleteDatasetTips": "确认删除该知识库?删除后数据无法恢复,请确认!",
"deleteFolderTips": "确认删除该文件夹及其包含的所有知识库?删除后数据无法恢复,请确认!"
},
"navbar": {
"Account": "账号",
"Apps": "应用",

View File

@ -16,7 +16,8 @@ import type { KbUpdateParams, CreateKbParams } from '../request/kb';
import { QuoteItemType } from '@/types/chat';
/* knowledge base */
export const getKbList = () => GET<KbListItemType[]>(`/plugins/kb/list`);
export const getKbList = (parentId?: string) =>
GET<KbListItemType[]>(`/plugins/kb/list`, { parentId });
export const getKbById = (id: string) => GET<KbItemType>(`/plugins/kb/detail?id=${id}`);

View File

@ -1,12 +1,15 @@
import { KbTypeEnum } from '@/constants/kb';
export type KbUpdateParams = {
id: string;
name: string;
tags: string;
avatar: string;
tags?: string;
name?: string;
avatar?: string;
};
export type CreateKbParams = {
parentId?: string;
name: string;
tags: string[];
avatar: string;
vectorModel: string;
vectorModel?: string;
type: `${KbTypeEnum}`;
};

View File

@ -0,0 +1,51 @@
import React from 'react';
import { Menu, MenuList, MenuItem } from '@chakra-ui/react';
interface Props {
width: number;
offset?: [number, number];
Button: React.ReactNode;
menuList: {
isActive?: boolean;
child: React.ReactNode;
onClick: () => void;
}[];
}
const MyMenu = ({ width, offset = [0, 10], Button, menuList }: Props) => {
const menuItemStyles = {
borderRadius: 'sm',
py: 3,
display: 'flex',
alignItems: 'center',
_hover: {
backgroundColor: 'myWhite.600',
color: 'hover.blue'
}
};
return (
<Menu offset={offset} autoSelect={false} isLazy>
{Button}
<MenuList
minW={`${width}px !important`}
p={'6px'}
border={'1px solid #fff'}
boxShadow={'0px 2px 4px rgba(161, 167, 179, 0.25), 0px 0px 1px rgba(121, 141, 159, 0.25);'}
>
{menuList.map((item, i) => (
<MenuItem
key={i}
{...menuItemStyles}
onClick={item.onClick}
color={item.isActive ? 'hover.blue' : ''}
>
{item.child}
</MenuItem>
))}
</MenuList>
</Menu>
);
};
export default MyMenu;

View File

@ -14,3 +14,19 @@ export const defaultKbDetail: KbItemType = {
maxToken: 3000
}
};
export enum KbTypeEnum {
folder = 'folder',
dataset = 'dataset'
}
export const KbTypeMap = {
[KbTypeEnum.folder]: {
name: 'folder'
},
[KbTypeEnum.dataset]: {
name: 'dataset'
}
};
export const FolderAvatarSrc = '/imgs/files/folder.svg';

View File

@ -1,4 +1,4 @@
import { useCallback, useRef } from 'react';
import { useCallback, useRef, useState } from 'react';
import {
AlertDialog,
AlertDialogBody,
@ -11,21 +11,25 @@ import {
} from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
export const useConfirm = (props: { title?: string; content: string }) => {
export const useConfirm = (props: { title?: string | null; content?: string | null }) => {
const { t } = useTranslation();
const { title = t('Warning'), content } = props;
const [customContent, setCustomContent] = useState(content);
const { isOpen, onOpen, onClose } = useDisclosure();
const cancelRef = useRef(null);
const confirmCb = useRef<any>();
const cancelCb = useRef<any>();
return {
openConfirm: useCallback(
(confirm?: any, cancel?: any) => {
(confirm?: any, cancel?: any, customContent?: string) => {
confirmCb.current = confirm;
cancelCb.current = cancel;
customContent && setCustomContent(customContent);
return onOpen;
},
[onOpen]
@ -44,7 +48,7 @@ export const useConfirm = (props: { title?: string; content: string }) => {
{title}
</AlertDialogHeader>
<AlertDialogBody>{content}</AlertDialogBody>
<AlertDialogBody>{customContent}</AlertDialogBody>
<AlertDialogFooter>
<Button
@ -70,7 +74,7 @@ export const useConfirm = (props: { title?: string; content: string }) => {
</AlertDialogOverlay>
</AlertDialog>
),
[content, isOpen, onClose, title]
[customContent, isOpen, onClose, t, title]
)
};
};

View File

@ -1,4 +1,4 @@
import React, { useCallback, useRef } from 'react';
import React, { useCallback, useRef, useState } from 'react';
import { ModalFooter, ModalBody, Input, useDisclosure, Button } from '@chakra-ui/react';
import MyModal from '@/components/MyModal';

View File

@ -0,0 +1,62 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@/service/response';
import { authUser } from '@/service/utils/auth';
import { connectToDatabase, KB } from '@/service/mongo';
import { KbTypeMap } from '@/constants/kb';
const limit = 50;
let success = 0;
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
await connectToDatabase();
await authUser({ req, authRoot: true });
await initKb();
jsonRes(res, {});
} catch (error) {
jsonRes(res, {
code: 500,
error
});
}
}
async function initKb(): Promise<any> {
try {
// 找到所有 type 不存在的 kb
const kbList = await KB.find({ type: { $exists: false } }).limit(limit);
if (kbList.length === 0) return;
await Promise.allSettled(
kbList.map(async (kb) => {
let id = '';
try {
// 创建一组以 kb 的 nameuserId 相同文件夹类型的数据
const result = await KB.create({
parentId: null,
userId: kb.userId,
avatar: KbTypeMap.folder.avatar,
name: kb.name,
type: 'folder'
});
id = result._id;
// 将现有的 kb 挂载到这个文件夹下
await KB.findByIdAndUpdate(kb._id, {
parentId: result._id,
type: 'manualData'
});
console.log(++success);
} catch (error) {
await KB.findByIdAndDelete(id);
}
})
);
return initKb();
} catch (error) {
return initKb();
}
}

View File

@ -6,11 +6,7 @@ import type { CreateKbParams } from '@/api/request/kb';
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
const { name, tags, avatar, vectorModel } = req.body as CreateKbParams;
if (!name || !vectorModel) {
throw new Error('缺少参数');
}
const { name, tags, avatar, vectorModel, parentId, type } = req.body as CreateKbParams;
// 凭证校验
const { userId } = await authUser({ req, authToken: true });
@ -22,7 +18,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
userId,
tags,
vectorModel,
avatar
avatar,
parentId: parentId || null,
type
});
jsonRes(res, { data: _id });

View File

@ -33,9 +33,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
_id: data._id,
avatar: data.avatar,
name: data.name,
userId: data.userId,
vectorModel: getVectorModel(data.vectorModel),
tags: data.tags.join(' ')
userId: data.userId
}
});
} catch (err) {

View File

@ -2,29 +2,25 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@/service/response';
import { connectToDatabase, KB } from '@/service/mongo';
import { authUser } from '@/service/utils/auth';
import { KbListItemType } from '@/types/plugin';
import { getVectorModel } from '@/service/utils/data';
import { KbListItemType } from '@/types/plugin';
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
const { parentId } = req.query as { parentId: string };
// 凭证校验
const { userId } = await authUser({ req, authToken: true });
await connectToDatabase();
const kbList = await KB.find(
{
userId
},
'_id avatar name tags vectorModel'
).sort({ updateTime: -1 });
const kbList = await KB.find({
userId,
parentId: parentId || null
}).sort({ updateTime: -1 });
const data = await Promise.all(
kbList.map(async (item) => ({
_id: item._id,
avatar: item.avatar,
name: item.name,
tags: item.tags,
...item.toJSON(),
vectorModel: getVectorModel(item.vectorModel)
}))
);

View File

@ -6,7 +6,7 @@ import type { KbUpdateParams } from '@/api/request/kb';
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
const { id, name, tags, avatar } = req.body as KbUpdateParams;
const { id, name, avatar, tags = '' } = req.body as KbUpdateParams;
if (!id || !name) {
throw new Error('缺少参数');
@ -23,8 +23,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
userId
},
{
avatar,
name,
...(name && { name }),
...(avatar && { avatar }),
tags: tags.split(' ').filter((item) => item)
}
);

View File

@ -11,10 +11,9 @@ import {
Textarea
} from '@chakra-ui/react';
import Avatar from '@/components/Avatar';
import { KbListItemType } from '@/types/plugin';
import { useForm } from 'react-hook-form';
import { QuestionOutlineIcon } from '@chakra-ui/icons';
import type { SelectedKbType } from '@/types/plugin';
import type { KbListItemType, SelectedKbType } from '@/types/plugin';
import { useGlobalStore } from '@/store/global';
import { useToast } from '@/hooks/useToast';
import MySlider from '@/components/Slider';

View File

@ -18,7 +18,7 @@ import MySelect from '@/components/Select';
import { QuestionOutlineIcon } from '@chakra-ui/icons';
import Tag from '@/components/Tag';
const CreateModal = ({ onClose }: { onClose: () => void }) => {
const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: string }) => {
const [refresh, setRefresh] = useState(false);
const { toast } = useToast();
const router = useRouter();
@ -28,7 +28,9 @@ const CreateModal = ({ onClose }: { onClose: () => void }) => {
avatar: '/icon/logo.svg',
name: '',
tags: [],
vectorModel: vectorModelList[0].model
vectorModel: vectorModelList[0].model,
type: 'dataset',
parentId
}
});
const InputRef = useRef<HTMLInputElement>(null);

View File

@ -0,0 +1,85 @@
import React, { useMemo, useRef } from 'react';
import { ModalFooter, ModalBody, Input, Button } from '@chakra-ui/react';
import MyModal from '@/components/MyModal';
import { useTranslation } from 'react-i18next';
import { useRequest } from '@/hooks/useRequest';
import { postCreateKb, putKbById } from '@/api/plugins/kb';
import { FolderAvatarSrc, KbTypeEnum } from '@/constants/kb';
const EditFolderModal = ({
onClose,
onSuccess,
id,
parentId,
name
}: {
onClose: () => void;
onSuccess: () => void;
id?: string;
parentId?: string;
name?: string;
}) => {
const { t } = useTranslation();
const inputRef = useRef<HTMLInputElement>(null);
const typeMap = useMemo(
() =>
id
? {
title: t('kb.Edit Folder')
}
: {
title: t('kb.Create Folder')
},
[id, t]
);
const { mutate: onSave, isLoading } = useRequest({
mutationFn: () => {
const val = inputRef.current?.value;
if (!val) return Promise.resolve('');
if (id) {
return putKbById({
id,
name: val
});
}
return postCreateKb({
parentId,
name: val,
type: KbTypeEnum.folder,
avatar: FolderAvatarSrc,
tags: []
});
},
onSuccess: (res) => {
if (!res) return;
onSuccess();
onClose();
}
});
return (
<MyModal isOpen onClose={onClose} title={typeMap.title}>
<ModalBody>
<Input
ref={inputRef}
defaultValue={name}
placeholder={t('kb.Folder Name') || ''}
autoFocus
maxLength={20}
/>
</ModalBody>
<ModalFooter>
<Button mr={3} variant={'base'} onClick={onClose}>
{t('common.Cancel')}
</Button>
<Button isLoading={isLoading} onClick={onSave}>
{t('Confirm')}
</Button>
</ModalFooter>
</MyModal>
);
};
export default EditFolderModal;

View File

@ -1,13 +1,14 @@
import React, { useCallback } from 'react';
import React, { useCallback, useRef, useState } from 'react';
import {
Box,
Card,
Flex,
Grid,
useTheme,
Button,
useDisclosure,
Card,
IconButton,
useDisclosure
MenuButton,
Image
} from '@chakra-ui/react';
import { useRouter } from 'next/router';
import { useUserStore } from '@/store/user';
@ -17,21 +18,34 @@ import { AddIcon } from '@chakra-ui/icons';
import { useQuery } from '@tanstack/react-query';
import { useToast } from '@/hooks/useToast';
import { delKbById } from '@/api/plugins/kb';
import { useTranslation } from 'react-i18next';
import Avatar from '@/components/Avatar';
import MyIcon from '@/components/Icon';
import Tag from '@/components/Tag';
import { serviceSideProps } from '@/utils/i18n';
import dynamic from 'next/dynamic';
import { FolderAvatarSrc, KbTypeEnum } from '@/constants/kb';
import Tag from '@/components/Tag';
import MyMenu from '@/components/MyMenu';
import { getErrText } from '@/utils/tools';
const CreateModal = dynamic(() => import('./component/CreateModal'), { ssr: false });
const EditFolderModal = dynamic(() => import('./component/EditFolderModal'), { ssr: false });
const Kb = () => {
const { t } = useTranslation();
const theme = useTheme();
const router = useRouter();
const { parentId } = router.query as { parentId: string };
const { toast } = useToast();
const DeleteTipsMap = useRef({
[KbTypeEnum.folder]: t('kb.deleteFolderTips'),
[KbTypeEnum.dataset]: t('kb.deleteDatasetTips')
});
const { openConfirm, ConfirmModal } = useConfirm({
title: '删除提示',
content: '确认删除该知识库?知识库相关的文件、记录将永久删除,无法恢复!'
title: t('common.Delete Warning'),
content: ''
});
const { myKbList, loadKbList, setKbList } = useUserStore();
@ -40,8 +54,12 @@ const Kb = () => {
onOpen: onOpenCreateModal,
onClose: onCloseCreateModal
} = useDisclosure();
const [editFolderData, setEditFolderData] = useState<{
id?: string;
name?: string;
}>();
const { refetch } = useQuery(['loadKbList'], () => loadKbList());
const { refetch } = useQuery(['loadKbList', parentId], () => loadKbList(parentId));
/* 点击删除 */
const onclickDelKb = useCallback(
@ -55,7 +73,7 @@ const Kb = () => {
setKbList(myKbList.filter((item) => item._id !== id));
} catch (err: any) {
toast({
title: err?.message || '删除失败',
title: getErrText(err, '删除失败'),
status: 'error'
});
}
@ -69,9 +87,49 @@ const Kb = () => {
<Box flex={1} className="textlg" letterSpacing={1} fontSize={'24px'} fontWeight={'bold'}>
</Box>
<Button leftIcon={<AddIcon />} variant={'base'} onClick={onOpenCreateModal}>
</Button>
<MyMenu
offset={[-30, 10]}
width={120}
Button={
<MenuButton
_hover={{
color: 'myBlue.600'
}}
>
<Flex
alignItems={'center'}
border={theme.borders.base}
px={5}
py={2}
borderRadius={'md'}
cursor={'pointer'}
>
<AddIcon mr={2} />
<Box>{t('Create New')}</Box>
</Flex>
</MenuButton>
}
menuList={[
{
child: (
<Flex>
<Image src={FolderAvatarSrc} alt={''} w={'20px'} mr={1} />
{t('Folder')}
</Flex>
),
onClick: () => setEditFolderData({})
},
{
child: (
<Flex>
<Image src={'/imgs/module/db.png'} alt={''} w={'20px'} mr={1} />
{t('Dataset')}
</Flex>
),
onClick: onOpenCreateModal
}
]}
/>
</Flex>
<Grid
p={5}
@ -86,7 +144,7 @@ const Kb = () => {
py={4}
px={5}
cursor={'pointer'}
h={'140px'}
h={'130px'}
border={theme.borders.md}
boxShadow={'none'}
userSelect={'none'}
@ -98,14 +156,23 @@ const Kb = () => {
display: 'block'
}
}}
onClick={() =>
router.push({
pathname: '/kb/detail',
query: {
kbId: kb._id
}
})
}
onClick={() => {
if (kb.type === KbTypeEnum.folder) {
router.push({
pathname: '/kb/list',
query: {
parentId: kb._id
}
});
} else if (kb.type === KbTypeEnum.dataset) {
router.push({
pathname: '/kb/detail',
query: {
kbId: kb._id
}
});
}
}}
>
<Flex alignItems={'center'} h={'38px'}>
<Avatar src={kb.avatar} borderRadius={'lg'} w={'28px'} />
@ -126,7 +193,11 @@ const Kb = () => {
}}
onClick={(e) => {
e.stopPropagation();
openConfirm(() => onclickDelKb(kb._id))();
openConfirm(
() => onclickDelKb(kb._id),
undefined,
DeleteTipsMap.current[kb.type]
)();
}}
/>
</Flex>
@ -140,8 +211,14 @@ const Kb = () => {
</Flex>
</Box>
<Flex justifyContent={'flex-end'} alignItems={'center'} fontSize={'sm'}>
<MyIcon mr={1} name="kbTest" w={'12px'} />
<Box color={'myGray.500'}>{kb.vectorModel.name}</Box>
{kb.type === KbTypeEnum.folder ? (
<Box color={'myGray.500'}>{t('Folder')}</Box>
) : (
<>
<MyIcon mr={1} name="kbTest" w={'12px'} />
<Box color={'myGray.500'}>{kb.vectorModel.name}</Box>
</>
)}
</Flex>
</Card>
))}
@ -155,7 +232,15 @@ const Kb = () => {
</Flex>
)}
<ConfirmModal />
{isOpenCreateModal && <CreateModal onClose={onCloseCreateModal} />}
{isOpenCreateModal && <CreateModal onClose={onCloseCreateModal} parentId={parentId} />}
{!!editFolderData && (
<EditFolderModal
onClose={() => setEditFolderData(undefined)}
onSuccess={refetch}
parentId={parentId}
{...editFolderData}
/>
)}
</PageContainer>
);
};

View File

@ -1,7 +1,13 @@
import { Schema, model, models, Model } from 'mongoose';
import { kbSchema as SchemaType } from '@/types/mongoSchema';
import { KbTypeMap } from '@/constants/kb';
const kbSchema = new Schema({
parentId: {
type: Schema.Types.ObjectId,
ref: 'kb',
default: null
},
userId: {
type: Schema.Types.ObjectId,
ref: 'user',
@ -24,6 +30,11 @@ const kbSchema = new Schema({
required: true,
default: 'text-embedding-ada-002'
},
type: {
type: String,
enum: Object.keys(KbTypeMap),
required: true
},
tags: {
type: [String],
default: []

View File

@ -8,7 +8,7 @@ import { getTokenLogin, putUserInfo } from '@/api/user';
import { defaultApp } from '@/constants/model';
import { AppListItemType, AppUpdateParams } from '@/types/app';
import type { KbItemType, KbListItemType } from '@/types/plugin';
import { getKbList, getKbById } from '@/api/plugins/kb';
import { getKbList, getKbById, putKbById } from '@/api/plugins/kb';
import { defaultKbDetail } from '@/constants/kb';
import type { AppSchema } from '@/types/mongoSchema';
@ -26,7 +26,7 @@ type State = {
clearAppModules(): void;
// kb
myKbList: KbListItemType[];
loadKbList: () => Promise<any>;
loadKbList: (parentId: string) => Promise<any>;
setKbList(val: KbListItemType[]): void;
kbDetail: KbItemType;
getKbDetail: (id: string, init?: boolean) => Promise<KbItemType>;
@ -108,14 +108,14 @@ export const useUserStore = create<State>()(
});
},
myKbList: [],
async loadKbList() {
const res = await getKbList();
async loadKbList(parentId) {
const res = await getKbList(parentId);
set((state) => {
state.myKbList = res;
});
return res;
},
setKbList(val: KbListItemType[]) {
setKbList(val) {
set((state) => {
state.myKbList = val;
});

View File

@ -6,6 +6,7 @@ import { TrainingModeEnum } from '@/constants/plugin';
import type { AppModuleItemType } from './app';
import { ChatSourceEnum, OutLinkTypeEnum } from '@/constants/chat';
import { AppTypeEnum } from '@/constants/app';
import { KbTypeEnum } from '@/constants/kb';
export interface UserModelSchema {
_id: string;
@ -166,15 +167,17 @@ export interface OutLinkSchema {
type: `${OutLinkTypeEnum}`;
}
export interface kbSchema {
export type kbSchema = {
_id: string;
userId: string;
parentId: string;
updateTime: Date;
avatar: string;
name: string;
vectorModel: string;
tags: string[];
}
type: `${KbTypeEnum}`;
};
export interface informSchema {
_id: string;

View File

@ -3,13 +3,10 @@ import type { kbSchema } from './mongoSchema';
export type SelectedKbType = { kbId: string; vectorModel: VectorModelItemType }[];
export type KbListItemType = {
_id: string;
avatar: string;
name: string;
tags: string[];
export type KbListItemType = Omit<kbSchema, 'vectorModel'> & {
vectorModel: VectorModelItemType;
};
/* kb type */
export interface KbItemType {
_id: string;