mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
fix: disable sending messages if both application and conversation are empty and add loading to all pages (#134)
* feat: add loading to all pages * fix: disable sending messages if both application and conversation are empty * feat: add chatSpin class to Spin of chat
This commit is contained in:
@ -0,0 +1,73 @@
|
||||
import {
|
||||
useFetchKnowledgeBaseConfiguration,
|
||||
useKnowledgeBaseId,
|
||||
useSelectKnowledgeDetails,
|
||||
useUpdateKnowledge,
|
||||
} from '@/hooks/knowledgeHook';
|
||||
import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import {
|
||||
useFetchTenantInfo,
|
||||
useSelectParserList,
|
||||
} from '@/hooks/userSettingHook';
|
||||
import {
|
||||
getBase64FromUploadFileList,
|
||||
getUploadFileListFromBase64,
|
||||
} from '@/utils/fileUtil';
|
||||
import { Form, UploadFile } from 'antd';
|
||||
import pick from 'lodash/pick';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { LlmModelType } from '../../constant';
|
||||
|
||||
export const useSubmitKnowledgeConfiguration = () => {
|
||||
const save = useUpdateKnowledge();
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
const submitLoading = useOneNamespaceEffectsLoading('kSModel', ['updateKb']);
|
||||
|
||||
const submitKnowledgeConfiguration = useCallback(
|
||||
async (values: any) => {
|
||||
const avatar = await getBase64FromUploadFileList(values.avatar);
|
||||
save({
|
||||
...values,
|
||||
avatar,
|
||||
kb_id: knowledgeBaseId,
|
||||
});
|
||||
},
|
||||
[save, knowledgeBaseId],
|
||||
);
|
||||
|
||||
return { submitKnowledgeConfiguration, submitLoading };
|
||||
};
|
||||
|
||||
export const useFetchKnowledgeConfigurationOnMount = () => {
|
||||
const [form] = Form.useForm();
|
||||
const loading = useOneNamespaceEffectsLoading('kSModel', ['getKbDetail']);
|
||||
|
||||
const knowledgeDetails = useSelectKnowledgeDetails();
|
||||
const parserList = useSelectParserList();
|
||||
const embeddingModelOptions = useSelectLlmOptions();
|
||||
|
||||
useFetchTenantInfo();
|
||||
useFetchKnowledgeBaseConfiguration();
|
||||
useFetchLlmList(LlmModelType.Embedding);
|
||||
|
||||
useEffect(() => {
|
||||
const fileList: UploadFile[] = getUploadFileListFromBase64(
|
||||
knowledgeDetails.avatar,
|
||||
);
|
||||
form.setFieldsValue({
|
||||
...pick(knowledgeDetails, [
|
||||
'description',
|
||||
'name',
|
||||
'permission',
|
||||
'embd_id',
|
||||
'parser_id',
|
||||
'language',
|
||||
'parser_config.chunk_token_num',
|
||||
]),
|
||||
avatar: fileList,
|
||||
});
|
||||
}, [form, knowledgeDetails]);
|
||||
|
||||
return { form, parserList, embeddingModelOptions, loading };
|
||||
};
|
||||
Reference in New Issue
Block a user