balibabu
commited on
Commit
·
eb38196
1
Parent(s):
407b252
feat: confirm before deleting knowledge base and add ChunkToolBar (#56)
Browse files* feat: confirm before deleting knowledge base
* feat: add ChunkToolBar
- web/src/components/modal-manager.tsx +6 -5
- web/src/hooks/storeHooks.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-toolbar/index.tsx +106 -0
- web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx +3 -1
- web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +21 -6
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +21 -9
- web/src/pages/add-knowledge/components/knowledge-file/model.ts +10 -2
- web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx +2 -1
- web/src/pages/add-knowledge/components/knowledge-setting/index.tsx +2 -1
- web/src/pages/add-knowledge/components/knowledge-setting/model.ts +1 -1
- web/src/pages/knowledge/index.tsx +27 -29
- web/src/pages/knowledge/knowledge-card/index.tsx +24 -24
- web/src/pages/knowledge/knowledge-creating-modal/index.tsx +81 -0
- web/src/services/kbService.ts +5 -0
- web/src/utils/api.ts +1 -0
- web/src/utils/{stroreUtil.ts → storeUtil.ts} +0 -0
web/src/components/modal-manager.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
interface IProps {
|
| 4 |
-
children: (props:
|
| 5 |
-
showModal(): void;
|
| 6 |
-
hideModal(): void;
|
| 7 |
-
visible: boolean;
|
| 8 |
-
}) => React.ReactNode;
|
| 9 |
}
|
| 10 |
|
| 11 |
const ModalManager = ({ children }: IProps) => {
|
|
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
|
| 3 |
+
export interface IModalManagerChildrenProps {
|
| 4 |
+
showModal(): void;
|
| 5 |
+
hideModal(): void;
|
| 6 |
+
visible: boolean;
|
| 7 |
+
}
|
| 8 |
interface IProps {
|
| 9 |
+
children: (props: IModalManagerChildrenProps) => React.ReactNode;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
}
|
| 11 |
|
| 12 |
const ModalManager = ({ children }: IProps) => {
|
web/src/hooks/storeHooks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { getOneNamespaceEffectsLoading } from '@/utils/
|
| 2 |
import { useSelector } from 'umi';
|
| 3 |
|
| 4 |
// Get the loading status of given effects under a certain namespace
|
|
|
|
| 1 |
+
import { getOneNamespaceEffectsLoading } from '@/utils/storeUtil';
|
| 2 |
import { useSelector } from 'umi';
|
| 3 |
|
| 4 |
// Get the loading status of given effects under a certain namespace
|
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-toolbar/index.tsx
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
|
| 2 |
+
import {
|
| 3 |
+
ArrowLeftOutlined,
|
| 4 |
+
CheckCircleOutlined,
|
| 5 |
+
CloseCircleOutlined,
|
| 6 |
+
DeleteOutlined,
|
| 7 |
+
DownOutlined,
|
| 8 |
+
FilePdfOutlined,
|
| 9 |
+
PlusOutlined,
|
| 10 |
+
SearchOutlined,
|
| 11 |
+
} from '@ant-design/icons';
|
| 12 |
+
import { Button, Checkbox, Flex, Menu, MenuProps, Popover, Space } from 'antd';
|
| 13 |
+
import { useMemo } from 'react';
|
| 14 |
+
|
| 15 |
+
const ChunkToolBar = () => {
|
| 16 |
+
const items: MenuProps['items'] = useMemo(() => {
|
| 17 |
+
return [
|
| 18 |
+
{
|
| 19 |
+
key: '1',
|
| 20 |
+
label: (
|
| 21 |
+
<>
|
| 22 |
+
<Checkbox>
|
| 23 |
+
<b>Select All</b>
|
| 24 |
+
</Checkbox>
|
| 25 |
+
</>
|
| 26 |
+
),
|
| 27 |
+
},
|
| 28 |
+
{ type: 'divider' },
|
| 29 |
+
{
|
| 30 |
+
key: '2',
|
| 31 |
+
label: (
|
| 32 |
+
<Space>
|
| 33 |
+
<CheckCircleOutlined />
|
| 34 |
+
<b>Enabled Selected</b>
|
| 35 |
+
</Space>
|
| 36 |
+
),
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
key: '3',
|
| 40 |
+
label: (
|
| 41 |
+
<Space>
|
| 42 |
+
<CloseCircleOutlined />
|
| 43 |
+
<b>Disabled Selected</b>
|
| 44 |
+
</Space>
|
| 45 |
+
),
|
| 46 |
+
},
|
| 47 |
+
{ type: 'divider' },
|
| 48 |
+
{
|
| 49 |
+
key: '4',
|
| 50 |
+
label: (
|
| 51 |
+
<Space>
|
| 52 |
+
<DeleteOutlined />
|
| 53 |
+
<b>Delete Selected</b>
|
| 54 |
+
</Space>
|
| 55 |
+
),
|
| 56 |
+
},
|
| 57 |
+
];
|
| 58 |
+
}, []);
|
| 59 |
+
|
| 60 |
+
const content = (
|
| 61 |
+
<Menu style={{ width: 200 }} items={items} selectable={false} />
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
return (
|
| 65 |
+
<Flex justify="space-between" align="center">
|
| 66 |
+
<Space>
|
| 67 |
+
<ArrowLeftOutlined />
|
| 68 |
+
<FilePdfOutlined />
|
| 69 |
+
xxx.pdf
|
| 70 |
+
</Space>
|
| 71 |
+
<Space>
|
| 72 |
+
{/* <Select
|
| 73 |
+
defaultValue="lucy"
|
| 74 |
+
style={{ width: 100 }}
|
| 75 |
+
popupMatchSelectWidth={false}
|
| 76 |
+
optionRender={() => null}
|
| 77 |
+
dropdownRender={(menu) => (
|
| 78 |
+
<div style={{ width: 300 }}>
|
| 79 |
+
{menu}
|
| 80 |
+
<Menu
|
| 81 |
+
// onClick={onClick}
|
| 82 |
+
style={{ width: 256 }}
|
| 83 |
+
// defaultSelectedKeys={['1']}
|
| 84 |
+
// defaultOpenKeys={['sub1']}
|
| 85 |
+
// mode="inline"
|
| 86 |
+
items={actionItems}
|
| 87 |
+
/>
|
| 88 |
+
</div>
|
| 89 |
+
)}
|
| 90 |
+
></Select> */}
|
| 91 |
+
<Popover content={content} placement="bottomLeft" arrow={false}>
|
| 92 |
+
<Button>
|
| 93 |
+
Bulk
|
| 94 |
+
<DownOutlined />
|
| 95 |
+
</Button>
|
| 96 |
+
</Popover>
|
| 97 |
+
<Button icon={<SearchOutlined />} />
|
| 98 |
+
<Button icon={<FilterIcon />} />
|
| 99 |
+
<Button icon={<DeleteOutlined />} />
|
| 100 |
+
<Button icon={<PlusOutlined />} type="primary" />
|
| 101 |
+
</Space>
|
| 102 |
+
</Flex>
|
| 103 |
+
);
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
export default ChunkToolBar;
|
web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { api_host } from '@/utils/api';
|
| 2 |
-
import { getOneNamespaceEffectsLoading } from '@/utils/
|
| 3 |
import { DeleteOutlined, MinusSquareOutlined } from '@ant-design/icons';
|
| 4 |
import type { PaginationProps } from 'antd';
|
| 5 |
import {
|
|
@@ -19,6 +19,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
| 19 |
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
| 20 |
import CreateModal from './components/createModal';
|
| 21 |
|
|
|
|
| 22 |
import styles from './index.less';
|
| 23 |
|
| 24 |
interface PayloadType {
|
|
@@ -126,6 +127,7 @@ const Chunk = () => {
|
|
| 126 |
return (
|
| 127 |
<>
|
| 128 |
<div className={styles.chunkPage}>
|
|
|
|
| 129 |
<div className={styles.filter}>
|
| 130 |
<div>
|
| 131 |
<Input
|
|
|
|
| 1 |
import { api_host } from '@/utils/api';
|
| 2 |
+
import { getOneNamespaceEffectsLoading } from '@/utils/storeUtil';
|
| 3 |
import { DeleteOutlined, MinusSquareOutlined } from '@ant-design/icons';
|
| 4 |
import type { PaginationProps } from 'antd';
|
| 5 |
import {
|
|
|
|
| 19 |
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
| 20 |
import CreateModal from './components/createModal';
|
| 21 |
|
| 22 |
+
import ChunkToolBar from './components/chunk-toolbar';
|
| 23 |
import styles from './index.less';
|
| 24 |
|
| 25 |
interface PayloadType {
|
|
|
|
| 127 |
return (
|
| 128 |
<>
|
| 129 |
<div className={styles.chunkPage}>
|
| 130 |
+
<ChunkToolBar></ChunkToolBar>
|
| 131 |
<div className={styles.filter}>
|
| 132 |
<div>
|
| 133 |
<Input
|
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
| 28 |
UploadProps,
|
| 29 |
} from 'antd';
|
| 30 |
import classNames from 'classnames';
|
| 31 |
-
import { ReactElement, useEffect, useState } from 'react';
|
| 32 |
import { Nullable } from 'typings';
|
| 33 |
import { Link, useDispatch, useNavigate, useSelector } from 'umi';
|
| 34 |
|
|
@@ -72,11 +72,15 @@ const UploaderItem = ({
|
|
| 72 |
const content = (
|
| 73 |
<Radio.Group onChange={onChange} value={value}>
|
| 74 |
<Space direction="vertical">
|
| 75 |
-
{parserArray.map(
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
</Space>
|
| 81 |
</Radio.Group>
|
| 82 |
);
|
|
@@ -147,6 +151,7 @@ const KnowledgeUploadFile = () => {
|
|
| 147 |
(state: any) => state.settingModel.tenantIfo,
|
| 148 |
);
|
| 149 |
const navigate = useNavigate();
|
|
|
|
| 150 |
|
| 151 |
const parserArray = tenantIfo?.parser_ids.split(',') ?? [];
|
| 152 |
|
|
@@ -168,6 +173,7 @@ const KnowledgeUploadFile = () => {
|
|
| 168 |
name: 'file',
|
| 169 |
multiple: true,
|
| 170 |
itemRender(originNode, file, fileList, actions) {
|
|
|
|
| 171 |
return (
|
| 172 |
<UploaderItem
|
| 173 |
isUpload={isUpload}
|
|
@@ -185,8 +191,17 @@ const KnowledgeUploadFile = () => {
|
|
| 185 |
},
|
| 186 |
};
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
const handleNextClick = () => {
|
| 189 |
if (!isUpload) {
|
|
|
|
| 190 |
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeBaseId}`);
|
| 191 |
} else {
|
| 192 |
setIsUpload(false);
|
|
|
|
| 28 |
UploadProps,
|
| 29 |
} from 'antd';
|
| 30 |
import classNames from 'classnames';
|
| 31 |
+
import { ReactElement, useEffect, useRef, useState } from 'react';
|
| 32 |
import { Nullable } from 'typings';
|
| 33 |
import { Link, useDispatch, useNavigate, useSelector } from 'umi';
|
| 34 |
|
|
|
|
| 72 |
const content = (
|
| 73 |
<Radio.Group onChange={onChange} value={value}>
|
| 74 |
<Space direction="vertical">
|
| 75 |
+
{parserArray.map(
|
| 76 |
+
(
|
| 77 |
+
x, // value is lowercase, key is uppercase
|
| 78 |
+
) => (
|
| 79 |
+
<Radio value={x.toLowerCase()} key={x}>
|
| 80 |
+
{x}
|
| 81 |
+
</Radio>
|
| 82 |
+
),
|
| 83 |
+
)}
|
| 84 |
</Space>
|
| 85 |
</Radio.Group>
|
| 86 |
);
|
|
|
|
| 151 |
(state: any) => state.settingModel.tenantIfo,
|
| 152 |
);
|
| 153 |
const navigate = useNavigate();
|
| 154 |
+
const fileListRef = useRef<UploadFile[]>([]);
|
| 155 |
|
| 156 |
const parserArray = tenantIfo?.parser_ids.split(',') ?? [];
|
| 157 |
|
|
|
|
| 173 |
name: 'file',
|
| 174 |
multiple: true,
|
| 175 |
itemRender(originNode, file, fileList, actions) {
|
| 176 |
+
fileListRef.current = fileList;
|
| 177 |
return (
|
| 178 |
<UploaderItem
|
| 179 |
isUpload={isUpload}
|
|
|
|
| 191 |
},
|
| 192 |
};
|
| 193 |
|
| 194 |
+
const runSelectedDocument = () => {
|
| 195 |
+
const ids = fileListRef.current.map((x) => x.response.id);
|
| 196 |
+
dispatch({
|
| 197 |
+
type: 'kFModel/document_run',
|
| 198 |
+
payload: { doc_ids: ids, run: 1 },
|
| 199 |
+
});
|
| 200 |
+
};
|
| 201 |
+
|
| 202 |
const handleNextClick = () => {
|
| 203 |
if (!isUpload) {
|
| 204 |
+
runSelectedDocument();
|
| 205 |
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeBaseId}`);
|
| 206 |
} else {
|
| 207 |
setIsUpload(false);
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
|
@@ -5,8 +5,13 @@ import {
|
|
| 5 |
} from '@/hooks/knowledgeHook';
|
| 6 |
import { Pagination } from '@/interfaces/common';
|
| 7 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
| 8 |
-
import { getOneNamespaceEffectsLoading } from '@/utils/
|
| 9 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import type { MenuProps } from 'antd';
|
| 11 |
import {
|
| 12 |
Button,
|
|
@@ -21,14 +26,13 @@ import {
|
|
| 21 |
import type { ColumnsType } from 'antd/es/table';
|
| 22 |
import { PaginationProps } from 'antd/lib';
|
| 23 |
import React, { useEffect, useMemo, useState } from 'react';
|
| 24 |
-
import { useDispatch, useNavigate, useSelector } from 'umi';
|
| 25 |
import CreateEPModal from './createEFileModal';
|
| 26 |
import styles from './index.less';
|
| 27 |
import ParsingActionCell from './parsing-action-cell';
|
| 28 |
import ParsingStatusCell from './parsing-status-cell';
|
| 29 |
import RenameModal from './rename-modal';
|
| 30 |
import SegmentSetModal from './segmentSetModal';
|
| 31 |
-
import UploadFile from './upload';
|
| 32 |
|
| 33 |
const KnowledgeFile = () => {
|
| 34 |
const dispatch = useDispatch();
|
|
@@ -155,24 +159,32 @@ const KnowledgeFile = () => {
|
|
| 155 |
key: '1',
|
| 156 |
label: (
|
| 157 |
<div>
|
| 158 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
</div>
|
| 160 |
),
|
| 161 |
},
|
|
|
|
| 162 |
{
|
| 163 |
key: '2',
|
| 164 |
label: (
|
| 165 |
<div>
|
| 166 |
<Button type="link" onClick={showCEFModal}>
|
| 167 |
-
|
| 168 |
-
|
| 169 |
</Button>
|
| 170 |
</div>
|
| 171 |
),
|
| 172 |
// disabled: true,
|
| 173 |
},
|
| 174 |
];
|
| 175 |
-
}, [
|
| 176 |
const chunkItems: MenuProps['items'] = [
|
| 177 |
{
|
| 178 |
key: '1',
|
|
@@ -191,7 +203,7 @@ const KnowledgeFile = () => {
|
|
| 191 |
<div>
|
| 192 |
<Button type="link" onClick={onRmDocument}>
|
| 193 |
{' '}
|
| 194 |
-
|
| 195 |
</Button>
|
| 196 |
</div>
|
| 197 |
),
|
|
|
|
| 5 |
} from '@/hooks/knowledgeHook';
|
| 6 |
import { Pagination } from '@/interfaces/common';
|
| 7 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
| 8 |
+
import { getOneNamespaceEffectsLoading } from '@/utils/storeUtil';
|
| 9 |
+
import {
|
| 10 |
+
FileOutlined,
|
| 11 |
+
FileTextOutlined,
|
| 12 |
+
PlusOutlined,
|
| 13 |
+
SearchOutlined,
|
| 14 |
+
} from '@ant-design/icons';
|
| 15 |
import type { MenuProps } from 'antd';
|
| 16 |
import {
|
| 17 |
Button,
|
|
|
|
| 26 |
import type { ColumnsType } from 'antd/es/table';
|
| 27 |
import { PaginationProps } from 'antd/lib';
|
| 28 |
import React, { useEffect, useMemo, useState } from 'react';
|
| 29 |
+
import { Link, useDispatch, useNavigate, useSelector } from 'umi';
|
| 30 |
import CreateEPModal from './createEFileModal';
|
| 31 |
import styles from './index.less';
|
| 32 |
import ParsingActionCell from './parsing-action-cell';
|
| 33 |
import ParsingStatusCell from './parsing-status-cell';
|
| 34 |
import RenameModal from './rename-modal';
|
| 35 |
import SegmentSetModal from './segmentSetModal';
|
|
|
|
| 36 |
|
| 37 |
const KnowledgeFile = () => {
|
| 38 |
const dispatch = useDispatch();
|
|
|
|
| 159 |
key: '1',
|
| 160 |
label: (
|
| 161 |
<div>
|
| 162 |
+
<Button type="link">
|
| 163 |
+
<Link to={`/knowledge/dataset/upload?id=${knowledgeBaseId}`}>
|
| 164 |
+
<Space>
|
| 165 |
+
<FileTextOutlined />
|
| 166 |
+
Local files
|
| 167 |
+
</Space>
|
| 168 |
+
</Link>
|
| 169 |
+
</Button>
|
| 170 |
</div>
|
| 171 |
),
|
| 172 |
},
|
| 173 |
+
{ type: 'divider' },
|
| 174 |
{
|
| 175 |
key: '2',
|
| 176 |
label: (
|
| 177 |
<div>
|
| 178 |
<Button type="link" onClick={showCEFModal}>
|
| 179 |
+
<FileOutlined />
|
| 180 |
+
Create empty file
|
| 181 |
</Button>
|
| 182 |
</div>
|
| 183 |
),
|
| 184 |
// disabled: true,
|
| 185 |
},
|
| 186 |
];
|
| 187 |
+
}, []);
|
| 188 |
const chunkItems: MenuProps['items'] = [
|
| 189 |
{
|
| 190 |
key: '1',
|
|
|
|
| 203 |
<div>
|
| 204 |
<Button type="link" onClick={onRmDocument}>
|
| 205 |
{' '}
|
| 206 |
+
Delete
|
| 207 |
</Button>
|
| 208 |
</div>
|
| 209 |
),
|
web/src/pages/add-knowledge/components/knowledge-file/model.ts
CHANGED
|
@@ -168,8 +168,8 @@ const model: DvaModel<KFModelState> = {
|
|
| 168 |
return retcode;
|
| 169 |
},
|
| 170 |
*document_create({ payload = {} }, { call, put }) {
|
| 171 |
-
const { data
|
| 172 |
-
const { retcode, data: res
|
| 173 |
if (retcode === 0) {
|
| 174 |
put({
|
| 175 |
type: 'kFModel/updateState',
|
|
@@ -181,6 +181,14 @@ const model: DvaModel<KFModelState> = {
|
|
| 181 |
}
|
| 182 |
return retcode;
|
| 183 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
*document_change_parser({ payload = {} }, { call, put }) {
|
| 185 |
const { data, response } = yield call(
|
| 186 |
kbService.document_change_parser,
|
|
|
|
| 168 |
return retcode;
|
| 169 |
},
|
| 170 |
*document_create({ payload = {} }, { call, put }) {
|
| 171 |
+
const { data } = yield call(kbService.document_create, payload);
|
| 172 |
+
const { retcode, data: res } = data;
|
| 173 |
if (retcode === 0) {
|
| 174 |
put({
|
| 175 |
type: 'kFModel/updateState',
|
|
|
|
| 181 |
}
|
| 182 |
return retcode;
|
| 183 |
},
|
| 184 |
+
*document_run({ payload = {} }, { call, put }) {
|
| 185 |
+
const { data } = yield call(kbService.document_run, payload);
|
| 186 |
+
const { retcode } = data;
|
| 187 |
+
if (retcode === 0) {
|
| 188 |
+
message.success('Run successfully !');
|
| 189 |
+
}
|
| 190 |
+
return retcode;
|
| 191 |
+
},
|
| 192 |
*document_change_parser({ payload = {} }, { call, put }) {
|
| 193 |
const { data, response } = yield call(
|
| 194 |
kbService.document_change_parser,
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx
CHANGED
|
@@ -55,7 +55,8 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
|
| 55 |
{isRunning ? (
|
| 56 |
<Space>
|
| 57 |
<Badge color={runningStatus.color} />
|
| 58 |
-
|
|
|
|
| 59 |
</Space>
|
| 60 |
) : (
|
| 61 |
runningStatus.label
|
|
|
|
| 55 |
{isRunning ? (
|
| 56 |
<Space>
|
| 57 |
<Badge color={runningStatus.color} />
|
| 58 |
+
{runningStatus.label}
|
| 59 |
+
<span>{record.progress * 100}%</span>
|
| 60 |
</Space>
|
| 61 |
) : (
|
| 62 |
runningStatus.label
|
web/src/pages/add-knowledge/components/knowledge-setting/index.tsx
CHANGED
|
@@ -19,7 +19,8 @@ const KnowledgeSetting = () => {
|
|
| 19 |
const settingModel = useSelector((state: any) => state.settingModel);
|
| 20 |
let navigate = useNavigate();
|
| 21 |
const { tenantIfo = {} } = settingModel;
|
| 22 |
-
const
|
|
|
|
| 23 |
const [form] = Form.useForm();
|
| 24 |
const [selectedTag, setSelectedTag] = useState('');
|
| 25 |
const values = Form.useWatch([], form);
|
|
|
|
| 19 |
const settingModel = useSelector((state: any) => state.settingModel);
|
| 20 |
let navigate = useNavigate();
|
| 21 |
const { tenantIfo = {} } = settingModel;
|
| 22 |
+
const parser_ids = tenantIfo?.parser_ids ?? '';
|
| 23 |
+
const embd_id = tenantIfo?.embd_id ?? '';
|
| 24 |
const [form] = Form.useForm();
|
| 25 |
const [selectedTag, setSelectedTag] = useState('');
|
| 26 |
const values = Form.useWatch([], form);
|
web/src/pages/add-knowledge/components/knowledge-setting/model.ts
CHANGED
|
@@ -35,7 +35,7 @@ const model: DvaModel<KSModelState> = {
|
|
| 35 |
if (retcode === 0) {
|
| 36 |
message.success('创建知识库成功!');
|
| 37 |
}
|
| 38 |
-
return
|
| 39 |
},
|
| 40 |
*updateKb({ payload = {} }, { call, put }) {
|
| 41 |
const { data } = yield call(kbService.updateKb, payload);
|
|
|
|
| 35 |
if (retcode === 0) {
|
| 36 |
message.success('创建知识库成功!');
|
| 37 |
}
|
| 38 |
+
return data;
|
| 39 |
},
|
| 40 |
*updateKb({ payload = {} }, { call, put }) {
|
| 41 |
const { data } = yield call(kbService.updateKb, payload);
|
web/src/pages/knowledge/index.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
|
| 2 |
-
import
|
| 3 |
import { PlusOutlined } from '@ant-design/icons';
|
| 4 |
import { Button, Flex, Space } from 'antd';
|
| 5 |
import { useCallback, useEffect } from 'react';
|
| 6 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
| 7 |
-
import styles from './index.less';
|
| 8 |
import KnowledgeCard from './knowledge-card';
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
const Knowledge = () => {
|
| 11 |
const dispatch = useDispatch();
|
|
@@ -20,9 +22,9 @@ const Knowledge = () => {
|
|
| 20 |
});
|
| 21 |
}, []);
|
| 22 |
|
| 23 |
-
const handleAddKnowledge = () => {
|
| 24 |
-
|
| 25 |
-
};
|
| 26 |
|
| 27 |
useEffect(() => {
|
| 28 |
fetchList();
|
|
@@ -41,32 +43,28 @@ const Knowledge = () => {
|
|
| 41 |
<Button icon={<FilterIcon />} className={styles.filterButton}>
|
| 42 |
Filters
|
| 43 |
</Button>
|
| 44 |
-
<
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</Space>
|
| 53 |
</div>
|
| 54 |
-
{/* <Row gutter={{ xs: 8, sm: 16, md: 24, lg: 32 }}>
|
| 55 |
-
{data.map((item: any) => {
|
| 56 |
-
return (
|
| 57 |
-
<Col
|
| 58 |
-
className="gutter-row"
|
| 59 |
-
key={item.name}
|
| 60 |
-
xs={24}
|
| 61 |
-
sm={12}
|
| 62 |
-
md={10}
|
| 63 |
-
lg={8}
|
| 64 |
-
>
|
| 65 |
-
<KnowledgeCard item={item}></KnowledgeCard>
|
| 66 |
-
</Col>
|
| 67 |
-
);
|
| 68 |
-
})}
|
| 69 |
-
</Row> */}
|
| 70 |
<Flex gap="large" wrap="wrap">
|
| 71 |
{data.map((item: any) => {
|
| 72 |
return <KnowledgeCard item={item} key={item.name}></KnowledgeCard>;
|
|
|
|
| 1 |
import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
|
| 2 |
+
import ModalManager from '@/components/modal-manager';
|
| 3 |
import { PlusOutlined } from '@ant-design/icons';
|
| 4 |
import { Button, Flex, Space } from 'antd';
|
| 5 |
import { useCallback, useEffect } from 'react';
|
| 6 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
|
|
|
| 7 |
import KnowledgeCard from './knowledge-card';
|
| 8 |
+
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
| 9 |
+
|
| 10 |
+
import styles from './index.less';
|
| 11 |
|
| 12 |
const Knowledge = () => {
|
| 13 |
const dispatch = useDispatch();
|
|
|
|
| 22 |
});
|
| 23 |
}, []);
|
| 24 |
|
| 25 |
+
// const handleAddKnowledge = () => {
|
| 26 |
+
// navigate(`/knowledge/${KnowledgeRouteKey.Configuration}`);
|
| 27 |
+
// };
|
| 28 |
|
| 29 |
useEffect(() => {
|
| 30 |
fetchList();
|
|
|
|
| 43 |
<Button icon={<FilterIcon />} className={styles.filterButton}>
|
| 44 |
Filters
|
| 45 |
</Button>
|
| 46 |
+
<ModalManager>
|
| 47 |
+
{({ visible, hideModal, showModal }) => (
|
| 48 |
+
<>
|
| 49 |
+
<Button
|
| 50 |
+
type="primary"
|
| 51 |
+
icon={<PlusOutlined />}
|
| 52 |
+
onClick={() => {
|
| 53 |
+
showModal();
|
| 54 |
+
}}
|
| 55 |
+
className={styles.topButton}
|
| 56 |
+
>
|
| 57 |
+
Create knowledge base
|
| 58 |
+
</Button>
|
| 59 |
+
<KnowledgeCreatingModal
|
| 60 |
+
visible={visible}
|
| 61 |
+
hideModal={hideModal}
|
| 62 |
+
></KnowledgeCreatingModal>
|
| 63 |
+
</>
|
| 64 |
+
)}
|
| 65 |
+
</ModalManager>
|
| 66 |
</Space>
|
| 67 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
<Flex gap="large" wrap="wrap">
|
| 69 |
{data.map((item: any) => {
|
| 70 |
return <KnowledgeCard item={item} key={item.name}></KnowledgeCard>;
|
web/src/pages/knowledge/knowledge-card/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
| 2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
|
|
|
| 3 |
import { formatDate } from '@/utils/date';
|
| 4 |
import {
|
| 5 |
CalendarOutlined,
|
|
@@ -11,18 +12,19 @@ import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
|
| 11 |
import { MouseEvent } from 'react';
|
| 12 |
import { useDispatch, useNavigate } from 'umi';
|
| 13 |
|
|
|
|
| 14 |
import styles from './index.less';
|
| 15 |
|
| 16 |
interface IProps {
|
| 17 |
-
item:
|
| 18 |
}
|
| 19 |
|
| 20 |
const KnowledgeCard = ({ item }: IProps) => {
|
| 21 |
const navigate = useNavigate();
|
| 22 |
const dispatch = useDispatch();
|
| 23 |
|
| 24 |
-
const handleDelete = (
|
| 25 |
-
|
| 26 |
};
|
| 27 |
|
| 28 |
const items: MenuProps['items'] = [
|
|
@@ -30,32 +32,34 @@ const KnowledgeCard = ({ item }: IProps) => {
|
|
| 30 |
key: '1',
|
| 31 |
label: (
|
| 32 |
<Space>
|
| 33 |
-
|
| 34 |
-
<DeleteOutlined
|
| 35 |
</Space>
|
| 36 |
),
|
| 37 |
},
|
| 38 |
];
|
| 39 |
|
| 40 |
-
const
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
type: 'knowledgeModel/rmKb',
|
| 43 |
payload: {
|
| 44 |
-
kb_id: id,
|
| 45 |
},
|
| 46 |
});
|
| 47 |
};
|
| 48 |
|
| 49 |
-
const handleCardClick = () => {
|
| 50 |
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${item.id}`);
|
| 51 |
};
|
| 52 |
|
| 53 |
-
const onConfirmDelete = (e?: MouseEvent<HTMLElement>) => {
|
| 54 |
-
e?.stopPropagation();
|
| 55 |
-
e?.nativeEvent.stopImmediatePropagation();
|
| 56 |
-
confirm(item.id);
|
| 57 |
-
};
|
| 58 |
-
|
| 59 |
return (
|
| 60 |
<Card className={styles.card} onClick={handleCardClick}>
|
| 61 |
<div className={styles.container}>
|
|
@@ -63,16 +67,12 @@ const KnowledgeCard = ({ item }: IProps) => {
|
|
| 63 |
<Avatar size={34} icon={<UserOutlined />} />
|
| 64 |
|
| 65 |
<span className={styles.delete}>
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
cancelText="No"
|
| 72 |
>
|
| 73 |
-
<DeleteOutlined onClick={handleDelete} />
|
| 74 |
-
</Popconfirm> */}
|
| 75 |
-
<Dropdown menu={{ items }}>
|
| 76 |
<MoreIcon />
|
| 77 |
</Dropdown>
|
| 78 |
</span>
|
|
|
|
| 1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
| 2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
| 3 |
+
import { IKnowledge } from '@/interfaces/database/knowledge';
|
| 4 |
import { formatDate } from '@/utils/date';
|
| 5 |
import {
|
| 6 |
CalendarOutlined,
|
|
|
|
| 12 |
import { MouseEvent } from 'react';
|
| 13 |
import { useDispatch, useNavigate } from 'umi';
|
| 14 |
|
| 15 |
+
import showDeleteConfirm from '@/components/deleting-confirm';
|
| 16 |
import styles from './index.less';
|
| 17 |
|
| 18 |
interface IProps {
|
| 19 |
+
item: IKnowledge;
|
| 20 |
}
|
| 21 |
|
| 22 |
const KnowledgeCard = ({ item }: IProps) => {
|
| 23 |
const navigate = useNavigate();
|
| 24 |
const dispatch = useDispatch();
|
| 25 |
|
| 26 |
+
const handleDelete = () => {
|
| 27 |
+
showDeleteConfirm({ onOk: removeKnowledge });
|
| 28 |
};
|
| 29 |
|
| 30 |
const items: MenuProps['items'] = [
|
|
|
|
| 32 |
key: '1',
|
| 33 |
label: (
|
| 34 |
<Space>
|
| 35 |
+
Delete
|
| 36 |
+
<DeleteOutlined />
|
| 37 |
</Space>
|
| 38 |
),
|
| 39 |
},
|
| 40 |
];
|
| 41 |
|
| 42 |
+
const handleDropdownMenuClick: MenuProps['onClick'] = ({ domEvent, key }) => {
|
| 43 |
+
domEvent.preventDefault();
|
| 44 |
+
domEvent.stopPropagation();
|
| 45 |
+
if (key === '1') {
|
| 46 |
+
handleDelete();
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
const removeKnowledge = () => {
|
| 51 |
+
return dispatch({
|
| 52 |
type: 'knowledgeModel/rmKb',
|
| 53 |
payload: {
|
| 54 |
+
kb_id: item.id,
|
| 55 |
},
|
| 56 |
});
|
| 57 |
};
|
| 58 |
|
| 59 |
+
const handleCardClick = (e: MouseEvent<HTMLElement>) => {
|
| 60 |
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${item.id}`);
|
| 61 |
};
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
return (
|
| 64 |
<Card className={styles.card} onClick={handleCardClick}>
|
| 65 |
<div className={styles.container}>
|
|
|
|
| 67 |
<Avatar size={34} icon={<UserOutlined />} />
|
| 68 |
|
| 69 |
<span className={styles.delete}>
|
| 70 |
+
<Dropdown
|
| 71 |
+
menu={{
|
| 72 |
+
items,
|
| 73 |
+
onClick: handleDropdownMenuClick,
|
| 74 |
+
}}
|
|
|
|
| 75 |
>
|
|
|
|
|
|
|
|
|
|
| 76 |
<MoreIcon />
|
| 77 |
</Dropdown>
|
| 78 |
</span>
|
web/src/pages/knowledge/knowledge-creating-modal/index.tsx
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
| 2 |
+
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
| 3 |
+
import { Form, Input, Modal } from 'antd';
|
| 4 |
+
import { useDispatch, useNavigate, useSelector } from 'umi';
|
| 5 |
+
|
| 6 |
+
type FieldType = {
|
| 7 |
+
name?: string;
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
const KnowledgeCreatingModal = ({
|
| 11 |
+
visible,
|
| 12 |
+
hideModal,
|
| 13 |
+
}: Omit<IModalManagerChildrenProps, 'showModal'>) => {
|
| 14 |
+
const [form] = Form.useForm();
|
| 15 |
+
const dispatch = useDispatch();
|
| 16 |
+
const loading = useSelector(
|
| 17 |
+
(state: any) => state.loading.effects['kSModel/createKb'],
|
| 18 |
+
);
|
| 19 |
+
const navigate = useNavigate();
|
| 20 |
+
|
| 21 |
+
const handleOk = async () => {
|
| 22 |
+
const ret = await form.validateFields();
|
| 23 |
+
|
| 24 |
+
const data = await dispatch<any>({
|
| 25 |
+
type: 'kSModel/createKb',
|
| 26 |
+
payload: {
|
| 27 |
+
name: ret.name,
|
| 28 |
+
},
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
if (data.retcode === 0) {
|
| 32 |
+
navigate(
|
| 33 |
+
`/knowledge/${KnowledgeRouteKey.Configuration}?id=${data.data.kb_id}`,
|
| 34 |
+
);
|
| 35 |
+
hideModal();
|
| 36 |
+
}
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
const handleCancel = () => {
|
| 40 |
+
hideModal();
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
const onFinish = (values: any) => {
|
| 44 |
+
console.log('Success:', values);
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
const onFinishFailed = (errorInfo: any) => {
|
| 48 |
+
console.log('Failed:', errorInfo);
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
return (
|
| 52 |
+
<Modal
|
| 53 |
+
title="Create knowledge base"
|
| 54 |
+
open={visible}
|
| 55 |
+
onOk={handleOk}
|
| 56 |
+
onCancel={handleCancel}
|
| 57 |
+
okButtonProps={{ loading }}
|
| 58 |
+
>
|
| 59 |
+
<Form
|
| 60 |
+
name="Create"
|
| 61 |
+
labelCol={{ span: 4 }}
|
| 62 |
+
wrapperCol={{ span: 20 }}
|
| 63 |
+
style={{ maxWidth: 600 }}
|
| 64 |
+
onFinish={onFinish}
|
| 65 |
+
onFinishFailed={onFinishFailed}
|
| 66 |
+
autoComplete="off"
|
| 67 |
+
form={form}
|
| 68 |
+
>
|
| 69 |
+
<Form.Item<FieldType>
|
| 70 |
+
label="Name"
|
| 71 |
+
name="name"
|
| 72 |
+
rules={[{ required: true, message: 'Please input name!' }]}
|
| 73 |
+
>
|
| 74 |
+
<Input />
|
| 75 |
+
</Form.Item>
|
| 76 |
+
</Form>
|
| 77 |
+
</Modal>
|
| 78 |
+
);
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
export default KnowledgeCreatingModal;
|
web/src/services/kbService.ts
CHANGED
|
@@ -21,6 +21,7 @@ const {
|
|
| 21 |
rm_chunk,
|
| 22 |
retrieval_test,
|
| 23 |
document_rename,
|
|
|
|
| 24 |
} = api;
|
| 25 |
|
| 26 |
const methods = {
|
|
@@ -66,6 +67,10 @@ const methods = {
|
|
| 66 |
url: document_create,
|
| 67 |
method: 'post',
|
| 68 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
document_change_parser: {
|
| 70 |
url: document_change_parser,
|
| 71 |
method: 'post',
|
|
|
|
| 21 |
rm_chunk,
|
| 22 |
retrieval_test,
|
| 23 |
document_rename,
|
| 24 |
+
document_run,
|
| 25 |
} = api;
|
| 26 |
|
| 27 |
const methods = {
|
|
|
|
| 67 |
url: document_create,
|
| 68 |
method: 'post',
|
| 69 |
},
|
| 70 |
+
document_run: {
|
| 71 |
+
url: document_run,
|
| 72 |
+
method: 'post',
|
| 73 |
+
},
|
| 74 |
document_change_parser: {
|
| 75 |
url: document_change_parser,
|
| 76 |
method: 'post',
|
web/src/utils/api.ts
CHANGED
|
@@ -40,5 +40,6 @@ export default {
|
|
| 40 |
document_rm: `${api_host}/document/rm`,
|
| 41 |
document_rename: `${api_host}/document/rename`,
|
| 42 |
document_create: `${api_host}/document/create`,
|
|
|
|
| 43 |
document_change_parser: `${api_host}/document/change_parser`,
|
| 44 |
};
|
|
|
|
| 40 |
document_rm: `${api_host}/document/rm`,
|
| 41 |
document_rename: `${api_host}/document/rename`,
|
| 42 |
document_create: `${api_host}/document/create`,
|
| 43 |
+
document_run: `${api_host}/document/run`,
|
| 44 |
document_change_parser: `${api_host}/document/change_parser`,
|
| 45 |
};
|
web/src/utils/{stroreUtil.ts → storeUtil.ts}
RENAMED
|
File without changes
|