yqj123
commited on
Commit
·
f3dd131
1
Parent(s):
103e12b
set port (#39)
Browse files* set port
* add knowledge-search
* update text
- web/package.json +2 -1
- web/src/pages/add-knowledge/components/knowledge-chunk/{createModal.tsx → components/createModal.tsx} +7 -4
- web/src/pages/add-knowledge/components/knowledge-chunk/{editTag.tsx → components/editTag.tsx} +0 -0
- web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx +5 -4
- web/src/pages/add-knowledge/components/knowledge-chunk/model.ts +2 -0
- web/src/pages/add-knowledge/components/knowledge-file/createEFileModal.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-search/index.less +79 -0
- web/src/pages/add-knowledge/components/knowledge-search/index.tsx +247 -3
- web/src/pages/add-knowledge/components/knowledge-search/model.ts +158 -0
- web/src/pages/add-knowledge/index.tsx +13 -7
- web/src/pages/login/index.tsx +4 -4
- web/src/pages/setting/CPwModal.tsx +1 -1
- web/src/pages/setting/SSModal.tsx +4 -4
- web/src/services/kbService.ts +9 -2
- web/src/utils/api.ts +2 -0
web/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"private": true,
|
3 |
"author": "zhaofengchao <[email protected]>",
|
4 |
"scripts": {
|
5 |
-
"dev": "
|
6 |
"build": "umi build",
|
7 |
"postinstall": "umi setup",
|
8 |
"setup": "umi setup",
|
@@ -30,6 +30,7 @@
|
|
30 |
"@types/react": "^18.0.33",
|
31 |
"@types/react-dom": "^18.0.11",
|
32 |
"@umijs/plugins": "^4.1.0",
|
|
|
33 |
"typescript": "^5.0.3",
|
34 |
"umi-plugin-icons": "^0.1.1"
|
35 |
}
|
|
|
2 |
"private": true,
|
3 |
"author": "zhaofengchao <[email protected]>",
|
4 |
"scripts": {
|
5 |
+
"dev": "cross-env PORT=9000 umi dev",
|
6 |
"build": "umi build",
|
7 |
"postinstall": "umi setup",
|
8 |
"setup": "umi setup",
|
|
|
30 |
"@types/react": "^18.0.33",
|
31 |
"@types/react-dom": "^18.0.11",
|
32 |
"@umijs/plugins": "^4.1.0",
|
33 |
+
"cross-env": "^7.0.3",
|
34 |
"typescript": "^5.0.3",
|
35 |
"umi-plugin-icons": "^0.1.1"
|
36 |
}
|
web/src/pages/add-knowledge/components/knowledge-chunk/{createModal.tsx → components/createModal.tsx}
RENAMED
@@ -14,10 +14,12 @@ interface kFProps {
|
|
14 |
dispatch: Dispatch;
|
15 |
chunkModel: chunkModelState;
|
16 |
getChunkList: () => void;
|
17 |
-
|
|
|
|
|
18 |
}
|
19 |
-
const Index: React.FC<kFProps> = ({
|
20 |
-
const {
|
21 |
const [important_kwd, setImportantKwd] = useState(['Unremovable', 'Tag 2', 'Tag 3']);
|
22 |
const { t } = useTranslation()
|
23 |
const handleCancel = () => {
|
@@ -29,6 +31,7 @@ const Index: React.FC<kFProps> = ({ chunkModel, dispatch, getChunkList, doc_id }
|
|
29 |
});
|
30 |
};
|
31 |
useEffect(() => {
|
|
|
32 |
if (chunk_id && isShowCreateModal) {
|
33 |
dispatch({
|
34 |
type: 'chunkModel/get_chunk',
|
@@ -85,7 +88,7 @@ const Index: React.FC<kFProps> = ({ chunkModel, dispatch, getChunkList, doc_id }
|
|
85 |
<Form.Item<FieldType>
|
86 |
label="chunk 内容"
|
87 |
name="content_ltks"
|
88 |
-
rules={[{ required: true, message: 'Please input
|
89 |
>
|
90 |
<Input.TextArea />
|
91 |
</Form.Item>
|
|
|
14 |
dispatch: Dispatch;
|
15 |
chunkModel: chunkModelState;
|
16 |
getChunkList: () => void;
|
17 |
+
isShowCreateModal: boolean;
|
18 |
+
doc_id: string;
|
19 |
+
chunk_id: string
|
20 |
}
|
21 |
+
const Index: React.FC<kFProps> = ({ dispatch, getChunkList, doc_id, isShowCreateModal, chunk_id }) => {
|
22 |
+
// const { , chunkInfo } = chunkModel
|
23 |
const [important_kwd, setImportantKwd] = useState(['Unremovable', 'Tag 2', 'Tag 3']);
|
24 |
const { t } = useTranslation()
|
25 |
const handleCancel = () => {
|
|
|
31 |
});
|
32 |
};
|
33 |
useEffect(() => {
|
34 |
+
console.log(chunk_id, isShowCreateModal)
|
35 |
if (chunk_id && isShowCreateModal) {
|
36 |
dispatch({
|
37 |
type: 'chunkModel/get_chunk',
|
|
|
88 |
<Form.Item<FieldType>
|
89 |
label="chunk 内容"
|
90 |
name="content_ltks"
|
91 |
+
rules={[{ required: true, message: 'Please input value!' }]}
|
92 |
>
|
93 |
<Input.TextArea />
|
94 |
</Form.Item>
|
web/src/pages/add-knowledge/components/knowledge-chunk/{editTag.tsx → components/editTag.tsx}
RENAMED
File without changes
|
web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx
CHANGED
@@ -4,7 +4,7 @@ import { Card, Row, Col, Input, Select, Switch, Pagination, Spin, Button, Popcon
|
|
4 |
import { MinusSquareOutlined, DeleteOutlined, } from '@ant-design/icons';
|
5 |
import type { PaginationProps } from 'antd';
|
6 |
import { api_host } from '@/utils/api'
|
7 |
-
import CreateModal from './createModal'
|
8 |
|
9 |
|
10 |
import styles from './index.less'
|
@@ -21,7 +21,7 @@ const Index: React.FC<chunkProps> = ({ chunkModel, dispatch, doc_id }) => {
|
|
21 |
const navigate = useNavigate()
|
22 |
const [pagination, setPagination] = useState({ page: 1, size: 30 })
|
23 |
// const [datas, setDatas] = useState(data)
|
24 |
-
const { data = [], total, loading } = chunkModel
|
25 |
console.log(chunkModel)
|
26 |
const getChunkList = (value?: string) => {
|
27 |
dispatch({
|
@@ -66,7 +66,8 @@ const Index: React.FC<chunkProps> = ({ chunkModel, dispatch, doc_id }) => {
|
|
66 |
type: 'chunkModel/updateState',
|
67 |
payload: {
|
68 |
isShowCreateModal: true,
|
69 |
-
chunk_id
|
|
|
70 |
},
|
71 |
callback: getChunkList
|
72 |
});
|
@@ -216,7 +217,7 @@ const Index: React.FC<chunkProps> = ({ chunkModel, dispatch, doc_id }) => {
|
|
216 |
</div>
|
217 |
|
218 |
</div >
|
219 |
-
<CreateModal doc_id={doc_id} getChunkList={getChunkList} />
|
220 |
</>
|
221 |
)
|
222 |
};
|
|
|
4 |
import { MinusSquareOutlined, DeleteOutlined, } from '@ant-design/icons';
|
5 |
import type { PaginationProps } from 'antd';
|
6 |
import { api_host } from '@/utils/api'
|
7 |
+
import CreateModal from './components/createModal'
|
8 |
|
9 |
|
10 |
import styles from './index.less'
|
|
|
21 |
const navigate = useNavigate()
|
22 |
const [pagination, setPagination] = useState({ page: 1, size: 30 })
|
23 |
// const [datas, setDatas] = useState(data)
|
24 |
+
const { data = [], total, loading, chunk_id, isShowCreateModal } = chunkModel
|
25 |
console.log(chunkModel)
|
26 |
const getChunkList = (value?: string) => {
|
27 |
dispatch({
|
|
|
66 |
type: 'chunkModel/updateState',
|
67 |
payload: {
|
68 |
isShowCreateModal: true,
|
69 |
+
chunk_id,
|
70 |
+
doc_id
|
71 |
},
|
72 |
callback: getChunkList
|
73 |
});
|
|
|
217 |
</div>
|
218 |
|
219 |
</div >
|
220 |
+
<CreateModal doc_id={doc_id} isShowCreateModal={isShowCreateModal} chunk_id={chunk_id} getChunkList={getChunkList} />
|
221 |
</>
|
222 |
)
|
223 |
};
|
web/src/pages/add-knowledge/components/knowledge-chunk/model.ts
CHANGED
@@ -8,6 +8,7 @@ export interface chunkModelState {
|
|
8 |
total: number;
|
9 |
isShowCreateModal: boolean;
|
10 |
chunk_id: string;
|
|
|
11 |
chunkInfo: any
|
12 |
}
|
13 |
export interface chunkgModelType {
|
@@ -33,6 +34,7 @@ const Model: chunkgModelType = {
|
|
33 |
total: 0,
|
34 |
isShowCreateModal: false,
|
35 |
chunk_id: '',
|
|
|
36 |
chunkInfo: {}
|
37 |
},
|
38 |
subscriptions: {
|
|
|
8 |
total: number;
|
9 |
isShowCreateModal: boolean;
|
10 |
chunk_id: string;
|
11 |
+
doc_id: string;
|
12 |
chunkInfo: any
|
13 |
}
|
14 |
export interface chunkgModelType {
|
|
|
34 |
total: 0,
|
35 |
isShowCreateModal: false,
|
36 |
chunk_id: '',
|
37 |
+
doc_id: '',
|
38 |
chunkInfo: {}
|
39 |
},
|
40 |
subscriptions: {
|
web/src/pages/add-knowledge/components/knowledge-file/createEFileModal.tsx
CHANGED
@@ -65,7 +65,7 @@ const Index: React.FC<kFProps> = ({ kFModel, dispatch, getKfList, kb_id }) => {
|
|
65 |
<Form.Item<FieldType>
|
66 |
label="文件名"
|
67 |
name="name"
|
68 |
-
rules={[{ required: true, message: 'Please input
|
69 |
>
|
70 |
<Input />
|
71 |
</Form.Item>
|
|
|
65 |
<Form.Item<FieldType>
|
66 |
label="文件名"
|
67 |
name="name"
|
68 |
+
rules={[{ required: true, message: 'Please input value!' }]}
|
69 |
>
|
70 |
<Input />
|
71 |
</Form.Item>
|
web/src/pages/add-knowledge/components/knowledge-search/index.less
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.chunkPage {
|
2 |
+
padding: 24px;
|
3 |
+
display: flex;
|
4 |
+
height: calc(100vh - 112px);
|
5 |
+
// flex-direction: column;
|
6 |
+
|
7 |
+
.filter {
|
8 |
+
margin-right: 20px;
|
9 |
+
display: flex;
|
10 |
+
height: 32px;
|
11 |
+
width: 300px;
|
12 |
+
flex-wrap: wrap;
|
13 |
+
justify-content: space-between;
|
14 |
+
}
|
15 |
+
|
16 |
+
.pageContainer {
|
17 |
+
flex: 1;
|
18 |
+
display: flex;
|
19 |
+
flex-direction: column;
|
20 |
+
|
21 |
+
.pageContent {
|
22 |
+
flex: 1;
|
23 |
+
width: 100%;
|
24 |
+
padding-right: 12px;
|
25 |
+
overflow-y: auto;
|
26 |
+
|
27 |
+
.spin {
|
28 |
+
min-height: 400px;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
.pageFooter {
|
33 |
+
height: 32px;
|
34 |
+
float: right;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
.container {
|
41 |
+
height: 100px;
|
42 |
+
display: flex;
|
43 |
+
flex-direction: column;
|
44 |
+
justify-content: space-between;
|
45 |
+
|
46 |
+
.content {
|
47 |
+
display: flex;
|
48 |
+
justify-content: space-between;
|
49 |
+
|
50 |
+
.context {
|
51 |
+
flex: 1;
|
52 |
+
// width: 207px;
|
53 |
+
height: 88px;
|
54 |
+
overflow: hidden;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
.footer {
|
59 |
+
height: 20px;
|
60 |
+
|
61 |
+
.text {
|
62 |
+
margin-left: 10px;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
.card {
|
68 |
+
:global {
|
69 |
+
.ant-card-body {
|
70 |
+
padding: 10px;
|
71 |
+
margin: 0;
|
72 |
+
}
|
73 |
+
|
74 |
+
margin-bottom: 10px;
|
75 |
+
}
|
76 |
+
|
77 |
+
cursor: pointer;
|
78 |
+
|
79 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-search/index.tsx
CHANGED
@@ -1,3 +1,247 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React, { useEffect, useState, useCallback, } from 'react';
|
2 |
+
import { useNavigate, connect, Dispatch } from 'umi'
|
3 |
+
import { Card, Row, Col, Input, Select, Switch, Pagination, Spin, Button, Popconfirm } from 'antd';
|
4 |
+
import { MinusSquareOutlined, DeleteOutlined, } from '@ant-design/icons';
|
5 |
+
import type { PaginationProps } from 'antd';
|
6 |
+
import { api_host } from '@/utils/api'
|
7 |
+
import CreateModal from '../knowledge-chunk/components/createModal'
|
8 |
+
|
9 |
+
|
10 |
+
import styles from './index.less'
|
11 |
+
import { debounce } from 'lodash';
|
12 |
+
import type { kSearchModelState } from './model'
|
13 |
+
import type { chunkModelState } from '../knowledge-chunk/model'
|
14 |
+
interface chunkProps {
|
15 |
+
dispatch: Dispatch;
|
16 |
+
kSearchModel: kSearchModelState;
|
17 |
+
chunkModel: chunkModelState;
|
18 |
+
kb_id: string
|
19 |
+
}
|
20 |
+
const Index: React.FC<chunkProps> = ({ kSearchModel, chunkModel, dispatch, kb_id }) => {
|
21 |
+
|
22 |
+
const { data = [], total, loading, d_list = [], question, doc_ids, pagination, } = kSearchModel
|
23 |
+
const { chunk_id, doc_id, isShowCreateModal } = chunkModel
|
24 |
+
const getChunkList = () => {
|
25 |
+
dispatch({
|
26 |
+
type: 'kSearchModel/updateState',
|
27 |
+
payload: {
|
28 |
+
loading: true
|
29 |
+
}
|
30 |
+
});
|
31 |
+
interface payloadType {
|
32 |
+
kb_id: string;
|
33 |
+
question?: string;
|
34 |
+
doc_ids: any[];
|
35 |
+
similarity_threshold?: number
|
36 |
+
}
|
37 |
+
const payload: payloadType = {
|
38 |
+
kb_id,
|
39 |
+
question,
|
40 |
+
doc_ids,
|
41 |
+
similarity_threshold: 0.1
|
42 |
+
}
|
43 |
+
dispatch({
|
44 |
+
type: 'kSearchModel/chunk_list',
|
45 |
+
payload: {
|
46 |
+
...payload,
|
47 |
+
...pagination
|
48 |
+
}
|
49 |
+
});
|
50 |
+
}
|
51 |
+
const confirm = (id: string) => {
|
52 |
+
console.log(id)
|
53 |
+
dispatch({
|
54 |
+
type: 'kSearchModel/rm_chunk',
|
55 |
+
payload: {
|
56 |
+
chunk_ids: [id]
|
57 |
+
},
|
58 |
+
callback: getChunkList
|
59 |
+
});
|
60 |
+
};
|
61 |
+
const handleEditchunk = (item: any) => {
|
62 |
+
const { chunk_id, doc_id } = item
|
63 |
+
dispatch({
|
64 |
+
type: 'chunkModel/updateState',
|
65 |
+
payload: {
|
66 |
+
isShowCreateModal: true,
|
67 |
+
chunk_id,
|
68 |
+
doc_id
|
69 |
+
},
|
70 |
+
callback: getChunkList
|
71 |
+
});
|
72 |
+
}
|
73 |
+
const onShowSizeChange: PaginationProps['onShowSizeChange'] = (page, size) => {
|
74 |
+
dispatch({
|
75 |
+
type: 'kSearchModel/updateState',
|
76 |
+
payload: {
|
77 |
+
pagination: { page, size }
|
78 |
+
}
|
79 |
+
});
|
80 |
+
};
|
81 |
+
useEffect(() => {
|
82 |
+
dispatch({
|
83 |
+
type: 'kSearchModel/updateState',
|
84 |
+
payload: {
|
85 |
+
loading: false,
|
86 |
+
doc_ids: [],
|
87 |
+
question: ""
|
88 |
+
}
|
89 |
+
});
|
90 |
+
dispatch({
|
91 |
+
type: 'kSearchModel/getKfList',
|
92 |
+
payload: {
|
93 |
+
kb_id
|
94 |
+
}
|
95 |
+
|
96 |
+
});
|
97 |
+
}, [])
|
98 |
+
const switchChunk = (item: any, available_int: boolean) => {
|
99 |
+
const { chunk_id, doc_id } = item
|
100 |
+
dispatch({
|
101 |
+
type: 'kSearchModel/updateState',
|
102 |
+
payload: {
|
103 |
+
loading: true
|
104 |
+
}
|
105 |
+
});
|
106 |
+
dispatch({
|
107 |
+
type: 'kSearchModel/switch_chunk',
|
108 |
+
payload: {
|
109 |
+
chunk_ids: [chunk_id],
|
110 |
+
doc_id,
|
111 |
+
available_int
|
112 |
+
},
|
113 |
+
callback: getChunkList
|
114 |
+
});
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
useEffect(() => {
|
119 |
+
getChunkList()
|
120 |
+
}, [doc_ids, pagination, question])
|
121 |
+
const debounceChange = debounce((value) => {
|
122 |
+
dispatch({
|
123 |
+
type: 'kSearchModel/updateState',
|
124 |
+
payload: {
|
125 |
+
question: value
|
126 |
+
}
|
127 |
+
});
|
128 |
+
}, 300)
|
129 |
+
const debounceCallback = useCallback((value: string) => debounceChange(value), [])
|
130 |
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
131 |
+
const value = e.target.value
|
132 |
+
debounceCallback(value)
|
133 |
+
}
|
134 |
+
const handleSelectChange = (value:
|
135 |
+
any[]) => {
|
136 |
+
dispatch({
|
137 |
+
type: 'kSearchModel/updateState',
|
138 |
+
payload: {
|
139 |
+
doc_ids: value
|
140 |
+
}
|
141 |
+
});
|
142 |
+
}
|
143 |
+
console.log('loading', loading)
|
144 |
+
return (<>
|
145 |
+
<div className={styles.chunkPage}>
|
146 |
+
<div className={styles.filter}>
|
147 |
+
<Select
|
148 |
+
showSearch
|
149 |
+
placeholder="文件列表"
|
150 |
+
optionFilterProp="children"
|
151 |
+
onChange={handleSelectChange}
|
152 |
+
style={{ width: 300, marginBottom: 20 }}
|
153 |
+
options={d_list}
|
154 |
+
fieldNames={{ label: 'name', value: 'id' }}
|
155 |
+
mode='multiple'
|
156 |
+
/>
|
157 |
+
|
158 |
+
<Input.TextArea autoSize={{ minRows: 6, maxRows: 6 }} placeholder="搜索" style={{ width: 300 }} allowClear onChange={handleInputChange} />
|
159 |
+
|
160 |
+
</div>
|
161 |
+
<div className={styles.pageContainer}>
|
162 |
+
<div className={styles.pageContent}>
|
163 |
+
<Spin spinning={loading} className={styles.spin} size='large'>
|
164 |
+
<Row gutter={{ xs: 8, sm: 16, md: 24, lg: 24 }} >
|
165 |
+
{
|
166 |
+
data.map((item: any) => {
|
167 |
+
return (<Col className="gutter-row" key={item.chunk_id} xs={24} sm={12} md={12} lg={8}>
|
168 |
+
<Card className={styles.card}
|
169 |
+
onClick={() => { handleEditchunk(item) }}
|
170 |
+
>
|
171 |
+
<img style={{ width: '50px' }} src={`${api_host}/document/image/${item.img_id}`} alt="" />
|
172 |
+
<div className={styles.container}>
|
173 |
+
<div className={styles.content}>
|
174 |
+
<span className={styles.context}>
|
175 |
+
{item.content_ltks}
|
176 |
+
</span>
|
177 |
+
<span className={styles.delete}>
|
178 |
+
<Switch size="small" defaultValue={item.doc_ids == '1'} onChange={(checked: boolean, e: any) => {
|
179 |
+
e.stopPropagation();
|
180 |
+
e.nativeEvent.stopImmediatePropagation(); switchChunk(item, checked)
|
181 |
+
}} />
|
182 |
+
</span>
|
183 |
+
</div>
|
184 |
+
<div className={styles.footer}>
|
185 |
+
<span className={styles.text}>
|
186 |
+
<MinusSquareOutlined />{item.doc_num}文档
|
187 |
+
</span>
|
188 |
+
<span className={styles.text}>
|
189 |
+
<MinusSquareOutlined />{item.chunk_num}个
|
190 |
+
</span>
|
191 |
+
<span className={styles.text}>
|
192 |
+
<MinusSquareOutlined />{item.token_num}千字符
|
193 |
+
</span>
|
194 |
+
<span style={{ float: 'right' }}>
|
195 |
+
<Popconfirm
|
196 |
+
title="Delete the task"
|
197 |
+
description="Are you sure to delete this task?"
|
198 |
+
onConfirm={(e: any) => {
|
199 |
+
e.stopPropagation();
|
200 |
+
e.nativeEvent.stopImmediatePropagation()
|
201 |
+
console.log(confirm)
|
202 |
+
confirm(item.chunk_id)
|
203 |
+
|
204 |
+
}}
|
205 |
+
okText="Yes"
|
206 |
+
cancelText="No"
|
207 |
+
>
|
208 |
+
<DeleteOutlined onClick={(e) => {
|
209 |
+
e.stopPropagation();
|
210 |
+
e.nativeEvent.stopImmediatePropagation()
|
211 |
+
}} />
|
212 |
+
</Popconfirm>
|
213 |
+
|
214 |
+
</span>
|
215 |
+
</div>
|
216 |
+
|
217 |
+
</div>
|
218 |
+
</Card>
|
219 |
+
</Col>)
|
220 |
+
})
|
221 |
+
}
|
222 |
+
</Row>
|
223 |
+
</Spin>
|
224 |
+
|
225 |
+
</div>
|
226 |
+
<div className={styles.pageFooter}>
|
227 |
+
<Pagination
|
228 |
+
responsive
|
229 |
+
showLessItems
|
230 |
+
showQuickJumper
|
231 |
+
showSizeChanger
|
232 |
+
onChange={onShowSizeChange}
|
233 |
+
defaultPageSize={30}
|
234 |
+
pageSizeOptions={[30, 60, 90]}
|
235 |
+
defaultCurrent={pagination.page}
|
236 |
+
total={total}
|
237 |
+
/>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
|
241 |
+
</div >
|
242 |
+
<CreateModal getChunkList={getChunkList} isShowCreateModal={isShowCreateModal} chunk_id={chunk_id} doc_id={doc_id} />
|
243 |
+
</>
|
244 |
+
)
|
245 |
+
};
|
246 |
+
|
247 |
+
export default connect(({ kSearchModel, chunkModel, loading }) => ({ kSearchModel, chunkModel, loading }))(Index);
|
web/src/pages/add-knowledge/components/knowledge-search/model.ts
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Effect, Reducer, Subscription } from 'umi'
|
2 |
+
import { message } from 'antd';
|
3 |
+
import kbService from '@/services/kbService';
|
4 |
+
|
5 |
+
export interface kSearchModelState {
|
6 |
+
loading: boolean;
|
7 |
+
data: any[];
|
8 |
+
total: number;
|
9 |
+
isShowCreateModal: boolean;
|
10 |
+
chunk_id: string;
|
11 |
+
chunkInfo: any;
|
12 |
+
d_list: any[];
|
13 |
+
question: string;
|
14 |
+
doc_ids: any[];
|
15 |
+
pagination: any;
|
16 |
+
doc_id: string
|
17 |
+
|
18 |
+
}
|
19 |
+
export interface chunkgModelType {
|
20 |
+
namespace: 'kSearchModel';
|
21 |
+
state: kSearchModelState;
|
22 |
+
effects: {
|
23 |
+
chunk_list: Effect;
|
24 |
+
get_chunk: Effect;
|
25 |
+
create_hunk: Effect;
|
26 |
+
switch_chunk: Effect;
|
27 |
+
rm_chunk: Effect;
|
28 |
+
getKfList: Effect;
|
29 |
+
};
|
30 |
+
reducers: {
|
31 |
+
updateState: Reducer<kSearchModelState>;
|
32 |
+
};
|
33 |
+
subscriptions: { setup: Subscription };
|
34 |
+
}
|
35 |
+
const Model: chunkgModelType = {
|
36 |
+
namespace: 'kSearchModel',
|
37 |
+
state: {
|
38 |
+
loading: false,
|
39 |
+
data: [],
|
40 |
+
total: 0,
|
41 |
+
isShowCreateModal: false,
|
42 |
+
chunk_id: '',
|
43 |
+
chunkInfo: {},
|
44 |
+
d_list: [],
|
45 |
+
question: '',
|
46 |
+
doc_ids: [],
|
47 |
+
pagination: { page: 1, size: 30 },
|
48 |
+
doc_id: ''
|
49 |
+
},
|
50 |
+
subscriptions: {
|
51 |
+
setup({ dispatch, history }) {
|
52 |
+
history.listen(location => {
|
53 |
+
console.log(location)
|
54 |
+
});
|
55 |
+
}
|
56 |
+
},
|
57 |
+
effects: {
|
58 |
+
*getKfList({ payload = {} }, { call, put }) {
|
59 |
+
const { data, response } = yield call(kbService.get_document_list, payload);
|
60 |
+
|
61 |
+
const { retcode, data: res, retmsg } = data
|
62 |
+
if (retcode === 0) {
|
63 |
+
yield put({
|
64 |
+
type: 'updateState',
|
65 |
+
payload: {
|
66 |
+
d_list: res
|
67 |
+
}
|
68 |
+
});
|
69 |
+
}
|
70 |
+
},
|
71 |
+
* chunk_list({ payload = {}, callback }, { call, put }) {
|
72 |
+
const { data, response } = yield call(kbService.retrieval_test, payload);
|
73 |
+
const { retcode, data: res, retmsg } = data
|
74 |
+
if (retcode === 0) {
|
75 |
+
console.log(res)
|
76 |
+
yield put({
|
77 |
+
type: 'updateState',
|
78 |
+
payload: {
|
79 |
+
data: res.chunks,
|
80 |
+
total: res.total,
|
81 |
+
loading: false
|
82 |
+
}
|
83 |
+
});
|
84 |
+
callback && callback()
|
85 |
+
|
86 |
+
}
|
87 |
+
},
|
88 |
+
*switch_chunk({ payload = {}, callback }, { call, put }) {
|
89 |
+
const { data, response } = yield call(kbService.switch_chunk, payload);
|
90 |
+
const { retcode, data: res, retmsg } = data
|
91 |
+
if (retcode === 0) {
|
92 |
+
callback && callback()
|
93 |
+
|
94 |
+
}
|
95 |
+
},
|
96 |
+
*rm_chunk({ payload = {}, callback }, { call, put }) {
|
97 |
+
console.log('shanchu')
|
98 |
+
const { data, response } = yield call(kbService.rm_chunk, payload);
|
99 |
+
const { retcode, data: res, retmsg } = data
|
100 |
+
if (retcode === 0) {
|
101 |
+
callback && callback()
|
102 |
+
|
103 |
+
}
|
104 |
+
},
|
105 |
+
* get_chunk({ payload = {}, callback }, { call, put }) {
|
106 |
+
const { data, response } = yield call(kbService.get_chunk, payload);
|
107 |
+
const { retcode, data: res, retmsg } = data
|
108 |
+
if (retcode === 0) {
|
109 |
+
|
110 |
+
yield put({
|
111 |
+
type: 'updateState',
|
112 |
+
payload: {
|
113 |
+
chunkInfo: res
|
114 |
+
}
|
115 |
+
});
|
116 |
+
callback && callback(res)
|
117 |
+
|
118 |
+
}
|
119 |
+
},
|
120 |
+
*create_hunk({ payload = {} }, { call, put }) {
|
121 |
+
yield put({
|
122 |
+
type: 'updateState',
|
123 |
+
payload: {
|
124 |
+
loading: true
|
125 |
+
}
|
126 |
+
});
|
127 |
+
let service = kbService.create_chunk
|
128 |
+
if (payload.chunk_id) {
|
129 |
+
service = kbService.set_chunk
|
130 |
+
}
|
131 |
+
const { data, response } = yield call(service, payload);
|
132 |
+
const { retcode, data: res, retmsg } = data
|
133 |
+
yield put({
|
134 |
+
type: 'updateState',
|
135 |
+
payload: {
|
136 |
+
loading: false
|
137 |
+
}
|
138 |
+
});
|
139 |
+
if (retcode === 0) {
|
140 |
+
yield put({
|
141 |
+
type: 'updateState',
|
142 |
+
payload: {
|
143 |
+
isShowCreateModal: false
|
144 |
+
}
|
145 |
+
});
|
146 |
+
}
|
147 |
+
},
|
148 |
+
},
|
149 |
+
reducers: {
|
150 |
+
updateState(state, { payload }) {
|
151 |
+
return {
|
152 |
+
...state,
|
153 |
+
...payload
|
154 |
+
};
|
155 |
+
}
|
156 |
+
}
|
157 |
+
};
|
158 |
+
export default Model;
|
web/src/pages/add-knowledge/index.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { connect, useNavigate, useLocation, Dispatch } from 'umi'
|
2 |
-
import React, { useState, useEffect } from 'react';
|
3 |
import type { MenuProps } from 'antd';
|
4 |
import { Menu } from 'antd';
|
5 |
import {
|
@@ -70,8 +70,10 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
|
|
70 |
label: React.ReactNode,
|
71 |
key: React.Key,
|
72 |
icon?: React.ReactNode,
|
|
|
73 |
children?: MenuItem[],
|
74 |
type?: 'group',
|
|
|
75 |
): MenuItem {
|
76 |
return {
|
77 |
key,
|
@@ -79,13 +81,17 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
|
|
79 |
children,
|
80 |
label,
|
81 |
type,
|
|
|
82 |
} as MenuItem;
|
83 |
}
|
84 |
-
const items: MenuItem[] =
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
89 |
const handleSelect: MenuProps['onSelect'] = (e) => {
|
90 |
navigate(`/knowledge/add/setting?activeKey=${e.key}&id=${id}`);
|
91 |
}
|
@@ -105,7 +111,7 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
|
|
105 |
<div className={styles.content}>
|
106 |
{activeKey === 'file' && !doc_id && <File kb_id={id} />}
|
107 |
{activeKey === 'setting' && <Setting kb_id={id} />}
|
108 |
-
{activeKey === 'search' && <Search />}
|
109 |
{activeKey === 'file' && !!doc_id && <Chunk doc_id={doc_id} />}
|
110 |
|
111 |
</div>
|
|
|
1 |
import { connect, useNavigate, useLocation, Dispatch } from 'umi'
|
2 |
+
import React, { useState, useEffect, useMemo } from 'react';
|
3 |
import type { MenuProps } from 'antd';
|
4 |
import { Menu } from 'antd';
|
5 |
import {
|
|
|
70 |
label: React.ReactNode,
|
71 |
key: React.Key,
|
72 |
icon?: React.ReactNode,
|
73 |
+
disabled?: boolean,
|
74 |
children?: MenuItem[],
|
75 |
type?: 'group',
|
76 |
+
|
77 |
): MenuItem {
|
78 |
return {
|
79 |
key,
|
|
|
81 |
children,
|
82 |
label,
|
83 |
type,
|
84 |
+
disabled
|
85 |
} as MenuItem;
|
86 |
}
|
87 |
+
const items: MenuItem[] = useMemo(() => {
|
88 |
+
const disabled = !id
|
89 |
+
return [
|
90 |
+
getItem('配置', 'setting', <ToolOutlined />),
|
91 |
+
getItem('知识库', 'file', <BarsOutlined />, disabled),
|
92 |
+
getItem('搜索测试', 'search', <SearchOutlined />, disabled),
|
93 |
+
]
|
94 |
+
}, [id]);
|
95 |
const handleSelect: MenuProps['onSelect'] = (e) => {
|
96 |
navigate(`/knowledge/add/setting?activeKey=${e.key}&id=${id}`);
|
97 |
}
|
|
|
111 |
<div className={styles.content}>
|
112 |
{activeKey === 'file' && !doc_id && <File kb_id={id} />}
|
113 |
{activeKey === 'setting' && <Setting kb_id={id} />}
|
114 |
+
{activeKey === 'search' && <Search kb_id={id} />}
|
115 |
{activeKey === 'file' && !!doc_id && <Chunk doc_id={doc_id} />}
|
116 |
|
117 |
</div>
|
web/src/pages/login/index.tsx
CHANGED
@@ -79,9 +79,9 @@ const View: FC<LoginProps> = ({
|
|
79 |
{...formItemLayout}
|
80 |
name="email"
|
81 |
label="Email"
|
82 |
-
rules={[{ required: true, message: 'Please input
|
83 |
>
|
84 |
-
<Input size='large' placeholder="Please input
|
85 |
</Form.Item>
|
86 |
{
|
87 |
title === 'register' && <Form.Item
|
@@ -97,9 +97,9 @@ const View: FC<LoginProps> = ({
|
|
97 |
{...formItemLayout}
|
98 |
name="password"
|
99 |
label="Password"
|
100 |
-
rules={[{ required: true, message: 'Please input
|
101 |
>
|
102 |
-
<Input size='large' placeholder="Please input
|
103 |
</Form.Item>
|
104 |
{
|
105 |
title === 'login' && <Form.Item
|
|
|
79 |
{...formItemLayout}
|
80 |
name="email"
|
81 |
label="Email"
|
82 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
83 |
>
|
84 |
+
<Input size='large' placeholder="Please input value" />
|
85 |
</Form.Item>
|
86 |
{
|
87 |
title === 'register' && <Form.Item
|
|
|
97 |
{...formItemLayout}
|
98 |
name="password"
|
99 |
label="Password"
|
100 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
101 |
>
|
102 |
+
<Input size='large' placeholder="Please input value" />
|
103 |
</Form.Item>
|
104 |
{
|
105 |
title === 'login' && <Form.Item
|
web/src/pages/setting/CPwModal.tsx
CHANGED
@@ -71,7 +71,7 @@ const Index: FC<CPwModalProps> = ({ settingModel, dispatch }) => {
|
|
71 |
<Form.Item<FieldType>
|
72 |
label="旧密码"
|
73 |
name="password"
|
74 |
-
rules={[{ required: true, message: 'Please input
|
75 |
>
|
76 |
<Input.Password />
|
77 |
</Form.Item>
|
|
|
71 |
<Form.Item<FieldType>
|
72 |
label="旧密码"
|
73 |
name="password"
|
74 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
75 |
>
|
76 |
<Input.Password />
|
77 |
</Form.Item>
|
web/src/pages/setting/SSModal.tsx
CHANGED
@@ -76,7 +76,7 @@ const Index: FC<SSModalProps> = ({ settingModel, dispatch }) => {
|
|
76 |
<Form.Item<FieldType>
|
77 |
label="embedding 模型"
|
78 |
name="embd_id"
|
79 |
-
rules={[{ required: true, message: 'Please input
|
80 |
initialValue={tenantIfo.embd_id}
|
81 |
|
82 |
>
|
@@ -93,7 +93,7 @@ const Index: FC<SSModalProps> = ({ settingModel, dispatch }) => {
|
|
93 |
<Form.Item<FieldType>
|
94 |
label="chat 模型"
|
95 |
name="llm_id"
|
96 |
-
rules={[{ required: true, message: 'Please input
|
97 |
initialValue={tenantIfo.llm_id}
|
98 |
|
99 |
>
|
@@ -110,7 +110,7 @@ const Index: FC<SSModalProps> = ({ settingModel, dispatch }) => {
|
|
110 |
<Form.Item<FieldType>
|
111 |
label="image2text 模型"
|
112 |
name="img2txt_id"
|
113 |
-
rules={[{ required: true, message: 'Please input
|
114 |
initialValue={tenantIfo.img2txt_id}
|
115 |
|
116 |
>
|
@@ -127,7 +127,7 @@ const Index: FC<SSModalProps> = ({ settingModel, dispatch }) => {
|
|
127 |
<Form.Item<FieldType>
|
128 |
label="speech2text 模型"
|
129 |
name="asr_id"
|
130 |
-
rules={[{ required: true, message: 'Please input
|
131 |
initialValue={tenantIfo.asr_id}
|
132 |
|
133 |
>
|
|
|
76 |
<Form.Item<FieldType>
|
77 |
label="embedding 模型"
|
78 |
name="embd_id"
|
79 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
80 |
initialValue={tenantIfo.embd_id}
|
81 |
|
82 |
>
|
|
|
93 |
<Form.Item<FieldType>
|
94 |
label="chat 模型"
|
95 |
name="llm_id"
|
96 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
97 |
initialValue={tenantIfo.llm_id}
|
98 |
|
99 |
>
|
|
|
110 |
<Form.Item<FieldType>
|
111 |
label="image2text 模型"
|
112 |
name="img2txt_id"
|
113 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
114 |
initialValue={tenantIfo.img2txt_id}
|
115 |
|
116 |
>
|
|
|
127 |
<Form.Item<FieldType>
|
128 |
label="speech2text 模型"
|
129 |
name="asr_id"
|
130 |
+
rules={[{ required: true, message: 'Please input value' }]}
|
131 |
initialValue={tenantIfo.asr_id}
|
132 |
|
133 |
>
|
web/src/services/kbService.ts
CHANGED
@@ -16,7 +16,10 @@ const {
|
|
16 |
chunk_list,
|
17 |
create_chunk,
|
18 |
set_chunk,
|
19 |
-
get_chunk,
|
|
|
|
|
|
|
20 |
interface kbService {
|
21 |
createKb: () => void;
|
22 |
updateKb: () => void;
|
@@ -34,6 +37,7 @@ interface kbService {
|
|
34 |
get_chunk: () => void;
|
35 |
switch_chunk: () => void;
|
36 |
rm_chunk: () => void;
|
|
|
37 |
}
|
38 |
const kbService: kbService = registerServer(
|
39 |
{
|
@@ -104,7 +108,10 @@ const kbService: kbService = registerServer(
|
|
104 |
url: rm_chunk,
|
105 |
method: 'post'
|
106 |
},
|
107 |
-
|
|
|
|
|
|
|
108 |
},
|
109 |
request
|
110 |
);
|
|
|
16 |
chunk_list,
|
17 |
create_chunk,
|
18 |
set_chunk,
|
19 |
+
get_chunk,
|
20 |
+
switch_chunk,
|
21 |
+
rm_chunk,
|
22 |
+
retrieval_test } = api;
|
23 |
interface kbService {
|
24 |
createKb: () => void;
|
25 |
updateKb: () => void;
|
|
|
37 |
get_chunk: () => void;
|
38 |
switch_chunk: () => void;
|
39 |
rm_chunk: () => void;
|
40 |
+
retrieval_test: () => void;
|
41 |
}
|
42 |
const kbService: kbService = registerServer(
|
43 |
{
|
|
|
108 |
url: rm_chunk,
|
109 |
method: 'post'
|
110 |
},
|
111 |
+
retrieval_test: {
|
112 |
+
url: retrieval_test,
|
113 |
+
method: 'post'
|
114 |
+
},
|
115 |
},
|
116 |
request
|
117 |
);
|
web/src/utils/api.ts
CHANGED
@@ -39,6 +39,8 @@ export default {
|
|
39 |
get_chunk: `${api_host}/chunk/get`,
|
40 |
switch_chunk: `${api_host}/chunk/switch`,
|
41 |
rm_chunk: `${api_host}/chunk/rm`,
|
|
|
|
|
42 |
|
43 |
|
44 |
|
|
|
39 |
get_chunk: `${api_host}/chunk/get`,
|
40 |
switch_chunk: `${api_host}/chunk/switch`,
|
41 |
rm_chunk: `${api_host}/chunk/rm`,
|
42 |
+
retrieval_test: `${api_host}/chunk/retrieval_test`,
|
43 |
+
|
44 |
|
45 |
|
46 |
|