import { useFetchKnowledgeBaseConfiguration, useFetchParserList, useKnowledgeBaseId, useSelectParserList, } from '@/hooks/knowledgeHook'; import { Button, Divider, Form, Input, Radio, Select, Space, Typography, Upload, UploadFile, } from 'antd'; import pick from 'lodash/pick'; import { useCallback, useEffect, useMemo } from 'react'; import { useDispatch, useSelector } from 'umi'; import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks'; import { IKnowledge } from '@/interfaces/database/knowledge'; import { IThirdOAIModelCollection } from '@/interfaces/database/llm'; import { PlusOutlined } from '@ant-design/icons'; import styles from './index.less'; const { Title } = Typography; const { Option } = Select; const Configuration = () => { const [form] = Form.useForm(); const dispatch = useDispatch(); const knowledgeBaseId = useKnowledgeBaseId(); const loading = useOneNamespaceEffectsLoading('kSModel', ['updateKb']); const llmInfo: IThirdOAIModelCollection = useSelector( (state: any) => state.settingModel.llmInfo, ); const knowledgeDetails: IKnowledge = useSelector( (state: any) => state.kSModel.knowledgeDetails, ); const normFile = (e: any) => { if (Array.isArray(e)) { return e; } return e?.fileList; }; const parserList = useSelectParserList(); const embeddingModelOptions = useMemo(() => { return Object.entries(llmInfo).map(([key, value]) => { return { label: key, options: value.map((x) => ({ label: x.llm_name, value: x.llm_name, })), }; }); }, [llmInfo]); const onFinish = async (values: any) => { console.info(values); const fileList = values.avatar; let avatar; if (Array.isArray(fileList) && fileList.length > 0) { avatar = fileList[0].thumbUrl; } dispatch({ type: 'kSModel/updateKb', payload: { ...values, avatar, kb_id: knowledgeBaseId, }, }); }; const onFinishFailed = (errorInfo: any) => { console.log('Failed:', errorInfo); }; const fetchLlmList = useCallback(() => { dispatch({ type: 'settingModel/llm_list', payload: { model_type: 'embedding' }, }); }, [dispatch]); useEffect(() => { const avatar = knowledgeDetails.avatar; let fileList: UploadFile[] = []; if (avatar) { fileList = [{ uid: '1', name: 'file', thumbUrl: avatar, status: 'done' }]; } form.setFieldsValue({ ...pick(knowledgeDetails, [ 'description', 'name', 'permission', 'embd_id', 'parser_id', ]), avatar: fileList, }); }, [form, knowledgeDetails]); useFetchParserList(); useFetchKnowledgeBaseConfiguration(); useEffect(() => { fetchLlmList(); }, [fetchLlmList]); return (
Configuration

Update your knowledge base details especially parsing method here.

Only me Team
); }; export default Configuration;