feat: remove KnowledgeSearching and add knowledge configuration page and add a run button to the document (#64)

* feat: add a run button to the document

* feat: add knowledge configuration page

* feat: remove KnowledgeSearching
This commit is contained in:
balibabu
2024-02-18 18:18:20 +08:00
committed by GitHub
parent 53be70c7a9
commit f3d0ebd293
22 changed files with 495 additions and 687 deletions

View File

@ -1,6 +1,6 @@
import showDeleteConfirm from '@/components/deleting-confirm';
import { IKnowledge } from '@/interfaces/database/knowledge';
import { useCallback } from 'react';
import { IKnowledge, ITenantInfo } from '@/interfaces/database/knowledge';
import { useCallback, useEffect, useMemo } from 'react';
import { useDispatch, useSearchParams, useSelector } from 'umi';
export const useKnowledgeBaseId = (): string => {
@ -77,3 +77,50 @@ export const useDeleteChunkByIds = (): {
removeChunk: onRemoveChunk,
};
};
export const useSelectParserList = (): Array<{
value: string;
label: string;
}> => {
const tenantIfo: Nullable<ITenantInfo> = useSelector(
(state: any) => state.settingModel.tenantIfo,
);
const parserList = useMemo(() => {
const parserArray: Array<string> = tenantIfo?.parser_ids.split(',') ?? [];
return parserArray.map((x) => {
const arr = x.split(':');
return { value: arr[0], label: arr[1] };
});
}, [tenantIfo]);
return parserList;
};
export const useFetchParserList = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch({
type: 'settingModel/getTenantInfo',
});
}, [dispatch]);
};
export const useFetchKnowledgeBaseConfiguration = () => {
const dispatch = useDispatch();
const knowledgeBaseId = useKnowledgeBaseId();
const fetchKnowledgeBaseConfiguration = useCallback(() => {
dispatch({
type: 'kSModel/getKbDetail',
payload: {
kb_id: knowledgeBaseId,
},
});
}, [dispatch, knowledgeBaseId]);
useEffect(() => {
fetchKnowledgeBaseConfiguration();
}, [fetchKnowledgeBaseConfiguration]);
};