mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: change all file names to lowercase #1574 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { useDeleteChunkByIds } from '@/hooks/knowledgeHook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useDeleteChunkByIds } from '@/hooks/knowledge-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { DeleteOutlined } from '@ant-design/icons';
|
||||
import { Checkbox, Divider, Form, Input, Modal, Space } from 'antd';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
|
||||
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useKnowledgeBaseId } from '@/hooks/knowledgeHook';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useKnowledgeBaseId } from '@/hooks/knowledge-hooks';
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
CheckCircleOutlined,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
|
||||
import { api_host } from '@/utils/api';
|
||||
import { useSize } from 'ahooks';
|
||||
import { CustomTextRenderer } from 'node_modules/react-pdf/dist/esm/shared/types';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { buildChunkHighlights } from '@/utils/documentUtils';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useFetchChunkList } from '@/hooks/chunkHooks';
|
||||
import { useDeleteChunkByIds } from '@/hooks/knowledgeHook';
|
||||
import { useFetchChunkList } from '@/hooks/chunk-hooks';
|
||||
import { useDeleteChunkByIds } from '@/hooks/knowledge-hooks';
|
||||
import type { PaginationProps } from 'antd';
|
||||
import { Divider, Flex, Pagination, Space, Spin, message } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { BaseState } from '@/interfaces/common';
|
||||
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import kbService from '@/services/kbService';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import { message } from 'antd';
|
||||
import { pick } from 'lodash';
|
||||
// import { delay } from '@/utils/storeUtil';
|
||||
|
||||
@ -6,17 +6,17 @@ import {
|
||||
useRunDocument,
|
||||
useSelectDocumentList,
|
||||
useUploadDocument,
|
||||
} from '@/hooks/documentHooks';
|
||||
} from '@/hooks/document-hooks';
|
||||
import {
|
||||
useDeleteDocumentById,
|
||||
useFetchKnowledgeDetail,
|
||||
useKnowledgeBaseId,
|
||||
} from '@/hooks/knowledgeHook';
|
||||
} from '@/hooks/knowledge-hooks';
|
||||
import {
|
||||
useChangeDocumentParser,
|
||||
useSetSelectedRecord,
|
||||
} from '@/hooks/logic-hooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
||||
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { getExtension, isFileUploadDone } from '@/utils/documentUtils';
|
||||
import {
|
||||
@ -40,7 +40,7 @@ import classNames from 'classnames';
|
||||
import { ReactElement, useCallback, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useNavigate } from 'umi';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Dragger } = Upload;
|
||||
|
||||
@ -3,13 +3,13 @@ import { ReactComponent as DeleteIcon } from '@/assets/svg/delete.svg';
|
||||
import { ReactComponent as DisableIcon } from '@/assets/svg/disable.svg';
|
||||
import { ReactComponent as EnableIcon } from '@/assets/svg/enable.svg';
|
||||
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
|
||||
import { useShowDeleteConfirm, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useRemoveDocument,
|
||||
useRunDocument,
|
||||
useSetDocumentStatus,
|
||||
} from '@/hooks/documentHooks';
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
|
||||
} from '@/hooks/document-hooks';
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
|
||||
import {
|
||||
DownOutlined,
|
||||
FileOutlined,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useCreateDocument,
|
||||
useFetchDocumentList,
|
||||
@ -8,10 +8,10 @@ import {
|
||||
useSetDocumentParser,
|
||||
useUploadDocument,
|
||||
useWebCrawl,
|
||||
} from '@/hooks/documentHooks';
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
||||
} from '@/hooks/document-hooks';
|
||||
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
||||
import { Pagination } from '@/interfaces/common';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { getUnSupportedFilesCount } from '@/utils/documentUtils';
|
||||
@ -296,13 +296,13 @@ export const useHandleWebCrawl = () => {
|
||||
const webCrawl = useWebCrawl();
|
||||
|
||||
const onWebCrawlUploadOk = useCallback(
|
||||
async (name: string, url: string ) => {
|
||||
async (name: string, url: string) => {
|
||||
const ret = await webCrawl(name, url);
|
||||
if (ret === 0) {
|
||||
hideWebCrawlUploadModal();
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
return -1
|
||||
return -1;
|
||||
},
|
||||
[webCrawl, hideWebCrawlUploadModal],
|
||||
);
|
||||
|
||||
@ -3,9 +3,9 @@ import SvgIcon from '@/components/svg-icon';
|
||||
import {
|
||||
useSelectDocumentList,
|
||||
useSetDocumentStatus,
|
||||
} from '@/hooks/documentHooks';
|
||||
} from '@/hooks/document-hooks';
|
||||
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
||||
import { useSelectParserList } from '@/hooks/userSettingHook';
|
||||
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { getExtension } from '@/utils/documentUtils';
|
||||
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
||||
|
||||
@ -1,276 +1,276 @@
|
||||
import { BaseState } from '@/interfaces/common';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import i18n from '@/locales/config';
|
||||
import kbService, { getDocumentFile } from '@/services/kbService';
|
||||
import { message } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
import pick from 'lodash/pick';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KFModelState extends BaseState {
|
||||
tenantIfo: any;
|
||||
data: IKnowledgeFile[];
|
||||
total: number;
|
||||
currentRecord: Nullable<IKnowledgeFile>;
|
||||
fileThumbnails: Record<string, string>;
|
||||
}
|
||||
|
||||
const model: DvaModel<KFModelState> = {
|
||||
namespace: 'kFModel',
|
||||
state: {
|
||||
tenantIfo: {},
|
||||
data: [],
|
||||
total: 0,
|
||||
currentRecord: null,
|
||||
searchString: '',
|
||||
pagination: {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
fileThumbnails: {} as Record<string, string>,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
|
||||
setCurrentRecord(state, { payload }) {
|
||||
return { ...state, currentRecord: payload };
|
||||
},
|
||||
setSearchString(state, { payload }) {
|
||||
return { ...state, searchString: payload };
|
||||
},
|
||||
setPagination(state, { payload }) {
|
||||
return { ...state, pagination: { ...state.pagination, ...payload } };
|
||||
},
|
||||
setFileThumbnails(state, { payload }) {
|
||||
return { ...state, fileThumbnails: payload };
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*createKf({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.createKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
},
|
||||
*updateKf({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.updateKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.modified'));
|
||||
}
|
||||
},
|
||||
*getKfDetail({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
},
|
||||
*getKfList({ payload = {} }, { call, put, select }) {
|
||||
const state: KFModelState = yield select((state: any) => state.kFModel);
|
||||
const requestBody = {
|
||||
...payload,
|
||||
page: state.pagination.current,
|
||||
page_size: state.pagination.pageSize,
|
||||
};
|
||||
if (state.searchString) {
|
||||
requestBody['keywords'] = state.searchString;
|
||||
}
|
||||
const { data } = yield call(kbService.get_document_list, requestBody);
|
||||
const { retcode, data: res } = data;
|
||||
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
data: res.docs,
|
||||
total: res.total,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
throttledGetDocumentList: [
|
||||
function* ({ payload }, { call, put }) {
|
||||
yield put({ type: 'getKfList', payload: { kb_id: payload } });
|
||||
},
|
||||
{ type: 'throttle', ms: 1000 }, // TODO: Provide type support for this effect
|
||||
],
|
||||
pollGetDocumentList: [
|
||||
function* ({ payload }, { call, put }) {
|
||||
yield put({ type: 'getKfList', payload: { kb_id: payload } });
|
||||
},
|
||||
{ type: 'poll', delay: 5000 }, // TODO: Provide type support for this effect
|
||||
],
|
||||
*updateDocumentStatus({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_change_status,
|
||||
pick(payload, ['doc_id', 'status']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.modified'));
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
},
|
||||
*document_rm({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_rm, {
|
||||
doc_id: payload.doc_id,
|
||||
});
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.deleted'));
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_rename({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_rename,
|
||||
omit(payload, ['kb_id']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.renamed'));
|
||||
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
|
||||
return retcode;
|
||||
},
|
||||
*document_create({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_create, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_run({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_run,
|
||||
omit(payload, ['knowledgeBaseId']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
if (payload.knowledgeBaseId) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.knowledgeBaseId },
|
||||
});
|
||||
}
|
||||
message.success(i18n.t('message.operated'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_change_parser({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_change_parser,
|
||||
omit(payload, ['kb_id']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
|
||||
message.success(i18n.t('message.modified'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*fetch_document_thumbnails({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_thumbnails, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setFileThumbnails', payload: data.data });
|
||||
}
|
||||
},
|
||||
*fetch_document_file({ payload = {} }, { call }) {
|
||||
const documentId = payload;
|
||||
try {
|
||||
const ret = yield call(getDocumentFile, documentId);
|
||||
return ret;
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
}
|
||||
},
|
||||
*upload_document({ payload = {} }, { call, put }) {
|
||||
const fileList = payload.fileList;
|
||||
const formData = new FormData();
|
||||
formData.append('kb_id', payload.kb_id);
|
||||
fileList.forEach((file: any) => {
|
||||
formData.append('file', file);
|
||||
});
|
||||
|
||||
const { data } = yield call(kbService.document_upload, formData);
|
||||
|
||||
const succeed = data.retcode === 0;
|
||||
|
||||
if (succeed) {
|
||||
message.success(i18n.t('message.uploaded'));
|
||||
}
|
||||
if (succeed || data.retcode === 500) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*web_crawl({ payload = {} }, { call, put }) {
|
||||
const formData = new FormData();
|
||||
formData.append('name', payload.name);
|
||||
formData.append('url', payload.url);
|
||||
formData.append('kb_id', payload.kb_id);
|
||||
|
||||
const { data } = yield call(kbService.web_crawl, formData);
|
||||
|
||||
const succeed = data.retcode === 0;
|
||||
|
||||
if (succeed) {
|
||||
message.success(i18n.t('message.uploaded'));
|
||||
}
|
||||
if (succeed || data.retcode === 500) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ location }) => {
|
||||
const state: { from: string } = (location.state ?? {
|
||||
from: '',
|
||||
}) as { from: string };
|
||||
if (
|
||||
state.from === '/knowledge' || // TODO: Just directly determine whether the current page is on the knowledge list page.
|
||||
location.pathname === '/knowledge/dataset/upload'
|
||||
) {
|
||||
dispatch({
|
||||
type: 'setPagination',
|
||||
payload: { current: 1, pageSize: 10 },
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
import { BaseState } from '@/interfaces/common';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import i18n from '@/locales/config';
|
||||
import kbService, { getDocumentFile } from '@/services/knowledge-service';
|
||||
import { message } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
import pick from 'lodash/pick';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KFModelState extends BaseState {
|
||||
tenantIfo: any;
|
||||
data: IKnowledgeFile[];
|
||||
total: number;
|
||||
currentRecord: Nullable<IKnowledgeFile>;
|
||||
fileThumbnails: Record<string, string>;
|
||||
}
|
||||
|
||||
const model: DvaModel<KFModelState> = {
|
||||
namespace: 'kFModel',
|
||||
state: {
|
||||
tenantIfo: {},
|
||||
data: [],
|
||||
total: 0,
|
||||
currentRecord: null,
|
||||
searchString: '',
|
||||
pagination: {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
fileThumbnails: {} as Record<string, string>,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
|
||||
setCurrentRecord(state, { payload }) {
|
||||
return { ...state, currentRecord: payload };
|
||||
},
|
||||
setSearchString(state, { payload }) {
|
||||
return { ...state, searchString: payload };
|
||||
},
|
||||
setPagination(state, { payload }) {
|
||||
return { ...state, pagination: { ...state.pagination, ...payload } };
|
||||
},
|
||||
setFileThumbnails(state, { payload }) {
|
||||
return { ...state, fileThumbnails: payload };
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*createKf({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.createKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
},
|
||||
*updateKf({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.updateKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.modified'));
|
||||
}
|
||||
},
|
||||
*getKfDetail({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
},
|
||||
*getKfList({ payload = {} }, { call, put, select }) {
|
||||
const state: KFModelState = yield select((state: any) => state.kFModel);
|
||||
const requestBody = {
|
||||
...payload,
|
||||
page: state.pagination.current,
|
||||
page_size: state.pagination.pageSize,
|
||||
};
|
||||
if (state.searchString) {
|
||||
requestBody['keywords'] = state.searchString;
|
||||
}
|
||||
const { data } = yield call(kbService.get_document_list, requestBody);
|
||||
const { retcode, data: res } = data;
|
||||
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
data: res.docs,
|
||||
total: res.total,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
throttledGetDocumentList: [
|
||||
function* ({ payload }, { call, put }) {
|
||||
yield put({ type: 'getKfList', payload: { kb_id: payload } });
|
||||
},
|
||||
{ type: 'throttle', ms: 1000 }, // TODO: Provide type support for this effect
|
||||
],
|
||||
pollGetDocumentList: [
|
||||
function* ({ payload }, { call, put }) {
|
||||
yield put({ type: 'getKfList', payload: { kb_id: payload } });
|
||||
},
|
||||
{ type: 'poll', delay: 5000 }, // TODO: Provide type support for this effect
|
||||
],
|
||||
*updateDocumentStatus({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_change_status,
|
||||
pick(payload, ['doc_id', 'status']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.modified'));
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
},
|
||||
*document_rm({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_rm, {
|
||||
doc_id: payload.doc_id,
|
||||
});
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.deleted'));
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_rename({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_rename,
|
||||
omit(payload, ['kb_id']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.renamed'));
|
||||
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
|
||||
return retcode;
|
||||
},
|
||||
*document_create({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_create, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_run({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_run,
|
||||
omit(payload, ['knowledgeBaseId']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
if (payload.knowledgeBaseId) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.knowledgeBaseId },
|
||||
});
|
||||
}
|
||||
message.success(i18n.t('message.operated'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*document_change_parser({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
kbService.document_change_parser,
|
||||
omit(payload, ['kb_id']),
|
||||
);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
|
||||
message.success(i18n.t('message.modified'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*fetch_document_thumbnails({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.document_thumbnails, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setFileThumbnails', payload: data.data });
|
||||
}
|
||||
},
|
||||
*fetch_document_file({ payload = {} }, { call }) {
|
||||
const documentId = payload;
|
||||
try {
|
||||
const ret = yield call(getDocumentFile, documentId);
|
||||
return ret;
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
}
|
||||
},
|
||||
*upload_document({ payload = {} }, { call, put }) {
|
||||
const fileList = payload.fileList;
|
||||
const formData = new FormData();
|
||||
formData.append('kb_id', payload.kb_id);
|
||||
fileList.forEach((file: any) => {
|
||||
formData.append('file', file);
|
||||
});
|
||||
|
||||
const { data } = yield call(kbService.document_upload, formData);
|
||||
|
||||
const succeed = data.retcode === 0;
|
||||
|
||||
if (succeed) {
|
||||
message.success(i18n.t('message.uploaded'));
|
||||
}
|
||||
if (succeed || data.retcode === 500) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*web_crawl({ payload = {} }, { call, put }) {
|
||||
const formData = new FormData();
|
||||
formData.append('name', payload.name);
|
||||
formData.append('url', payload.url);
|
||||
formData.append('kb_id', payload.kb_id);
|
||||
|
||||
const { data } = yield call(kbService.web_crawl, formData);
|
||||
|
||||
const succeed = data.retcode === 0;
|
||||
|
||||
if (succeed) {
|
||||
message.success(i18n.t('message.uploaded'));
|
||||
}
|
||||
if (succeed || data.retcode === 500) {
|
||||
yield put({
|
||||
type: 'getKfList',
|
||||
payload: { kb_id: payload.kb_id },
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ location }) => {
|
||||
const state: { from: string } = (location.state ?? {
|
||||
from: '',
|
||||
}) as { from: string };
|
||||
if (
|
||||
state.from === '/knowledge' || // TODO: Just directly determine whether the current page is on the knowledge list page.
|
||||
location.pathname === '/knowledge/dataset/upload'
|
||||
) {
|
||||
dispatch({
|
||||
type: 'setPagination',
|
||||
payload: { current: 1, pageSize: 10 },
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useShowDeleteConfirm, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useRemoveDocument } from '@/hooks/documentHooks';
|
||||
import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
|
||||
import { useRemoveDocument } from '@/hooks/document-hooks';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { api_host } from '@/utils/api';
|
||||
import { downloadFile } from '@/utils/fileUtil';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ReactComponent as CancelIcon } from '@/assets/svg/cancel.svg';
|
||||
import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg';
|
||||
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
import React from 'react';
|
||||
import {useTranslate} from "@/hooks/commonHooks";
|
||||
|
||||
|
||||
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
||||
loading: boolean;
|
||||
@ -36,14 +35,28 @@ const WebCrawlModal: React.FC<IProps> = ({ visible, hideModal, onOk }) => {
|
||||
<Form.Item
|
||||
label="Name"
|
||||
name="name"
|
||||
rules={[{ required: true, message: 'Please input name!' },{ max: 10, message: 'The maximum length of name is 128 characters' }]}
|
||||
rules={[
|
||||
{ required: true, message: 'Please input name!' },
|
||||
{
|
||||
max: 10,
|
||||
message: 'The maximum length of name is 128 characters',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder="Document name" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="URL"
|
||||
name="url"
|
||||
rules={[{ required: true, message: 'Please input url!' },{pattern: new RegExp('(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]'), message: 'Please enter a valid URL!'}]}
|
||||
rules={[
|
||||
{ required: true, message: 'Please input url!' },
|
||||
{
|
||||
pattern: new RegExp(
|
||||
'(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]',
|
||||
),
|
||||
message: 'Please enter a valid URL!',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder="https://www.baidu.com" />
|
||||
</Form.Item>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSelectParserList } from '@/hooks/userSettingHook';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
||||
import { Col, Divider, Empty, Row, Typography } from 'antd';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
@ -11,7 +11,7 @@ import MaxTokenNumber from '@/components/max-token-number';
|
||||
import ParseConfiguration, {
|
||||
showRaptorParseConfiguration,
|
||||
} from '@/components/parse-configuration';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
import styles from './index.less';
|
||||
|
||||
|
||||
@ -3,14 +3,14 @@ import {
|
||||
useKnowledgeBaseId,
|
||||
useSelectKnowledgeDetails,
|
||||
useUpdateKnowledge,
|
||||
} from '@/hooks/knowledgeHook';
|
||||
import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks';
|
||||
import { useNavigateToDataset } from '@/hooks/routeHook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
} from '@/hooks/knowledge-hooks';
|
||||
import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llm-hooks';
|
||||
import { useNavigateToDataset } from '@/hooks/route-hook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import {
|
||||
useFetchTenantInfo,
|
||||
useSelectParserList,
|
||||
} from '@/hooks/userSettingHook';
|
||||
} from '@/hooks/user-setting-hooks';
|
||||
import {
|
||||
getBase64FromUploadFileList,
|
||||
getUploadFileListFromBase64,
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
import { Col, Divider, Row, Spin, Typography } from 'antd';
|
||||
import CategoryPanel from './category-panel';
|
||||
import ConfigurationForm from './configuration';
|
||||
import {
|
||||
useHandleChunkMethodChange,
|
||||
useSelectKnowledgeDetailsLoading,
|
||||
} from './hooks';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
const Configuration = () => {
|
||||
const loading = useSelectKnowledgeDetailsLoading();
|
||||
const { form, chunkMethod } = useHandleChunkMethodChange();
|
||||
const { t } = useTranslate('knowledgeConfiguration');
|
||||
|
||||
return (
|
||||
<div className={styles.configurationWrapper}>
|
||||
<Title level={5}>
|
||||
{t('configuration', { keyPrefix: 'knowledgeDetails' })}
|
||||
</Title>
|
||||
<p>{t('titleDescription')}</p>
|
||||
<Divider></Divider>
|
||||
<Spin spinning={loading}>
|
||||
<Row gutter={32}>
|
||||
<Col span={8}>
|
||||
<ConfigurationForm form={form}></ConfigurationForm>
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
<CategoryPanel chunkMethod={chunkMethod}></CategoryPanel>
|
||||
</Col>
|
||||
</Row>
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Configuration;
|
||||
import { Col, Divider, Row, Spin, Typography } from 'antd';
|
||||
import CategoryPanel from './category-panel';
|
||||
import ConfigurationForm from './configuration';
|
||||
import {
|
||||
useHandleChunkMethodChange,
|
||||
useSelectKnowledgeDetailsLoading,
|
||||
} from './hooks';
|
||||
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
const Configuration = () => {
|
||||
const loading = useSelectKnowledgeDetailsLoading();
|
||||
const { form, chunkMethod } = useHandleChunkMethodChange();
|
||||
const { t } = useTranslate('knowledgeConfiguration');
|
||||
|
||||
return (
|
||||
<div className={styles.configurationWrapper}>
|
||||
<Title level={5}>
|
||||
{t('configuration', { keyPrefix: 'knowledgeDetails' })}
|
||||
</Title>
|
||||
<p>{t('titleDescription')}</p>
|
||||
<Divider></Divider>
|
||||
<Spin spinning={loading}>
|
||||
<Row gutter={32}>
|
||||
<Col span={8}>
|
||||
<ConfigurationForm form={form}></ConfigurationForm>
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
<CategoryPanel chunkMethod={chunkMethod}></CategoryPanel>
|
||||
</Col>
|
||||
</Row>
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Configuration;
|
||||
|
||||
@ -1,57 +1,57 @@
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import i18n from '@/locales/config';
|
||||
import kbService from '@/services/kbService';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KSModelState {
|
||||
isShowPSwModal: boolean;
|
||||
tenantIfo: any;
|
||||
knowledgeDetails: IKnowledge;
|
||||
}
|
||||
|
||||
const model: DvaModel<KSModelState> = {
|
||||
namespace: 'kSModel',
|
||||
state: {
|
||||
isShowPSwModal: false,
|
||||
tenantIfo: {},
|
||||
knowledgeDetails: {} as any,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
setKnowledgeDetails(state, { payload }) {
|
||||
return { ...state, knowledgeDetails: payload };
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*createKb({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.createKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*updateKb({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.updateKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({ type: 'getKbDetail', payload: { kb_id: payload.kb_id } });
|
||||
message.success(i18n.t('message.updated'));
|
||||
}
|
||||
},
|
||||
*getKbDetail({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setKnowledgeDetails', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import i18n from '@/locales/config';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KSModelState {
|
||||
isShowPSwModal: boolean;
|
||||
tenantIfo: any;
|
||||
knowledgeDetails: IKnowledge;
|
||||
}
|
||||
|
||||
const model: DvaModel<KSModelState> = {
|
||||
namespace: 'kSModel',
|
||||
state: {
|
||||
isShowPSwModal: false,
|
||||
tenantIfo: {},
|
||||
knowledgeDetails: {} as any,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
setKnowledgeDetails(state, { payload }) {
|
||||
return { ...state, knowledgeDetails: payload };
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*createKb({ payload = {} }, { call }) {
|
||||
const { data } = yield call(kbService.createKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*updateKb({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.updateKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({ type: 'getKbDetail', payload: { kb_id: payload.kb_id } });
|
||||
message.success(i18n.t('message.updated'));
|
||||
}
|
||||
},
|
||||
*getKbDetail({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setKnowledgeDetails', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { ReactComponent as ConfigurationIcon } from '@/assets/svg/knowledge-configration.svg';
|
||||
import { ReactComponent as DatasetIcon } from '@/assets/svg/knowledge-dataset.svg';
|
||||
import { ReactComponent as TestingIcon } from '@/assets/svg/knowledge-testing.svg';
|
||||
import { useFetchKnowledgeBaseConfiguration } from '@/hooks/knowledgeHook';
|
||||
import { useSecondPathName } from '@/hooks/routeHook';
|
||||
import { useFetchKnowledgeBaseConfiguration } from '@/hooks/knowledge-hooks';
|
||||
import { useSecondPathName } from '@/hooks/route-hook';
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import { getWidth } from '@/utils';
|
||||
import { Avatar, Menu, MenuProps, Space } from 'antd';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTestChunkRetrieval } from '@/hooks/knowledgeHook';
|
||||
import { useTestChunkRetrieval } from '@/hooks/knowledge-hooks';
|
||||
import { Flex, Form } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
import { useDispatch } from 'umi';
|
||||
|
||||
@ -3,7 +3,7 @@ import {
|
||||
ITestingChunk,
|
||||
ITestingDocument,
|
||||
} from '@/interfaces/database/knowledge';
|
||||
import kbService from '@/services/kbService';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface TestingModelState extends Pick<BaseState, 'pagination'> {
|
||||
|
||||
@ -3,9 +3,9 @@ import { Button, Card, Divider, Flex, Form, Input } from 'antd';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
|
||||
import Rerank from '@/components/rerank';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useFetchLlmList } from '@/hooks/llmHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchLlmList } from '@/hooks/llm-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { useEffect } from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ReactComponent as SelectedFilesCollapseIcon } from '@/assets/svg/selected-files-collapse.svg';
|
||||
import Image from '@/components/image';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { ITestingChunk } from '@/interfaces/database/knowledge';
|
||||
import {
|
||||
Card,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
|
||||
import NewDocumentLink from '@/components/new-document-link';
|
||||
import { useGetDocumentUrl } from '@/hooks/documentHooks';
|
||||
import { useGetDocumentUrl } from '@/hooks/document-hooks';
|
||||
import { ITestingDocument } from '@/interfaces/database/knowledge';
|
||||
import { isPdf } from '@/utils/documentUtils';
|
||||
import { Table, TableProps } from 'antd';
|
||||
|
||||
@ -1,93 +1,93 @@
|
||||
import { useKnowledgeBaseId } from '@/hooks/knowledgeHook';
|
||||
import {
|
||||
useNavigateWithFromState,
|
||||
useSecondPathName,
|
||||
useThirdPathName,
|
||||
} from '@/hooks/routeHook';
|
||||
import { Breadcrumb } from 'antd';
|
||||
import { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, Outlet, useDispatch, useLocation } from 'umi';
|
||||
import Siderbar from './components/knowledge-sidebar';
|
||||
import { KnowledgeDatasetRouteKey, KnowledgeRouteKey } from './constant';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeAdding = () => {
|
||||
const dispatch = useDispatch();
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
const activeKey: KnowledgeRouteKey =
|
||||
(useSecondPathName() as KnowledgeRouteKey) || KnowledgeRouteKey.Dataset;
|
||||
|
||||
const datasetActiveKey: KnowledgeDatasetRouteKey =
|
||||
useThirdPathName() as KnowledgeDatasetRouteKey;
|
||||
|
||||
const gotoList = useNavigateWithFromState();
|
||||
|
||||
const breadcrumbItems: ItemType[] = useMemo(() => {
|
||||
const items: ItemType[] = [
|
||||
{
|
||||
title: (
|
||||
<a onClick={() => gotoList('/knowledge')}>
|
||||
{t('header.knowledgeBase')}
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: datasetActiveKey ? (
|
||||
<Link
|
||||
to={`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeBaseId}`}
|
||||
>
|
||||
{t(`knowledgeDetails.${activeKey}`)}
|
||||
</Link>
|
||||
) : (
|
||||
t(`knowledgeDetails.${activeKey}`)
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
if (datasetActiveKey) {
|
||||
items.push({
|
||||
title: t(`knowledgeDetails.${datasetActiveKey}`),
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [activeKey, datasetActiveKey, gotoList, knowledgeBaseId, t]);
|
||||
|
||||
useEffect(() => {
|
||||
const search: string = location.search.slice(1);
|
||||
const map = search.split('&').reduce<Record<string, string>>((obj, cur) => {
|
||||
const [key, value] = cur.split('=');
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
dispatch({
|
||||
type: 'kAModel/updateState',
|
||||
payload: {
|
||||
doc_id: undefined,
|
||||
...map,
|
||||
},
|
||||
});
|
||||
}, [location, dispatch]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.container}>
|
||||
<Siderbar></Siderbar>
|
||||
<div className={styles.contentWrapper}>
|
||||
<Breadcrumb items={breadcrumbItems} />
|
||||
<div className={styles.content}>
|
||||
<Outlet></Outlet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default KnowledgeAdding;
|
||||
import { useKnowledgeBaseId } from '@/hooks/knowledge-hooks';
|
||||
import {
|
||||
useNavigateWithFromState,
|
||||
useSecondPathName,
|
||||
useThirdPathName,
|
||||
} from '@/hooks/route-hook';
|
||||
import { Breadcrumb } from 'antd';
|
||||
import { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, Outlet, useDispatch, useLocation } from 'umi';
|
||||
import Siderbar from './components/knowledge-sidebar';
|
||||
import { KnowledgeDatasetRouteKey, KnowledgeRouteKey } from './constant';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeAdding = () => {
|
||||
const dispatch = useDispatch();
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
const activeKey: KnowledgeRouteKey =
|
||||
(useSecondPathName() as KnowledgeRouteKey) || KnowledgeRouteKey.Dataset;
|
||||
|
||||
const datasetActiveKey: KnowledgeDatasetRouteKey =
|
||||
useThirdPathName() as KnowledgeDatasetRouteKey;
|
||||
|
||||
const gotoList = useNavigateWithFromState();
|
||||
|
||||
const breadcrumbItems: ItemType[] = useMemo(() => {
|
||||
const items: ItemType[] = [
|
||||
{
|
||||
title: (
|
||||
<a onClick={() => gotoList('/knowledge')}>
|
||||
{t('header.knowledgeBase')}
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: datasetActiveKey ? (
|
||||
<Link
|
||||
to={`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeBaseId}`}
|
||||
>
|
||||
{t(`knowledgeDetails.${activeKey}`)}
|
||||
</Link>
|
||||
) : (
|
||||
t(`knowledgeDetails.${activeKey}`)
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
if (datasetActiveKey) {
|
||||
items.push({
|
||||
title: t(`knowledgeDetails.${datasetActiveKey}`),
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [activeKey, datasetActiveKey, gotoList, knowledgeBaseId, t]);
|
||||
|
||||
useEffect(() => {
|
||||
const search: string = location.search.slice(1);
|
||||
const map = search.split('&').reduce<Record<string, string>>((obj, cur) => {
|
||||
const [key, value] = cur.split('=');
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
dispatch({
|
||||
type: 'kAModel/updateState',
|
||||
payload: {
|
||||
doc_id: undefined,
|
||||
...map,
|
||||
},
|
||||
});
|
||||
}, [location, dispatch]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.container}>
|
||||
<Siderbar></Siderbar>
|
||||
<div className={styles.contentWrapper}>
|
||||
<Breadcrumb items={breadcrumbItems} />
|
||||
<div className={styles.content}>
|
||||
<Outlet></Outlet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default KnowledgeAdding;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import CopyToClipboard from '@/components/copy-to-clipboard';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IToken } from '@/interfaces/database/chat';
|
||||
import { formatDate } from '@/utils/date';
|
||||
|
||||
@ -4,7 +4,7 @@ import classNames from 'classnames';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import KnowledgeBaseItem from '@/components/knowledge-base-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
||||
|
||||
@ -14,7 +14,7 @@ import AssistantSetting from './assistant-setting';
|
||||
import ModelSetting from './model-setting';
|
||||
import PromptEngine from './prompt-engine';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useFetchLlmModelOnVisible,
|
||||
useFetchModelId,
|
||||
|
||||
@ -30,7 +30,7 @@ import { EditableCell, EditableRow } from './editable-cell';
|
||||
|
||||
import Rerank from '@/components/rerank';
|
||||
import TopNItem from '@/components/top-n-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useSelectPromptConfigParameters } from '../hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import MessageItem from '@/components/message-item';
|
||||
import DocumentPreviewer from '@/components/pdf-previewer';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Button, Drawer, Flex, Input, Spin } from 'antd';
|
||||
import {
|
||||
useClickDrawer,
|
||||
@ -14,7 +14,7 @@ import {
|
||||
} from '../hooks';
|
||||
import { buildMessageItemReference } from '../utils';
|
||||
|
||||
import { useSelectUserInfo } from '@/hooks/userSettingHook';
|
||||
import { useSelectUserInfo } from '@/hooks/user-setting-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const ChatContainer = () => {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import LineChart from '@/components/line-chart';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IDialog, IStats } from '@/interfaces/database/chat';
|
||||
import { formatDate } from '@/utils/date';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import CopyToClipboard from '@/components/copy-to-clipboard';
|
||||
import HightLightMarkdown from '@/components/highlight-markdown';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { Card, Modal, Tabs, TabsProps } from 'antd';
|
||||
import styles from './index.less';
|
||||
|
||||
@ -17,14 +17,14 @@ import {
|
||||
useSelectTokenList,
|
||||
useSetDialog,
|
||||
useUpdateConversation,
|
||||
} from '@/hooks/chatHooks';
|
||||
} from '@/hooks/chat-hooks';
|
||||
import {
|
||||
useSetModalState,
|
||||
useShowDeleteConfirm,
|
||||
useTranslate,
|
||||
} from '@/hooks/commonHooks';
|
||||
} from '@/hooks/common-hooks';
|
||||
import { useSendMessageWithSse } from '@/hooks/logic-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import {
|
||||
IAnswer,
|
||||
IConversation,
|
||||
|
||||
@ -41,7 +41,7 @@ import {
|
||||
useSelectFirstDialogOnMount,
|
||||
} from './hooks';
|
||||
|
||||
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
||||
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
||||
import { IDialog } from '@/interfaces/database/chat';
|
||||
import ChatOverviewModal from './chat-overview-modal';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Image from '@/components/image';
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useSelectFileThumbnails } from '@/hooks/knowledgeHook';
|
||||
import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
|
||||
import { IReference } from '@/interfaces/database/chat';
|
||||
import { IChunk } from '@/interfaces/database/knowledge';
|
||||
import { getExtension } from '@/utils/documentUtils';
|
||||
|
||||
@ -1,262 +1,262 @@
|
||||
import {
|
||||
IConversation,
|
||||
IDialog,
|
||||
IStats,
|
||||
IToken,
|
||||
Message,
|
||||
} from '@/interfaces/database/chat';
|
||||
import i18n from '@/locales/config';
|
||||
import chatService from '@/services/chatService';
|
||||
import { message } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
import { DvaModel } from 'umi';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { IClientConversation, IMessage } from './interface';
|
||||
import { getDocumentIdsFromConversionReference } from './utils';
|
||||
|
||||
export interface ChatModelState {
|
||||
name: string;
|
||||
dialogList: IDialog[];
|
||||
currentDialog: IDialog;
|
||||
conversationList: IConversation[];
|
||||
currentConversation: IClientConversation;
|
||||
tokenList: IToken[];
|
||||
stats: IStats;
|
||||
}
|
||||
|
||||
const model: DvaModel<ChatModelState> = {
|
||||
namespace: 'chatModel',
|
||||
state: {
|
||||
name: 'kate',
|
||||
dialogList: [],
|
||||
currentDialog: <IDialog>{},
|
||||
conversationList: [],
|
||||
currentConversation: {} as IClientConversation,
|
||||
tokenList: [],
|
||||
stats: {} as IStats,
|
||||
},
|
||||
reducers: {
|
||||
save(state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload,
|
||||
};
|
||||
},
|
||||
setDialogList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
dialogList: payload,
|
||||
};
|
||||
},
|
||||
setCurrentDialog(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
currentDialog: payload,
|
||||
};
|
||||
},
|
||||
setConversationList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
conversationList: payload,
|
||||
};
|
||||
},
|
||||
setCurrentConversation(state, { payload }) {
|
||||
const messageList =
|
||||
payload?.message?.map((x: Message | IMessage) => ({
|
||||
...x,
|
||||
id: 'id' in x ? x.id : uuid(),
|
||||
})) ?? [];
|
||||
return {
|
||||
...state,
|
||||
currentConversation: { ...payload, message: messageList },
|
||||
};
|
||||
},
|
||||
setTokenList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
tokenList: payload,
|
||||
};
|
||||
},
|
||||
setStats(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
stats: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
*getDialog({ payload }, { call, put }) {
|
||||
const needToBeSaved =
|
||||
payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
|
||||
const { data } = yield call(chatService.getDialog, {
|
||||
dialog_id: payload.dialog_id,
|
||||
});
|
||||
if (data.retcode === 0 && needToBeSaved) {
|
||||
yield put({ type: 'setCurrentDialog', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*setDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'listDialog' });
|
||||
message.success(
|
||||
i18n.t(`message.${payload.dialog_id ? 'modified' : 'created'}`),
|
||||
);
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*removeDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.removeDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'listDialog' });
|
||||
message.success(i18n.t('message.deleted'));
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*listDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setDialogList', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*listConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listConversation, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setConversationList', payload: data.data });
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*getConversation({ payload }, { call, put }) {
|
||||
const needToBeSaved =
|
||||
payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
|
||||
const { data } = yield call(chatService.getConversation, {
|
||||
conversation_id: payload.conversation_id,
|
||||
});
|
||||
if (data.retcode === 0 && needToBeSaved) {
|
||||
yield put({
|
||||
type: 'kFModel/fetch_document_thumbnails',
|
||||
payload: {
|
||||
doc_ids: getDocumentIdsFromConversionReference(data.data),
|
||||
},
|
||||
});
|
||||
yield put({ type: 'setCurrentConversation', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*setConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setConversation, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listConversation',
|
||||
payload: {
|
||||
dialog_id: data.data.dialog_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*completeConversation({ payload }, { call }) {
|
||||
const { data } = yield call(chatService.completeConversation, payload);
|
||||
// if (data.retcode === 0) {
|
||||
// yield put({
|
||||
// type: 'getConversation',
|
||||
// payload: {
|
||||
// conversation_id: payload.conversation_id,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
return data.retcode;
|
||||
},
|
||||
*removeConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.removeConversation, {
|
||||
conversation_ids: payload.conversation_ids,
|
||||
});
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listConversation',
|
||||
payload: { dialog_id: payload.dialog_id },
|
||||
});
|
||||
message.success(i18n.t('message.deleted'));
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*createToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.createToken, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listToken',
|
||||
payload: payload,
|
||||
});
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*listToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listToken, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'setTokenList',
|
||||
payload: data.data,
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*removeToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
chatService.removeToken,
|
||||
omit(payload, ['dialogId']),
|
||||
);
|
||||
if (data.retcode === 0) {
|
||||
message.success(i18n.t('message.deleted'));
|
||||
yield put({
|
||||
type: 'listToken',
|
||||
payload: { dialog_id: payload.dialogId },
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*getStats({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.getStats, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'setStats',
|
||||
payload: data.data,
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*createExternalConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
chatService.createExternalConversation,
|
||||
payload,
|
||||
);
|
||||
// if (data.retcode === 0) {
|
||||
// yield put({
|
||||
// type: 'getExternalConversation',
|
||||
// payload: data.data.id,
|
||||
// });
|
||||
// }
|
||||
return data;
|
||||
},
|
||||
*getExternalConversation({ payload }, { call }) {
|
||||
const { data } = yield call(
|
||||
chatService.getExternalConversation,
|
||||
null,
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
},
|
||||
*completeExternalConversation({ payload }, { call }) {
|
||||
const { data } = yield call(
|
||||
chatService.completeExternalConversation,
|
||||
payload,
|
||||
);
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default model;
|
||||
import {
|
||||
IConversation,
|
||||
IDialog,
|
||||
IStats,
|
||||
IToken,
|
||||
Message,
|
||||
} from '@/interfaces/database/chat';
|
||||
import i18n from '@/locales/config';
|
||||
import chatService from '@/services/chat-service';
|
||||
import { message } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
import { DvaModel } from 'umi';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { IClientConversation, IMessage } from './interface';
|
||||
import { getDocumentIdsFromConversionReference } from './utils';
|
||||
|
||||
export interface ChatModelState {
|
||||
name: string;
|
||||
dialogList: IDialog[];
|
||||
currentDialog: IDialog;
|
||||
conversationList: IConversation[];
|
||||
currentConversation: IClientConversation;
|
||||
tokenList: IToken[];
|
||||
stats: IStats;
|
||||
}
|
||||
|
||||
const model: DvaModel<ChatModelState> = {
|
||||
namespace: 'chatModel',
|
||||
state: {
|
||||
name: 'kate',
|
||||
dialogList: [],
|
||||
currentDialog: <IDialog>{},
|
||||
conversationList: [],
|
||||
currentConversation: {} as IClientConversation,
|
||||
tokenList: [],
|
||||
stats: {} as IStats,
|
||||
},
|
||||
reducers: {
|
||||
save(state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload,
|
||||
};
|
||||
},
|
||||
setDialogList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
dialogList: payload,
|
||||
};
|
||||
},
|
||||
setCurrentDialog(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
currentDialog: payload,
|
||||
};
|
||||
},
|
||||
setConversationList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
conversationList: payload,
|
||||
};
|
||||
},
|
||||
setCurrentConversation(state, { payload }) {
|
||||
const messageList =
|
||||
payload?.message?.map((x: Message | IMessage) => ({
|
||||
...x,
|
||||
id: 'id' in x ? x.id : uuid(),
|
||||
})) ?? [];
|
||||
return {
|
||||
...state,
|
||||
currentConversation: { ...payload, message: messageList },
|
||||
};
|
||||
},
|
||||
setTokenList(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
tokenList: payload,
|
||||
};
|
||||
},
|
||||
setStats(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
stats: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
*getDialog({ payload }, { call, put }) {
|
||||
const needToBeSaved =
|
||||
payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
|
||||
const { data } = yield call(chatService.getDialog, {
|
||||
dialog_id: payload.dialog_id,
|
||||
});
|
||||
if (data.retcode === 0 && needToBeSaved) {
|
||||
yield put({ type: 'setCurrentDialog', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*setDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'listDialog' });
|
||||
message.success(
|
||||
i18n.t(`message.${payload.dialog_id ? 'modified' : 'created'}`),
|
||||
);
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*removeDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.removeDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'listDialog' });
|
||||
message.success(i18n.t('message.deleted'));
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*listDialog({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listDialog, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setDialogList', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*listConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listConversation, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setConversationList', payload: data.data });
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*getConversation({ payload }, { call, put }) {
|
||||
const needToBeSaved =
|
||||
payload.needToBeSaved === undefined ? true : payload.needToBeSaved;
|
||||
const { data } = yield call(chatService.getConversation, {
|
||||
conversation_id: payload.conversation_id,
|
||||
});
|
||||
if (data.retcode === 0 && needToBeSaved) {
|
||||
yield put({
|
||||
type: 'kFModel/fetch_document_thumbnails',
|
||||
payload: {
|
||||
doc_ids: getDocumentIdsFromConversionReference(data.data),
|
||||
},
|
||||
});
|
||||
yield put({ type: 'setCurrentConversation', payload: data.data });
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*setConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.setConversation, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listConversation',
|
||||
payload: {
|
||||
dialog_id: data.data.dialog_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*completeConversation({ payload }, { call }) {
|
||||
const { data } = yield call(chatService.completeConversation, payload);
|
||||
// if (data.retcode === 0) {
|
||||
// yield put({
|
||||
// type: 'getConversation',
|
||||
// payload: {
|
||||
// conversation_id: payload.conversation_id,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
return data.retcode;
|
||||
},
|
||||
*removeConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.removeConversation, {
|
||||
conversation_ids: payload.conversation_ids,
|
||||
});
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listConversation',
|
||||
payload: { dialog_id: payload.dialog_id },
|
||||
});
|
||||
message.success(i18n.t('message.deleted'));
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*createToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.createToken, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'listToken',
|
||||
payload: payload,
|
||||
});
|
||||
message.success(i18n.t('message.created'));
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*listToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.listToken, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'setTokenList',
|
||||
payload: data.data,
|
||||
});
|
||||
}
|
||||
return data;
|
||||
},
|
||||
*removeToken({ payload }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
chatService.removeToken,
|
||||
omit(payload, ['dialogId']),
|
||||
);
|
||||
if (data.retcode === 0) {
|
||||
message.success(i18n.t('message.deleted'));
|
||||
yield put({
|
||||
type: 'listToken',
|
||||
payload: { dialog_id: payload.dialogId },
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*getStats({ payload }, { call, put }) {
|
||||
const { data } = yield call(chatService.getStats, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({
|
||||
type: 'setStats',
|
||||
payload: data.data,
|
||||
});
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
*createExternalConversation({ payload }, { call, put }) {
|
||||
const { data } = yield call(
|
||||
chatService.createExternalConversation,
|
||||
payload,
|
||||
);
|
||||
// if (data.retcode === 0) {
|
||||
// yield put({
|
||||
// type: 'getExternalConversation',
|
||||
// payload: data.data.id,
|
||||
// });
|
||||
// }
|
||||
return data;
|
||||
},
|
||||
*getExternalConversation({ payload }, { call }) {
|
||||
const { data } = yield call(
|
||||
chatService.getExternalConversation,
|
||||
null,
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
},
|
||||
*completeExternalConversation({ payload }, { call }) {
|
||||
const { data } = yield call(
|
||||
chatService.completeExternalConversation,
|
||||
payload,
|
||||
);
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default model;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import MessageItem from '@/components/message-item';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
||||
import { Button, Flex, Input, Spin } from 'antd';
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
@ -2,9 +2,9 @@ import { MessageType } from '@/constants/chat';
|
||||
import {
|
||||
useCreateSharedConversation,
|
||||
useFetchSharedConversation,
|
||||
} from '@/hooks/chatHooks';
|
||||
} from '@/hooks/chat-hooks';
|
||||
import { useSendMessageWithSse } from '@/hooks/logic-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { IAnswer } from '@/interfaces/database/chat';
|
||||
import api from '@/utils/api';
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Alert, Flex } from 'antd';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import React from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { api_host } from '@/utils/api';
|
||||
import { downloadFile } from '@/utils/fileUtil';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { filterOptionsByInput } from '@/utils/commonUtil';
|
||||
import { Form, Modal, Select } from 'antd';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ReactComponent as DeleteIcon } from '@/assets/svg/delete.svg';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import {
|
||||
DownOutlined,
|
||||
FileTextOutlined,
|
||||
@ -26,7 +26,7 @@ import {
|
||||
useSelectBreadcrumbItems,
|
||||
} from './hooks';
|
||||
|
||||
import { useSelectParentFolderList } from '@/hooks/fileManagerHooks';
|
||||
import { useSelectParentFolderList } from '@/hooks/file-manager-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
interface IProps {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
|
||||
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useConnectToKnowledge,
|
||||
useCreateFolder,
|
||||
@ -9,9 +9,9 @@ import {
|
||||
useSelectFileList,
|
||||
useSelectParentFolderList,
|
||||
useUploadFile,
|
||||
} from '@/hooks/fileManagerHooks';
|
||||
} from '@/hooks/file-manager-hooks';
|
||||
import { useGetPagination, useSetPagination } from '@/hooks/logic-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { PaginationProps } from 'antd';
|
||||
import { TableRowSelection } from 'antd/es/table/interface';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSelectFileList } from '@/hooks/fileManagerHooks';
|
||||
import { useSelectFileList } from '@/hooks/file-manager-hooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { formatDate } from '@/utils/date';
|
||||
import { Button, Flex, Space, Table, Tag, Typography } from 'antd';
|
||||
@ -19,7 +19,7 @@ import {
|
||||
import FileUploadModal from '@/components/file-upload-modal';
|
||||
import RenameModal from '@/components/rename-modal';
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { formatNumberWithThousandsSeparator } from '@/utils/commonUtil';
|
||||
import { getExtension } from '@/utils/documentUtils';
|
||||
import ConnectToKnowledgeModal from './connect-to-knowledge-modal';
|
||||
|
||||
@ -4,7 +4,7 @@ import { IFile, IFolder } from '@/interfaces/database/file-manager';
|
||||
import i18n from '@/locales/config';
|
||||
import fileManagerService, {
|
||||
getDocumentFile,
|
||||
} from '@/services/fileManagerService';
|
||||
} from '@/services/file-manager-service';
|
||||
import { message } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input } from 'antd';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Flex } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import lowerFirst from 'lodash/lowerFirst';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Flex } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import { pick } from 'lodash';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Flex } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import lowerFirst from 'lodash/lowerFirst';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Flex } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import lowerFirst from 'lodash/lowerFirst';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { CloseOutlined } from '@ant-design/icons';
|
||||
import { Button, Card, Form, FormListFieldData, Input, Select } from 'antd';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import LLMSelect from '@/components/llm-select';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form } from 'antd';
|
||||
import { useSetLlmSetting } from '../hooks';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import MessageItem from '@/components/message-item';
|
||||
import DocumentPreviewer from '@/components/pdf-previewer';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useClickDrawer, useGetFileIcon } from '@/pages/chat/hooks';
|
||||
import { buildMessageItemReference } from '@/pages/chat/utils';
|
||||
import { Button, Drawer, Flex, Input, Spin } from 'antd';
|
||||
|
||||
import { useSelectCurrentMessages, useSendMessage } from './hooks';
|
||||
|
||||
import { useSelectUserInfo } from '@/hooks/userSettingHook';
|
||||
import { useSelectUserInfo } from '@/hooks/user-setting-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const FlowChatBox = () => {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import TopNItem from '@/components/top-n-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Select } from 'antd';
|
||||
import { useMemo } from 'react';
|
||||
import { Channel } from '../constant';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { Drawer, Flex, Form, Input } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Card, Divider, Flex, Layout, Tooltip } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import lowerFirst from 'lodash/lowerFirst';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { EditableCell, EditableRow } from '@/components/editable-cell';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { DeleteOutlined } from '@ant-design/icons';
|
||||
import { Button, Flex, Select, Table, TableProps } from 'antd';
|
||||
import { IGenerateParameter } from '../interface';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import LLMSelect from '@/components/llm-select';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input, InputNumber, Switch } from 'antd';
|
||||
import { useSetLlmSetting } from '../hooks';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchFlow } from '@/hooks/flow-hooks';
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons';
|
||||
import { Button, Flex, Space } from 'antd';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useSetModalState } from '@/hooks/commonHooks';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { useFetchFlow, useResetFlow, useSetFlow } from '@/hooks/flow-hooks';
|
||||
import { useFetchLlmList } from '@/hooks/llmHooks';
|
||||
import { useFetchLlmList } from '@/hooks/llm-hooks';
|
||||
import { IGraph } from '@/interfaces/database/flow';
|
||||
import { useIsFetching } from '@tanstack/react-query';
|
||||
import React, {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSetModalState } from '@/hooks/commonHooks';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { Layout } from 'antd';
|
||||
import { useState } from 'react';
|
||||
import { ReactFlowProvider } from 'reactflow';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import LLMSelect from '@/components/llm-select';
|
||||
import TopNItem from '@/components/top-n-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form } from 'antd';
|
||||
import { useSetLlmSetting } from '../hooks';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
|
||||
import { useSelectItem } from '@/hooks/logic-hooks';
|
||||
import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSetModalState } from '@/hooks/commonHooks';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useFetchFlowList,
|
||||
useFetchFlowTemplates,
|
||||
|
||||
@ -4,7 +4,7 @@ import CreateFlowModal from './create-flow-modal';
|
||||
import FlowCard from './flow-card';
|
||||
import { useFetchDataOnMount, useSaveFlow } from './hooks';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const FlowList = () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { Button, Form, Input } from 'antd';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import LLMSelect from '@/components/llm-select';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Select } from 'antd';
|
||||
import { Operator } from '../constant';
|
||||
import { useBuildFormSelectOptions } from '../form-hooks';
|
||||
|
||||
@ -2,7 +2,7 @@ import KnowledgeBaseItem from '@/components/knowledge-base-item';
|
||||
import Rerank from '@/components/rerank';
|
||||
import SimilaritySlider from '@/components/similarity-slider';
|
||||
import TopNItem from '@/components/top-n-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import type { FormProps } from 'antd';
|
||||
import { Form, Input } from 'antd';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import LLMSelect from '@/components/llm-select';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, InputNumber } from 'antd';
|
||||
import { useSetLlmSetting } from '../hooks';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import TopNItem from '@/components/top-n-item';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Select } from 'antd';
|
||||
import { LanguageOptions } from '../constant';
|
||||
import { IOperatorForm } from '../interface';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSelectKnowledgeList } from '@/hooks/knowledgeHook';
|
||||
import { useSelectKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { useState } from 'react';
|
||||
|
||||
export const useSearchKnowledge = () => {
|
||||
|
||||
@ -1,82 +1,82 @@
|
||||
import ModalManager from '@/components/modal-manager';
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
||||
import { useSelectUserInfo } from '@/hooks/userSettingHook';
|
||||
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { Button, Empty, Flex, Input, Space, Spin } from 'antd';
|
||||
import KnowledgeCard from './knowledge-card';
|
||||
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSearchKnowledge, useSelectKnowledgeListByKeywords } from './hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeList = () => {
|
||||
const { searchString, handleInputChange } = useSearchKnowledge();
|
||||
const { loading } = useFetchKnowledgeList();
|
||||
const list = useSelectKnowledgeListByKeywords(searchString);
|
||||
const userInfo = useSelectUserInfo();
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
||||
|
||||
return (
|
||||
<Flex className={styles.knowledge} vertical flex={1}>
|
||||
<div className={styles.topWrapper}>
|
||||
<div>
|
||||
<span className={styles.title}>
|
||||
{t('welcome')}, {userInfo.nickname}
|
||||
</span>
|
||||
<p className={styles.description}>{t('description')}</p>
|
||||
</div>
|
||||
<Space size={'large'}>
|
||||
<Input
|
||||
placeholder={t('searchKnowledgePlaceholder')}
|
||||
value={searchString}
|
||||
style={{ width: 220 }}
|
||||
allowClear
|
||||
onChange={handleInputChange}
|
||||
prefix={<SearchOutlined />}
|
||||
/>
|
||||
|
||||
<ModalManager>
|
||||
{({ visible, hideModal, showModal }) => (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => {
|
||||
showModal();
|
||||
}}
|
||||
className={styles.topButton}
|
||||
>
|
||||
{t('createKnowledgeBase')}
|
||||
</Button>
|
||||
<KnowledgeCreatingModal
|
||||
visible={visible}
|
||||
hideModal={hideModal}
|
||||
></KnowledgeCreatingModal>
|
||||
</>
|
||||
)}
|
||||
</ModalManager>
|
||||
</Space>
|
||||
</div>
|
||||
<Spin spinning={loading}>
|
||||
<Flex
|
||||
gap={'large'}
|
||||
wrap="wrap"
|
||||
className={styles.knowledgeCardContainer}
|
||||
>
|
||||
{list.length > 0 ? (
|
||||
list.map((item: any) => {
|
||||
return (
|
||||
<KnowledgeCard item={item} key={item.name}></KnowledgeCard>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Empty className={styles.knowledgeEmpty}></Empty>
|
||||
)}
|
||||
</Flex>
|
||||
</Spin>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default KnowledgeList;
|
||||
import ModalManager from '@/components/modal-manager';
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { useSelectUserInfo } from '@/hooks/user-setting-hooks';
|
||||
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { Button, Empty, Flex, Input, Space, Spin } from 'antd';
|
||||
import KnowledgeCard from './knowledge-card';
|
||||
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSearchKnowledge, useSelectKnowledgeListByKeywords } from './hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeList = () => {
|
||||
const { searchString, handleInputChange } = useSearchKnowledge();
|
||||
const { loading } = useFetchKnowledgeList();
|
||||
const list = useSelectKnowledgeListByKeywords(searchString);
|
||||
const userInfo = useSelectUserInfo();
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
||||
|
||||
return (
|
||||
<Flex className={styles.knowledge} vertical flex={1}>
|
||||
<div className={styles.topWrapper}>
|
||||
<div>
|
||||
<span className={styles.title}>
|
||||
{t('welcome')}, {userInfo.nickname}
|
||||
</span>
|
||||
<p className={styles.description}>{t('description')}</p>
|
||||
</div>
|
||||
<Space size={'large'}>
|
||||
<Input
|
||||
placeholder={t('searchKnowledgePlaceholder')}
|
||||
value={searchString}
|
||||
style={{ width: 220 }}
|
||||
allowClear
|
||||
onChange={handleInputChange}
|
||||
prefix={<SearchOutlined />}
|
||||
/>
|
||||
|
||||
<ModalManager>
|
||||
{({ visible, hideModal, showModal }) => (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => {
|
||||
showModal();
|
||||
}}
|
||||
className={styles.topButton}
|
||||
>
|
||||
{t('createKnowledgeBase')}
|
||||
</Button>
|
||||
<KnowledgeCreatingModal
|
||||
visible={visible}
|
||||
hideModal={hideModal}
|
||||
></KnowledgeCreatingModal>
|
||||
</>
|
||||
)}
|
||||
</ModalManager>
|
||||
</Space>
|
||||
</div>
|
||||
<Spin spinning={loading}>
|
||||
<Flex
|
||||
gap={'large'}
|
||||
wrap="wrap"
|
||||
className={styles.knowledgeCardContainer}
|
||||
>
|
||||
{list.length > 0 ? (
|
||||
list.map((item: any) => {
|
||||
return (
|
||||
<KnowledgeCard item={item} key={item.name}></KnowledgeCard>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Empty className={styles.knowledgeEmpty}></Empty>
|
||||
)}
|
||||
</Flex>
|
||||
</Spin>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default KnowledgeList;
|
||||
|
||||
@ -1,63 +1,63 @@
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import kbService from '@/services/kbService';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KnowledgeModelState {
|
||||
data: IKnowledge[];
|
||||
knowledge: IKnowledge;
|
||||
}
|
||||
|
||||
const model: DvaModel<KnowledgeModelState> = {
|
||||
namespace: 'knowledgeModel',
|
||||
state: {
|
||||
data: [],
|
||||
knowledge: {} as IKnowledge,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
setKnowledge(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
knowledge: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*rmKb({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.rmKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getList',
|
||||
payload: {},
|
||||
});
|
||||
}
|
||||
},
|
||||
*getList({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.getList, payload);
|
||||
const { retcode, data: res } = data;
|
||||
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
data: res,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
*getKnowledgeDetail({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setKnowledge', payload: data.data });
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface KnowledgeModelState {
|
||||
data: IKnowledge[];
|
||||
knowledge: IKnowledge;
|
||||
}
|
||||
|
||||
const model: DvaModel<KnowledgeModelState> = {
|
||||
namespace: 'knowledgeModel',
|
||||
state: {
|
||||
data: [],
|
||||
knowledge: {} as IKnowledge,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
setKnowledge(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
knowledge: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*rmKb({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.rmKb, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'getList',
|
||||
payload: {},
|
||||
});
|
||||
}
|
||||
},
|
||||
*getList({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.getList, payload);
|
||||
const { retcode, data: res } = data;
|
||||
|
||||
if (retcode === 0) {
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
data: res,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
*getKnowledgeDetail({ payload = {} }, { call, put }) {
|
||||
const { data } = yield call(kbService.get_kb_detail, payload);
|
||||
if (data.retcode === 0) {
|
||||
yield put({ type: 'setKnowledge', payload: data.data });
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
|
||||
@ -1,199 +1,199 @@
|
||||
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { rsaPsw } from '@/utils';
|
||||
import { Button, Checkbox, Form, Input } from 'antd';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Icon, useNavigate } from 'umi';
|
||||
import RightPanel from './right-panel';
|
||||
|
||||
import { Domain } from '@/constants/common';
|
||||
import styles from './index.less';
|
||||
|
||||
const Login = () => {
|
||||
const [title, setTitle] = useState('login');
|
||||
const navigate = useNavigate();
|
||||
const login = useLogin();
|
||||
const register = useRegister();
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'login' });
|
||||
|
||||
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
||||
|
||||
const signLoading = useOneNamespaceEffectsLoading('loginModel', [
|
||||
'login',
|
||||
'register',
|
||||
]);
|
||||
|
||||
const changeTitle = () => {
|
||||
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
||||
};
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
form.validateFields(['nickname']);
|
||||
}, [form]);
|
||||
|
||||
const onCheck = async () => {
|
||||
try {
|
||||
const params = await form.validateFields();
|
||||
|
||||
const rsaPassWord = rsaPsw(params.password) as string;
|
||||
|
||||
if (title === 'login') {
|
||||
const retcode = await login({
|
||||
email: params.email,
|
||||
password: rsaPassWord,
|
||||
});
|
||||
if (retcode === 0) {
|
||||
navigate('/knowledge');
|
||||
}
|
||||
} else {
|
||||
const retcode = await register({
|
||||
nickname: params.nickname,
|
||||
email: params.email,
|
||||
password: rsaPassWord,
|
||||
});
|
||||
if (retcode === 0) {
|
||||
setTitle('login');
|
||||
}
|
||||
}
|
||||
} catch (errorInfo) {
|
||||
console.log('Failed:', errorInfo);
|
||||
}
|
||||
};
|
||||
const formItemLayout = {
|
||||
labelCol: { span: 6 },
|
||||
// wrapperCol: { span: 8 },
|
||||
};
|
||||
|
||||
const toGoogle = () => {
|
||||
window.location.href =
|
||||
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.loginPage}>
|
||||
<div className={styles.loginLeft}>
|
||||
<div className={styles.leftContainer}>
|
||||
<div className={styles.loginTitle}>
|
||||
<div>{title === 'login' ? t('login') : t('register')}</div>
|
||||
<span>
|
||||
{title === 'login'
|
||||
? t('loginDescription')
|
||||
: t('registerDescription')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
name="dynamic_rule"
|
||||
style={{ maxWidth: 600 }}
|
||||
>
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="email"
|
||||
label={t('emailLabel')}
|
||||
rules={[{ required: true, message: t('emailPlaceholder') }]}
|
||||
>
|
||||
<Input size="large" placeholder={t('emailPlaceholder')} />
|
||||
</Form.Item>
|
||||
{title === 'register' && (
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="nickname"
|
||||
label={t('nicknameLabel')}
|
||||
rules={[{ required: true, message: t('nicknamePlaceholder') }]}
|
||||
>
|
||||
<Input size="large" placeholder={t('nicknamePlaceholder')} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="password"
|
||||
label={t('passwordLabel')}
|
||||
rules={[{ required: true, message: t('passwordPlaceholder') }]}
|
||||
>
|
||||
<Input.Password
|
||||
size="large"
|
||||
placeholder={t('passwordPlaceholder')}
|
||||
onPressEnter={onCheck}
|
||||
/>
|
||||
</Form.Item>
|
||||
{title === 'login' && (
|
||||
<Form.Item name="remember" valuePropName="checked">
|
||||
<Checkbox> {t('rememberMe')}</Checkbox>
|
||||
</Form.Item>
|
||||
)}
|
||||
<div>
|
||||
{title === 'login' && (
|
||||
<div>
|
||||
{t('signInTip')}
|
||||
<Button type="link" onClick={changeTitle}>
|
||||
{t('signUp')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{title === 'register' && (
|
||||
<div>
|
||||
{t('signUpTip')}
|
||||
<Button type="link" onClick={changeTitle}>
|
||||
{t('login')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
type="primary"
|
||||
block
|
||||
size="large"
|
||||
onClick={onCheck}
|
||||
loading={signLoading}
|
||||
>
|
||||
{title === 'login' ? t('login') : t('continue')}
|
||||
</Button>
|
||||
{title === 'login' && (
|
||||
<>
|
||||
{/* <Button
|
||||
block
|
||||
size="large"
|
||||
onClick={toGoogle}
|
||||
style={{ marginTop: 15 }}
|
||||
>
|
||||
<div>
|
||||
<Icon
|
||||
icon="local:google"
|
||||
style={{ verticalAlign: 'middle', marginRight: 5 }}
|
||||
/>
|
||||
Sign in with Google
|
||||
</div>
|
||||
</Button> */}
|
||||
{location.host === Domain && (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
onClick={toGoogle}
|
||||
style={{ marginTop: 15 }}
|
||||
>
|
||||
<div>
|
||||
<Icon
|
||||
icon="local:github"
|
||||
style={{ verticalAlign: 'middle', marginRight: 5 }}
|
||||
/>
|
||||
Sign in with Github
|
||||
</div>
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.loginRight}>
|
||||
<RightPanel></RightPanel>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Login;
|
||||
import { useLogin, useRegister } from '@/hooks/login-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { rsaPsw } from '@/utils';
|
||||
import { Button, Checkbox, Form, Input } from 'antd';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Icon, useNavigate } from 'umi';
|
||||
import RightPanel from './right-panel';
|
||||
|
||||
import { Domain } from '@/constants/common';
|
||||
import styles from './index.less';
|
||||
|
||||
const Login = () => {
|
||||
const [title, setTitle] = useState('login');
|
||||
const navigate = useNavigate();
|
||||
const login = useLogin();
|
||||
const register = useRegister();
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'login' });
|
||||
|
||||
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
||||
|
||||
const signLoading = useOneNamespaceEffectsLoading('loginModel', [
|
||||
'login',
|
||||
'register',
|
||||
]);
|
||||
|
||||
const changeTitle = () => {
|
||||
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
||||
};
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
form.validateFields(['nickname']);
|
||||
}, [form]);
|
||||
|
||||
const onCheck = async () => {
|
||||
try {
|
||||
const params = await form.validateFields();
|
||||
|
||||
const rsaPassWord = rsaPsw(params.password) as string;
|
||||
|
||||
if (title === 'login') {
|
||||
const retcode = await login({
|
||||
email: params.email,
|
||||
password: rsaPassWord,
|
||||
});
|
||||
if (retcode === 0) {
|
||||
navigate('/knowledge');
|
||||
}
|
||||
} else {
|
||||
const retcode = await register({
|
||||
nickname: params.nickname,
|
||||
email: params.email,
|
||||
password: rsaPassWord,
|
||||
});
|
||||
if (retcode === 0) {
|
||||
setTitle('login');
|
||||
}
|
||||
}
|
||||
} catch (errorInfo) {
|
||||
console.log('Failed:', errorInfo);
|
||||
}
|
||||
};
|
||||
const formItemLayout = {
|
||||
labelCol: { span: 6 },
|
||||
// wrapperCol: { span: 8 },
|
||||
};
|
||||
|
||||
const toGoogle = () => {
|
||||
window.location.href =
|
||||
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.loginPage}>
|
||||
<div className={styles.loginLeft}>
|
||||
<div className={styles.leftContainer}>
|
||||
<div className={styles.loginTitle}>
|
||||
<div>{title === 'login' ? t('login') : t('register')}</div>
|
||||
<span>
|
||||
{title === 'login'
|
||||
? t('loginDescription')
|
||||
: t('registerDescription')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
name="dynamic_rule"
|
||||
style={{ maxWidth: 600 }}
|
||||
>
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="email"
|
||||
label={t('emailLabel')}
|
||||
rules={[{ required: true, message: t('emailPlaceholder') }]}
|
||||
>
|
||||
<Input size="large" placeholder={t('emailPlaceholder')} />
|
||||
</Form.Item>
|
||||
{title === 'register' && (
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="nickname"
|
||||
label={t('nicknameLabel')}
|
||||
rules={[{ required: true, message: t('nicknamePlaceholder') }]}
|
||||
>
|
||||
<Input size="large" placeholder={t('nicknamePlaceholder')} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item
|
||||
{...formItemLayout}
|
||||
name="password"
|
||||
label={t('passwordLabel')}
|
||||
rules={[{ required: true, message: t('passwordPlaceholder') }]}
|
||||
>
|
||||
<Input.Password
|
||||
size="large"
|
||||
placeholder={t('passwordPlaceholder')}
|
||||
onPressEnter={onCheck}
|
||||
/>
|
||||
</Form.Item>
|
||||
{title === 'login' && (
|
||||
<Form.Item name="remember" valuePropName="checked">
|
||||
<Checkbox> {t('rememberMe')}</Checkbox>
|
||||
</Form.Item>
|
||||
)}
|
||||
<div>
|
||||
{title === 'login' && (
|
||||
<div>
|
||||
{t('signInTip')}
|
||||
<Button type="link" onClick={changeTitle}>
|
||||
{t('signUp')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{title === 'register' && (
|
||||
<div>
|
||||
{t('signUpTip')}
|
||||
<Button type="link" onClick={changeTitle}>
|
||||
{t('login')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
type="primary"
|
||||
block
|
||||
size="large"
|
||||
onClick={onCheck}
|
||||
loading={signLoading}
|
||||
>
|
||||
{title === 'login' ? t('login') : t('continue')}
|
||||
</Button>
|
||||
{title === 'login' && (
|
||||
<>
|
||||
{/* <Button
|
||||
block
|
||||
size="large"
|
||||
onClick={toGoogle}
|
||||
style={{ marginTop: 15 }}
|
||||
>
|
||||
<div>
|
||||
<Icon
|
||||
icon="local:google"
|
||||
style={{ verticalAlign: 'middle', marginRight: 5 }}
|
||||
/>
|
||||
Sign in with Google
|
||||
</div>
|
||||
</Button> */}
|
||||
{location.host === Domain && (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
onClick={toGoogle}
|
||||
style={{ marginTop: 15 }}
|
||||
>
|
||||
<div>
|
||||
<Icon
|
||||
icon="local:github"
|
||||
style={{ verticalAlign: 'middle', marginRight: 5 }}
|
||||
/>
|
||||
Sign in with Github
|
||||
</div>
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.loginRight}>
|
||||
<RightPanel></RightPanel>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Login;
|
||||
|
||||
@ -1,69 +1,69 @@
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import i18n from '@/locales/config';
|
||||
import userService from '@/services/userService';
|
||||
import authorizationUtil from '@/utils/authorizationUtil';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface LoginModelState {
|
||||
list: any[];
|
||||
info: any;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
const model: DvaModel<LoginModelState> = {
|
||||
namespace: 'loginModel',
|
||||
state: {
|
||||
list: [],
|
||||
info: {},
|
||||
visible: false,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*login({ payload = {} }, { call }) {
|
||||
const { data, response } = yield call(userService.login, payload);
|
||||
const { retcode, data: res } = data;
|
||||
const authorization = response.headers.get(Authorization);
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.logged'));
|
||||
const token = res.access_token;
|
||||
const userInfo = {
|
||||
avatar: res.avatar,
|
||||
name: res.nickname,
|
||||
email: res.email,
|
||||
};
|
||||
authorizationUtil.setItems({
|
||||
Authorization: authorization,
|
||||
userInfo: JSON.stringify(userInfo),
|
||||
Token: token,
|
||||
});
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*register({ payload = {} }, { call }) {
|
||||
const { data } = yield call(userService.register, payload);
|
||||
console.log();
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.registered'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*logout({ payload = {} }, { call }) {
|
||||
const { data } = yield call(userService.logout, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.logout'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import i18n from '@/locales/config';
|
||||
import userService from '@/services/user-service';
|
||||
import authorizationUtil from '@/utils/authorizationUtil';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
export interface LoginModelState {
|
||||
list: any[];
|
||||
info: any;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
const model: DvaModel<LoginModelState> = {
|
||||
namespace: 'loginModel',
|
||||
state: {
|
||||
list: [],
|
||||
info: {},
|
||||
visible: false,
|
||||
},
|
||||
reducers: {
|
||||
updateState(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*login({ payload = {} }, { call }) {
|
||||
const { data, response } = yield call(userService.login, payload);
|
||||
const { retcode, data: res } = data;
|
||||
const authorization = response.headers.get(Authorization);
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.logged'));
|
||||
const token = res.access_token;
|
||||
const userInfo = {
|
||||
avatar: res.avatar,
|
||||
name: res.nickname,
|
||||
email: res.email,
|
||||
};
|
||||
authorizationUtil.setItems({
|
||||
Authorization: authorization,
|
||||
userInfo: JSON.stringify(userInfo),
|
||||
Token: token,
|
||||
});
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*register({ payload = {} }, { call }) {
|
||||
const { data } = yield call(userService.register, payload);
|
||||
console.log();
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.registered'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
*logout({ payload = {} }, { call }) {
|
||||
const { data } = yield call(userService.logout, payload);
|
||||
const { retcode } = data;
|
||||
if (retcode === 0) {
|
||||
message.success(i18n.t('message.logout'));
|
||||
}
|
||||
return retcode;
|
||||
},
|
||||
},
|
||||
};
|
||||
export default model;
|
||||
|
||||
@ -3,7 +3,7 @@ import SvgIcon from '@/components/svg-icon';
|
||||
import { Flex, Rate, Space, Typography } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { SettingOutlined } from '@ant-design/icons';
|
||||
import { Button, Flex, Typography } from 'antd';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { Form } from 'antd';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
} from '@/interfaces/database/llm';
|
||||
import { IUserInfo } from '@/interfaces/database/userSetting';
|
||||
import i18n from '@/locales/config';
|
||||
import userService from '@/services/userService';
|
||||
import userService from '@/services/user-service';
|
||||
import { message } from 'antd';
|
||||
import { DvaModel } from 'umi';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
import { ApiKeyPostBody } from '../../interface';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks';
|
||||
import {
|
||||
IApiKeySavingParams,
|
||||
ISystemModelSettingSavingParams,
|
||||
@ -8,12 +8,12 @@ import {
|
||||
useSaveApiKey,
|
||||
useSaveTenantInfo,
|
||||
useSelectLlmOptionsByModelType,
|
||||
} from '@/hooks/llmHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
} from '@/hooks/llm-hooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import {
|
||||
useFetchTenantInfo,
|
||||
useSelectTenantInfo,
|
||||
} from '@/hooks/userSettingHook';
|
||||
} from '@/hooks/user-setting-hooks';
|
||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { ApiKeyPostBody } from '../interface';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { ReactComponent as MoreModelIcon } from '@/assets/svg/more-model.svg';
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
|
||||
import {
|
||||
LlmItem,
|
||||
useFetchLlmFactoryListOnMount,
|
||||
useFetchMyLlmListOnMount,
|
||||
} from '@/hooks/llmHooks';
|
||||
} from '@/hooks/llm-hooks';
|
||||
import {
|
||||
CloseCircleOutlined,
|
||||
SettingOutlined,
|
||||
@ -61,9 +61,9 @@ const IconMap = {
|
||||
Mistral: 'mistral',
|
||||
'Azure-OpenAI': 'azure',
|
||||
Bedrock: 'bedrock',
|
||||
Gemini:'gemini',
|
||||
Gemini: 'gemini',
|
||||
Groq: 'Groq',
|
||||
OpenRouter:'open-router'
|
||||
OpenRouter: 'open-router',
|
||||
};
|
||||
|
||||
const LlmIcon = ({ name }: { name: string }) => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import { Flex, Form, Input, Modal, Select, Space, Switch } from 'antd';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { LlmModelType } from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { ISystemModelSettingSavingParams } from '@/hooks/llmHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { ISystemModelSettingSavingParams } from '@/hooks/llm-hooks';
|
||||
import { Form, Modal, Select } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
import { useFetchSystemModelSettingOnMount } from '../hooks';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import { Flex, Form, Input, Modal, Select, Space, Switch } from 'antd';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useSaveSetting } from '@/hooks/userSettingHook';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
||||
import { useSaveSetting } from '@/hooks/user-setting-hooks';
|
||||
import { rsaPsw } from '@/utils';
|
||||
import { Button, Divider, Form, Input, Space } from 'antd';
|
||||
import SettingTitle from '../components/setting-title';
|
||||
import { useValidateSubmittable } from '../hooks';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import parentStyles from '../index.less';
|
||||
import styles from './index.less';
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import {
|
||||
useFetchUserInfo,
|
||||
useSaveSetting,
|
||||
useSelectUserInfo,
|
||||
} from '@/hooks/userSettingHook';
|
||||
} from '@/hooks/user-setting-hooks';
|
||||
import {
|
||||
getBase64FromUploadFileList,
|
||||
getUploadFileListFromBase64,
|
||||
@ -31,7 +31,7 @@ import {
|
||||
} from '../hooks';
|
||||
|
||||
import { LanguageList } from '@/constants/common';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useChangeLanguage } from '@/hooks/logic-hooks';
|
||||
import parentStyles from '../index.less';
|
||||
import styles from './index.less';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useFetchSystemStatus } from '@/hooks/userSettingHook';
|
||||
import { useFetchSystemStatus } from '@/hooks/user-setting-hooks';
|
||||
import { ISystemStatus, Minio } from '@/interfaces/database/userSetting';
|
||||
import { Badge, Card, Flex, Spin, Typography } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Button, Card, Flex } from 'antd';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSelectUserInfo } from '@/hooks/userSettingHook';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useSelectUserInfo } from '@/hooks/user-setting-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
const UserSettingTeam = () => {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Domain } from '@/constants/common';
|
||||
import { useSecondPathName } from '@/hooks/routeHook';
|
||||
import { useSecondPathName } from '@/hooks/route-hook';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { Flex, Menu } from 'antd';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
@ -10,8 +10,8 @@ import {
|
||||
UserSettingRouteKey,
|
||||
} from '../constants';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useFetchSystemVersion, useLogout } from '@/hooks/userSettingHook';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchSystemVersion, useLogout } from '@/hooks/user-setting-hooks';
|
||||
import styles from './index.less';
|
||||
|
||||
type MenuItem = Required<MenuProps>['items'][number];
|
||||
|
||||
Reference in New Issue
Block a user