feat: fetch knowledge detail on KnowledgeUploadFile mount and add category column to chunk table and set initial value for the model field of chat setting (#104)

* feat: set initial value for the model field of chat setting

* feat: add category column to chunk table

* feat: fetch knowledge detail on KnowledgeUploadFile mount
This commit is contained in:
balibabu
2024-03-06 19:17:45 +08:00
committed by GitHub
parent b89ac3c4be
commit aaf3084324
14 changed files with 230 additions and 320 deletions

View File

@@ -1,5 +1,6 @@
import { ITenantInfo } from '@/interfaces/database/knowledge';
import { IUserInfo } from '@/interfaces/database/userSetting';
import { useCallback, useEffect } from 'react';
import { useCallback, useEffect, useMemo } from 'react';
import { useDispatch, useSelector } from 'umi';
export const useFetchUserInfo = () => {
@@ -20,3 +21,46 @@ export const useSelectUserInfo = () => {
return userInfo;
};
export const useSelectTenantInfo = () => {
const tenantInfo: ITenantInfo = useSelector(
(state: any) => state.settingModel.tenantIfo,
);
return tenantInfo;
};
export const useFetchTenantInfo = (isOnMountFetching: boolean = true) => {
const dispatch = useDispatch();
const fetchTenantInfo = useCallback(() => {
dispatch({
type: 'settingModel/getTenantInfo',
});
}, [dispatch]);
useEffect(() => {
if (isOnMountFetching) {
fetchTenantInfo();
}
}, [fetchTenantInfo, isOnMountFetching]);
return fetchTenantInfo;
};
export const useSelectParserList = (): Array<{
value: string;
label: string;
}> => {
const tenantInfo: ITenantInfo = useSelectTenantInfo();
const parserList = useMemo(() => {
const parserArray: Array<string> = tenantInfo?.parser_ids.split(',') ?? [];
return parserArray.map((x) => {
const arr = x.split(':');
return { value: arr[0], label: arr[1] };
});
}, [tenantInfo]);
return parserList;
};