balibabu
commited on
Commit
·
967c830
1
Parent(s):
1ed30a6
feat: add image for chunk method (#139)
Browse files* feat: add image of chunk method
* feat: add image for chunk method
- web/package-lock.json +10 -3
- web/package.json +1 -0
- web/src/assets/svg/chunk-method/book-01.svg +0 -0
- web/src/assets/svg/chunk-method/book-02.svg +0 -0
- web/src/assets/svg/chunk-method/book-03.svg +0 -0
- web/src/assets/svg/chunk-method/book-04.svg +0 -0
- web/src/assets/svg/chunk-method/chunk-empty.svg +161 -0
- web/src/assets/svg/chunk-method/law-01.svg +0 -0
- web/src/assets/svg/chunk-method/law-02.svg +0 -0
- web/src/assets/svg/chunk-method/law-03.svg +0 -0
- web/src/assets/svg/chunk-method/law-04.svg +0 -0
- web/src/assets/svg/chunk-method/manual-01.svg +0 -0
- web/src/assets/svg/chunk-method/manual-02.svg +0 -0
- web/src/assets/svg/chunk-method/manual-03.svg +0 -0
- web/src/assets/svg/chunk-method/manual-04.svg +0 -0
- web/src/assets/svg/chunk-method/media-02.svg +0 -0
- web/src/assets/svg/chunk-method/naive-01.svg +0 -0
- web/src/assets/svg/chunk-method/naive-02.svg +0 -0
- web/src/assets/svg/chunk-method/paper-01.svg +0 -0
- web/src/assets/svg/chunk-method/paper-02.svg +0 -0
- web/src/assets/svg/chunk-method/presentation-01.svg +0 -0
- web/src/assets/svg/chunk-method/presentation-02.svg +0 -0
- web/src/assets/svg/chunk-method/qa-01.svg +0 -0
- web/src/assets/svg/chunk-method/qa-02.svg +0 -0
- web/src/assets/svg/chunk-method/resume-01.svg +0 -0
- web/src/assets/svg/chunk-method/resume-02.svg +0 -0
- web/src/assets/svg/chunk-method/table-01.svg +0 -0
- web/src/assets/svg/chunk-method/table-02.svg +0 -0
- web/src/components/svg-icon.tsx +30 -27
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx +71 -0
- web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +141 -156
- web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts +14 -4
- web/src/pages/add-knowledge/components/knowledge-setting/index.less +12 -0
- web/src/pages/add-knowledge/components/knowledge-setting/index.tsx +34 -1
- web/src/pages/add-knowledge/components/knowledge-setting/utils.ts +84 -0
- web/src/pages/user-setting/setting-model/index.tsx +2 -2
- web/tsconfig.json +1 -1
web/package-lock.json
CHANGED
@@ -39,6 +39,7 @@
|
|
39 |
"@types/react-dom": "^18.0.11",
|
40 |
"@types/react-syntax-highlighter": "^15.5.11",
|
41 |
"@types/uuid": "^9.0.8",
|
|
|
42 |
"@umijs/lint": "^4.1.1",
|
43 |
"@umijs/plugins": "^4.1.0",
|
44 |
"cross-env": "^7.0.3",
|
@@ -886,9 +887,9 @@
|
|
886 |
}
|
887 |
},
|
888 |
"node_modules/@babel/runtime": {
|
889 |
-
"version": "7.
|
890 |
-
"resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.
|
891 |
-
"integrity": "sha512
|
892 |
"dependencies": {
|
893 |
"regenerator-runtime": "^0.14.0"
|
894 |
},
|
@@ -2993,6 +2994,12 @@
|
|
2993 |
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==",
|
2994 |
"dev": true
|
2995 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
2996 |
"node_modules/@types/yargs": {
|
2997 |
"version": "16.0.9",
|
2998 |
"resolved": "https://registry.npmmirror.com/@types/yargs/-/yargs-16.0.9.tgz",
|
|
|
39 |
"@types/react-dom": "^18.0.11",
|
40 |
"@types/react-syntax-highlighter": "^15.5.11",
|
41 |
"@types/uuid": "^9.0.8",
|
42 |
+
"@types/webpack-env": "^1.18.4",
|
43 |
"@umijs/lint": "^4.1.1",
|
44 |
"@umijs/plugins": "^4.1.0",
|
45 |
"cross-env": "^7.0.3",
|
|
|
887 |
}
|
888 |
},
|
889 |
"node_modules/@babel/runtime": {
|
890 |
+
"version": "7.24.1",
|
891 |
+
"resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.24.1.tgz",
|
892 |
+
"integrity": "sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==",
|
893 |
"dependencies": {
|
894 |
"regenerator-runtime": "^0.14.0"
|
895 |
},
|
|
|
2994 |
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==",
|
2995 |
"dev": true
|
2996 |
},
|
2997 |
+
"node_modules/@types/webpack-env": {
|
2998 |
+
"version": "1.18.4",
|
2999 |
+
"resolved": "https://registry.npmmirror.com/@types/webpack-env/-/webpack-env-1.18.4.tgz",
|
3000 |
+
"integrity": "sha512-I6e+9+HtWADAWeeJWDFQtdk4EVSAbj6Rtz4q8fJ7mSr1M0jzlFcs8/HZ+Xb5SHzVm1dxH7aUiI+A8kA8Gcrm0A==",
|
3001 |
+
"dev": true
|
3002 |
+
},
|
3003 |
"node_modules/@types/yargs": {
|
3004 |
"version": "16.0.9",
|
3005 |
"resolved": "https://registry.npmmirror.com/@types/yargs/-/yargs-16.0.9.tgz",
|
web/package.json
CHANGED
@@ -43,6 +43,7 @@
|
|
43 |
"@types/react-dom": "^18.0.11",
|
44 |
"@types/react-syntax-highlighter": "^15.5.11",
|
45 |
"@types/uuid": "^9.0.8",
|
|
|
46 |
"@umijs/lint": "^4.1.1",
|
47 |
"@umijs/plugins": "^4.1.0",
|
48 |
"cross-env": "^7.0.3",
|
|
|
43 |
"@types/react-dom": "^18.0.11",
|
44 |
"@types/react-syntax-highlighter": "^15.5.11",
|
45 |
"@types/uuid": "^9.0.8",
|
46 |
+
"@types/webpack-env": "^1.18.4",
|
47 |
"@umijs/lint": "^4.1.1",
|
48 |
"@umijs/plugins": "^4.1.0",
|
49 |
"cross-env": "^7.0.3",
|
web/src/assets/svg/chunk-method/book-01.svg
ADDED
|
web/src/assets/svg/chunk-method/book-02.svg
ADDED
|
web/src/assets/svg/chunk-method/book-03.svg
ADDED
|
web/src/assets/svg/chunk-method/book-04.svg
ADDED
|
web/src/assets/svg/chunk-method/chunk-empty.svg
ADDED
|
web/src/assets/svg/chunk-method/law-01.svg
ADDED
|
web/src/assets/svg/chunk-method/law-02.svg
ADDED
|
web/src/assets/svg/chunk-method/law-03.svg
ADDED
|
web/src/assets/svg/chunk-method/law-04.svg
ADDED
|
web/src/assets/svg/chunk-method/manual-01.svg
ADDED
|
web/src/assets/svg/chunk-method/manual-02.svg
ADDED
|
web/src/assets/svg/chunk-method/manual-03.svg
ADDED
|
web/src/assets/svg/chunk-method/manual-04.svg
ADDED
|
web/src/assets/svg/chunk-method/media-02.svg
ADDED
|
web/src/assets/svg/chunk-method/naive-01.svg
ADDED
|
web/src/assets/svg/chunk-method/naive-02.svg
ADDED
|
web/src/assets/svg/chunk-method/paper-01.svg
ADDED
|
web/src/assets/svg/chunk-method/paper-02.svg
ADDED
|
web/src/assets/svg/chunk-method/presentation-01.svg
ADDED
|
web/src/assets/svg/chunk-method/presentation-02.svg
ADDED
|
web/src/assets/svg/chunk-method/qa-01.svg
ADDED
|
web/src/assets/svg/chunk-method/qa-02.svg
ADDED
|
web/src/assets/svg/chunk-method/resume-01.svg
ADDED
|
web/src/assets/svg/chunk-method/resume-02.svg
ADDED
|
web/src/assets/svg/chunk-method/table-01.svg
ADDED
|
web/src/assets/svg/chunk-method/table-02.svg
ADDED
|
web/src/components/svg-icon.tsx
CHANGED
@@ -1,34 +1,37 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
useDynamicSVGImport,
|
4 |
-
} from '@/hooks/commonHooks';
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
name: string;
|
8 |
-
|
9 |
-
onError?: UseDynamicSVGImportOptions['onError'];
|
10 |
}
|
11 |
|
12 |
-
const SvgIcon
|
13 |
-
name
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
onError,
|
21 |
-
});
|
22 |
-
if (error) {
|
23 |
-
return error.message;
|
24 |
-
}
|
25 |
-
if (loading) {
|
26 |
-
return 'Loading...';
|
27 |
-
}
|
28 |
-
if (SvgIcon) {
|
29 |
-
return <SvgIcon {...rest} />;
|
30 |
-
}
|
31 |
-
return null;
|
32 |
};
|
33 |
|
34 |
export default SvgIcon;
|
|
|
1 |
+
import Icon from '@ant-design/icons';
|
2 |
+
import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';
|
|
|
|
|
3 |
|
4 |
+
const importAll = (requireContext: __WebpackModuleApi.RequireContext) => {
|
5 |
+
const list = requireContext.keys().map((key) => {
|
6 |
+
const name = key.replace(/\.\/(.*)\.\w+$/, '$1');
|
7 |
+
console.log(name, requireContext(key));
|
8 |
+
return { name, value: requireContext(key) };
|
9 |
+
});
|
10 |
+
return list;
|
11 |
+
};
|
12 |
+
|
13 |
+
let routeList: { name: string; value: string }[] = [];
|
14 |
+
|
15 |
+
try {
|
16 |
+
routeList = importAll(require.context('@/assets/svg', true, /\.svg$/));
|
17 |
+
} catch (error) {
|
18 |
+
console.warn(error);
|
19 |
+
routeList = [];
|
20 |
+
}
|
21 |
+
|
22 |
+
interface IProps extends IconComponentProps {
|
23 |
name: string;
|
24 |
+
width: string | number;
|
|
|
25 |
}
|
26 |
|
27 |
+
const SvgIcon = ({ name, width, ...restProps }: IProps) => {
|
28 |
+
const ListItem = routeList.find((item) => item.name === name);
|
29 |
+
return (
|
30 |
+
<Icon
|
31 |
+
component={() => <img src={ListItem?.value} alt="" width={width} />}
|
32 |
+
{...(restProps as any)}
|
33 |
+
/>
|
34 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
};
|
36 |
|
37 |
export default SvgIcon;
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -220,7 +220,7 @@ const KnowledgeFile = () => {
|
|
220 |
key: 'create_date',
|
221 |
},
|
222 |
{
|
223 |
-
title: '
|
224 |
dataIndex: 'parser_id',
|
225 |
key: 'parser_id',
|
226 |
render: (text) => {
|
|
|
220 |
key: 'create_date',
|
221 |
},
|
222 |
{
|
223 |
+
title: 'Chunk Method',
|
224 |
dataIndex: 'parser_id',
|
225 |
key: 'parser_id',
|
226 |
render: (text) => {
|
web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import SvgIcon from '@/components/svg-icon';
|
2 |
+
import { useSelectParserList } from '@/hooks/userSettingHook';
|
3 |
+
import { Col, Divider, Empty, Row, Typography } from 'antd';
|
4 |
+
import { useMemo } from 'react';
|
5 |
+
import styles from './index.less';
|
6 |
+
import { ImageMap, TextMap } from './utils';
|
7 |
+
|
8 |
+
const { Title, Text } = Typography;
|
9 |
+
|
10 |
+
const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => {
|
11 |
+
const parserList = useSelectParserList();
|
12 |
+
|
13 |
+
const item = useMemo(() => {
|
14 |
+
const item = parserList.find((x) => x.value === chunkMethod);
|
15 |
+
if (item) {
|
16 |
+
return {
|
17 |
+
title: item.label,
|
18 |
+
description: TextMap[item.value as keyof typeof TextMap]?.description,
|
19 |
+
};
|
20 |
+
}
|
21 |
+
return { title: '', description: '' };
|
22 |
+
}, [parserList, chunkMethod]);
|
23 |
+
|
24 |
+
const imageList = useMemo(() => {
|
25 |
+
if (chunkMethod in ImageMap) {
|
26 |
+
return ImageMap[chunkMethod as keyof typeof ImageMap];
|
27 |
+
}
|
28 |
+
return [];
|
29 |
+
}, [chunkMethod]);
|
30 |
+
|
31 |
+
return (
|
32 |
+
<section className={styles.categoryPanelWrapper}>
|
33 |
+
{imageList.length > 0 ? (
|
34 |
+
<>
|
35 |
+
<Title level={5} className={styles.topTitle}>
|
36 |
+
{item.title} Category
|
37 |
+
</Title>
|
38 |
+
<Text>{item.description}</Text>
|
39 |
+
<Title level={5}>{item.title} Image Examples</Title>
|
40 |
+
<Text>
|
41 |
+
We've prepared detailed visual guides to make understanding easier
|
42 |
+
for you.
|
43 |
+
</Text>
|
44 |
+
<Row gutter={[10, 10]} className={styles.imageRow}>
|
45 |
+
{imageList.map((x) => (
|
46 |
+
<Col span={12} key={x}>
|
47 |
+
<SvgIcon
|
48 |
+
name={x}
|
49 |
+
width={'100%'}
|
50 |
+
className={styles.image}
|
51 |
+
></SvgIcon>
|
52 |
+
</Col>
|
53 |
+
))}
|
54 |
+
</Row>
|
55 |
+
<Title level={5}>{item.title} Dialogue Examples</Title>
|
56 |
+
<Divider></Divider>
|
57 |
+
</>
|
58 |
+
) : (
|
59 |
+
<Empty description={''} image={null}>
|
60 |
+
<p>
|
61 |
+
This will display a visual explanation of the knowledge base
|
62 |
+
categories
|
63 |
+
</p>
|
64 |
+
<SvgIcon name={'chunk-method/chunk-empty'} width={'100%'}></SvgIcon>
|
65 |
+
</Empty>
|
66 |
+
)}
|
67 |
+
</section>
|
68 |
+
);
|
69 |
+
};
|
70 |
+
|
71 |
+
export default CategoryPanel;
|
web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx
CHANGED
@@ -2,7 +2,6 @@ import { normFile } from '@/utils/fileUtil';
|
|
2 |
import { PlusOutlined } from '@ant-design/icons';
|
3 |
import {
|
4 |
Button,
|
5 |
-
Divider,
|
6 |
Flex,
|
7 |
Form,
|
8 |
Input,
|
@@ -11,8 +10,6 @@ import {
|
|
11 |
Select,
|
12 |
Slider,
|
13 |
Space,
|
14 |
-
Spin,
|
15 |
-
Typography,
|
16 |
Upload,
|
17 |
} from 'antd';
|
18 |
import {
|
@@ -20,174 +17,162 @@ import {
|
|
20 |
useSubmitKnowledgeConfiguration,
|
21 |
} from './hooks';
|
22 |
|
|
|
23 |
import styles from './index.less';
|
24 |
|
25 |
-
const { Title } = Typography;
|
26 |
const { Option } = Select;
|
27 |
|
28 |
-
const
|
29 |
const { submitKnowledgeConfiguration, submitLoading } =
|
30 |
useSubmitKnowledgeConfiguration();
|
31 |
-
const {
|
32 |
-
useFetchKnowledgeConfigurationOnMount();
|
33 |
|
34 |
const onFinishFailed = (errorInfo: any) => {
|
35 |
console.log('Failed:', errorInfo);
|
36 |
};
|
37 |
|
38 |
return (
|
39 |
-
<
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
>
|
52 |
-
<
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
</
|
80 |
-
<
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
></Select>
|
112 |
-
</Form.Item>
|
113 |
-
<Form.Item
|
114 |
-
name="parser_id"
|
115 |
-
label="Knowledge base category"
|
116 |
-
tooltip="xx"
|
117 |
-
rules={[{ required: true }]}
|
118 |
-
>
|
119 |
-
<Select placeholder="Please select a country">
|
120 |
-
{parserList.map((x) => (
|
121 |
-
<Option value={x.value} key={x.value}>
|
122 |
-
{x.label}
|
123 |
-
</Option>
|
124 |
-
))}
|
125 |
-
</Select>
|
126 |
-
</Form.Item>
|
127 |
-
<Form.Item noStyle dependencies={['parser_id']}>
|
128 |
-
{({ getFieldValue }) => {
|
129 |
-
const parserId = getFieldValue('parser_id');
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
<InputNumber
|
158 |
-
className={styles.sliderInputNumber}
|
159 |
-
max={2048}
|
160 |
-
min={0}
|
161 |
-
/>
|
162 |
-
</Form.Item>
|
163 |
-
</Flex>
|
164 |
</Form.Item>
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
</
|
186 |
-
</
|
187 |
-
</
|
188 |
-
</
|
189 |
-
</
|
190 |
);
|
191 |
};
|
192 |
|
193 |
-
export default
|
|
|
2 |
import { PlusOutlined } from '@ant-design/icons';
|
3 |
import {
|
4 |
Button,
|
|
|
5 |
Flex,
|
6 |
Form,
|
7 |
Input,
|
|
|
10 |
Select,
|
11 |
Slider,
|
12 |
Space,
|
|
|
|
|
13 |
Upload,
|
14 |
} from 'antd';
|
15 |
import {
|
|
|
17 |
useSubmitKnowledgeConfiguration,
|
18 |
} from './hooks';
|
19 |
|
20 |
+
import { FormInstance } from 'antd/lib';
|
21 |
import styles from './index.less';
|
22 |
|
|
|
23 |
const { Option } = Select;
|
24 |
|
25 |
+
const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
26 |
const { submitKnowledgeConfiguration, submitLoading } =
|
27 |
useSubmitKnowledgeConfiguration();
|
28 |
+
const { parserList, embeddingModelOptions } =
|
29 |
+
useFetchKnowledgeConfigurationOnMount(form);
|
30 |
|
31 |
const onFinishFailed = (errorInfo: any) => {
|
32 |
console.log('Failed:', errorInfo);
|
33 |
};
|
34 |
|
35 |
return (
|
36 |
+
<Form
|
37 |
+
form={form}
|
38 |
+
name="validateOnly"
|
39 |
+
layout="vertical"
|
40 |
+
autoComplete="off"
|
41 |
+
onFinish={submitKnowledgeConfiguration}
|
42 |
+
onFinishFailed={onFinishFailed}
|
43 |
+
>
|
44 |
+
<Form.Item
|
45 |
+
name="name"
|
46 |
+
label="Knowledge base name"
|
47 |
+
rules={[{ required: true }]}
|
48 |
+
>
|
49 |
+
<Input />
|
50 |
+
</Form.Item>
|
51 |
+
<Form.Item
|
52 |
+
name="avatar"
|
53 |
+
label="Knowledge base photo"
|
54 |
+
valuePropName="fileList"
|
55 |
+
getValueFromEvent={normFile}
|
56 |
+
>
|
57 |
+
<Upload
|
58 |
+
listType="picture-card"
|
59 |
+
maxCount={1}
|
60 |
+
beforeUpload={() => false}
|
61 |
+
showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
|
62 |
>
|
63 |
+
<button style={{ border: 0, background: 'none' }} type="button">
|
64 |
+
<PlusOutlined />
|
65 |
+
<div style={{ marginTop: 8 }}>Upload</div>
|
66 |
+
</button>
|
67 |
+
</Upload>
|
68 |
+
</Form.Item>
|
69 |
+
<Form.Item name="description" label="Description">
|
70 |
+
<Input />
|
71 |
+
</Form.Item>
|
72 |
+
<Form.Item
|
73 |
+
label="Language"
|
74 |
+
name="language"
|
75 |
+
initialValue={'Chinese'}
|
76 |
+
rules={[{ required: true, message: 'Please input your language!' }]}
|
77 |
+
>
|
78 |
+
<Select placeholder="select your language">
|
79 |
+
<Option value="English">English</Option>
|
80 |
+
<Option value="Chinese">Chinese</Option>
|
81 |
+
</Select>
|
82 |
+
</Form.Item>
|
83 |
+
<Form.Item
|
84 |
+
name="permission"
|
85 |
+
label="Permissions"
|
86 |
+
tooltip="coming soon"
|
87 |
+
rules={[{ required: true }]}
|
88 |
+
>
|
89 |
+
<Radio.Group>
|
90 |
+
<Radio value="me">Only me</Radio>
|
91 |
+
<Radio value="team">Team</Radio>
|
92 |
+
</Radio.Group>
|
93 |
+
</Form.Item>
|
94 |
+
<Form.Item
|
95 |
+
name="embd_id"
|
96 |
+
label="Embedding Model"
|
97 |
+
rules={[{ required: true }]}
|
98 |
+
tooltip="xx"
|
99 |
+
>
|
100 |
+
<Select
|
101 |
+
placeholder="Please select a country"
|
102 |
+
options={embeddingModelOptions}
|
103 |
+
></Select>
|
104 |
+
</Form.Item>
|
105 |
+
<Form.Item
|
106 |
+
name="parser_id"
|
107 |
+
label="Chunk method"
|
108 |
+
tooltip="xx"
|
109 |
+
rules={[{ required: true }]}
|
110 |
+
>
|
111 |
+
<Select placeholder="Please select a country">
|
112 |
+
{parserList.map((x) => (
|
113 |
+
<Option value={x.value} key={x.value}>
|
114 |
+
{x.label}
|
115 |
+
</Option>
|
116 |
+
))}
|
117 |
+
</Select>
|
118 |
+
</Form.Item>
|
119 |
+
<Form.Item noStyle dependencies={['parser_id']}>
|
120 |
+
{({ getFieldValue }) => {
|
121 |
+
const parserId = getFieldValue('parser_id');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
+
if (parserId === 'naive') {
|
124 |
+
return (
|
125 |
+
<Form.Item label="Max token number" tooltip="xxx">
|
126 |
+
<Flex gap={20} align="center">
|
127 |
+
<Flex flex={1}>
|
128 |
+
<Form.Item
|
129 |
+
name={['parser_config', 'chunk_token_num']}
|
130 |
+
noStyle
|
131 |
+
initialValue={128}
|
132 |
+
rules={[
|
133 |
+
{ required: true, message: 'Province is required' },
|
134 |
+
]}
|
135 |
+
>
|
136 |
+
<Slider className={styles.variableSlider} max={2048} />
|
137 |
+
</Form.Item>
|
138 |
+
</Flex>
|
139 |
+
<Form.Item
|
140 |
+
name={['parser_config', 'chunk_token_num']}
|
141 |
+
noStyle
|
142 |
+
rules={[{ required: true, message: 'Street is required' }]}
|
143 |
+
>
|
144 |
+
<InputNumber
|
145 |
+
className={styles.sliderInputNumber}
|
146 |
+
max={2048}
|
147 |
+
min={0}
|
148 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
</Form.Item>
|
150 |
+
</Flex>
|
151 |
+
</Form.Item>
|
152 |
+
);
|
153 |
+
}
|
154 |
+
return null;
|
155 |
+
}}
|
156 |
+
</Form.Item>
|
157 |
+
<Form.Item>
|
158 |
+
<div className={styles.buttonWrapper}>
|
159 |
+
<Space>
|
160 |
+
<Button htmlType="reset" size={'middle'}>
|
161 |
+
Cancel
|
162 |
+
</Button>
|
163 |
+
<Button
|
164 |
+
htmlType="submit"
|
165 |
+
type="primary"
|
166 |
+
size={'middle'}
|
167 |
+
loading={submitLoading}
|
168 |
+
>
|
169 |
+
Save
|
170 |
+
</Button>
|
171 |
+
</Space>
|
172 |
+
</div>
|
173 |
+
</Form.Item>
|
174 |
+
</Form>
|
175 |
);
|
176 |
};
|
177 |
|
178 |
+
export default ConfigurationForm;
|
web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts
CHANGED
@@ -15,6 +15,7 @@ import {
|
|
15 |
getUploadFileListFromBase64,
|
16 |
} from '@/utils/fileUtil';
|
17 |
import { Form, UploadFile } from 'antd';
|
|
|
18 |
import pick from 'lodash/pick';
|
19 |
import { useCallback, useEffect } from 'react';
|
20 |
import { LlmModelType } from '../../constant';
|
@@ -39,9 +40,8 @@ export const useSubmitKnowledgeConfiguration = () => {
|
|
39 |
return { submitKnowledgeConfiguration, submitLoading };
|
40 |
};
|
41 |
|
42 |
-
export const useFetchKnowledgeConfigurationOnMount = () => {
|
43 |
-
const [form] = Form.useForm();
|
44 |
-
const loading = useOneNamespaceEffectsLoading('kSModel', ['getKbDetail']);
|
45 |
|
46 |
const knowledgeDetails = useSelectKnowledgeDetails();
|
47 |
const parserList = useSelectParserList();
|
@@ -69,5 +69,15 @@ export const useFetchKnowledgeConfigurationOnMount = () => {
|
|
69 |
});
|
70 |
}, [form, knowledgeDetails]);
|
71 |
|
72 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
};
|
|
|
15 |
getUploadFileListFromBase64,
|
16 |
} from '@/utils/fileUtil';
|
17 |
import { Form, UploadFile } from 'antd';
|
18 |
+
import { FormInstance } from 'antd/lib';
|
19 |
import pick from 'lodash/pick';
|
20 |
import { useCallback, useEffect } from 'react';
|
21 |
import { LlmModelType } from '../../constant';
|
|
|
40 |
return { submitKnowledgeConfiguration, submitLoading };
|
41 |
};
|
42 |
|
43 |
+
export const useFetchKnowledgeConfigurationOnMount = (form: FormInstance) => {
|
44 |
+
// const [form] = Form.useForm();
|
|
|
45 |
|
46 |
const knowledgeDetails = useSelectKnowledgeDetails();
|
47 |
const parserList = useSelectParserList();
|
|
|
69 |
});
|
70 |
}, [form, knowledgeDetails]);
|
71 |
|
72 |
+
return { parserList, embeddingModelOptions };
|
73 |
+
};
|
74 |
+
|
75 |
+
export const useSelectKnowledgeDetailsLoading = () =>
|
76 |
+
useOneNamespaceEffectsLoading('kSModel', ['getKbDetail']);
|
77 |
+
|
78 |
+
export const useHandleChunkMethodChange = () => {
|
79 |
+
const [form] = Form.useForm();
|
80 |
+
const chunkMethod = Form.useWatch('parser_id', form);
|
81 |
+
|
82 |
+
return { form, chunkMethod };
|
83 |
};
|
web/src/pages/add-knowledge/components/knowledge-setting/index.less
CHANGED
@@ -31,3 +31,15 @@
|
|
31 |
width: 100%;
|
32 |
}
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
width: 100%;
|
32 |
}
|
33 |
}
|
34 |
+
|
35 |
+
.categoryPanelWrapper {
|
36 |
+
.topTitle {
|
37 |
+
margin-top: 0;
|
38 |
+
}
|
39 |
+
.imageRow {
|
40 |
+
margin-top: 16px;
|
41 |
+
}
|
42 |
+
.image {
|
43 |
+
width: 100%;
|
44 |
+
}
|
45 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-setting/index.tsx
CHANGED
@@ -1,3 +1,36 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
export default Configuration;
|
|
|
1 |
+
import { Col, Divider, Row, Spin, Typography } from 'antd';
|
2 |
+
import CategoryPanel from './category-panel';
|
3 |
+
import ConfigurationForm from './configuration';
|
4 |
+
import {
|
5 |
+
useHandleChunkMethodChange,
|
6 |
+
useSelectKnowledgeDetailsLoading,
|
7 |
+
} from './hooks';
|
8 |
+
|
9 |
+
import styles from './index.less';
|
10 |
+
|
11 |
+
const { Title } = Typography;
|
12 |
+
|
13 |
+
const Configuration = () => {
|
14 |
+
const loading = useSelectKnowledgeDetailsLoading();
|
15 |
+
const { form, chunkMethod } = useHandleChunkMethodChange();
|
16 |
+
|
17 |
+
return (
|
18 |
+
<div className={styles.configurationWrapper}>
|
19 |
+
<Title level={5}>Configuration</Title>
|
20 |
+
<p>Update your knowledge base details especially parsing method here.</p>
|
21 |
+
<Divider></Divider>
|
22 |
+
<Spin spinning={loading}>
|
23 |
+
<Row gutter={32}>
|
24 |
+
<Col span={12}>
|
25 |
+
<ConfigurationForm form={form}></ConfigurationForm>
|
26 |
+
</Col>
|
27 |
+
<Col span={12}>
|
28 |
+
<CategoryPanel chunkMethod={chunkMethod}></CategoryPanel>
|
29 |
+
</Col>
|
30 |
+
</Row>
|
31 |
+
</Spin>
|
32 |
+
</div>
|
33 |
+
);
|
34 |
+
};
|
35 |
|
36 |
export default Configuration;
|
web/src/pages/add-knowledge/components/knowledge-setting/utils.ts
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const getImageName = (prefix: string, length: number) =>
|
2 |
+
new Array(length)
|
3 |
+
.fill(0)
|
4 |
+
.map((x, idx) => `chunk-method/${prefix}-0${idx + 1}`);
|
5 |
+
|
6 |
+
export const ImageMap = {
|
7 |
+
book: getImageName('book', 4),
|
8 |
+
laws: getImageName('law', 4),
|
9 |
+
manual: getImageName('manual', 4),
|
10 |
+
media: getImageName('media', 2),
|
11 |
+
naive: getImageName('naive', 2),
|
12 |
+
paper: getImageName('paper', 2),
|
13 |
+
presentation: getImageName('presentation', 2),
|
14 |
+
qa: getImageName('qa', 2),
|
15 |
+
resume: getImageName('resume', 2),
|
16 |
+
table: getImageName('table', 2),
|
17 |
+
};
|
18 |
+
|
19 |
+
export const TextMap = {
|
20 |
+
book: {
|
21 |
+
title: '',
|
22 |
+
description: `Supported file formats are docx, excel, pdf, txt.
|
23 |
+
Since a book is long and not all the parts are useful, if it's a PDF,
|
24 |
+
please setup the page ranges for every book in order eliminate negative effects and save computing time for analyzing.`,
|
25 |
+
},
|
26 |
+
laws: {
|
27 |
+
title: '',
|
28 |
+
description: `Supported file formats are docx, pdf, txt.`,
|
29 |
+
},
|
30 |
+
manual: { title: '', description: `Only pdf is supported.` },
|
31 |
+
media: { title: '', description: '' },
|
32 |
+
naive: {
|
33 |
+
title: '',
|
34 |
+
description: `Supported file formats are docx, pdf, txt.
|
35 |
+
This method apply the naive ways to chunk files.
|
36 |
+
Successive text will be sliced into pieces using 'delimiter'.
|
37 |
+
Next, these successive pieces are merge into chunks whose token number is no more than 'Max token number'.`,
|
38 |
+
},
|
39 |
+
paper: {
|
40 |
+
title: '',
|
41 |
+
description: `Only pdf is supported.
|
42 |
+
The special part is that, the abstract of the paper will be sliced as an entire chunk, and will not be sliced partly.`,
|
43 |
+
},
|
44 |
+
presentation: {
|
45 |
+
title: '',
|
46 |
+
description: `The supported file formats are pdf, pptx.
|
47 |
+
Every page will be treated as a chunk. And the thumbnail of every page will be stored.
|
48 |
+
PPT file will be parsed by using this method automatically, setting-up for every PPT file is not necessary.`,
|
49 |
+
},
|
50 |
+
qa: {
|
51 |
+
title: '',
|
52 |
+
description: `Excel and csv(txt) format files are supported.
|
53 |
+
If the file is in excel format, there should be 2 column question and answer without header.
|
54 |
+
And question column is ahead of answer column.
|
55 |
+
And it's O.K if it has multiple sheets as long as the columns are rightly composed.
|
56 |
+
|
57 |
+
If it's in csv format, it should be UTF-8 encoded. Use TAB as delimiter to separate question and answer.
|
58 |
+
|
59 |
+
All the deformed lines will be ignored.
|
60 |
+
Every pair of Q&A will be treated as a chunk.`,
|
61 |
+
},
|
62 |
+
resume: {
|
63 |
+
title: '',
|
64 |
+
description: `The supported file formats are pdf, docx and txt.`,
|
65 |
+
},
|
66 |
+
table: {
|
67 |
+
title: '',
|
68 |
+
description: `Excel and csv(txt) format files are supported.
|
69 |
+
For csv or txt file, the delimiter between columns is TAB.
|
70 |
+
The first line must be column headers.
|
71 |
+
Column headers must be meaningful terms inorder to make our NLP model understanding.
|
72 |
+
It's good to enumerate some synonyms using slash '/' to separate, and even better to
|
73 |
+
enumerate values using brackets like 'gender/sex(male, female)'.
|
74 |
+
Here are some examples for headers:
|
75 |
+
1. supplier/vendor\tcolor(yellow, red, brown)\tgender/sex(male, female)\tsize(M,L,XL,XXL)
|
76 |
+
2. 姓名/名字\t电话/手机/微信\t最高学历(高中,职高,硕士,本科,博士,初中,中技,中专,专科,专升本,MPA,MBA,EMBA)
|
77 |
+
Every row in table will be treated as a chunk.
|
78 |
+
|
79 |
+
visual:
|
80 |
+
Image files are supported. Video is comming soon.
|
81 |
+
If the picture has text in it, OCR is applied to extract the text as a description of it.
|
82 |
+
If the text extracted by OCR is not enough, visual LLM is used to get the descriptions.`,
|
83 |
+
},
|
84 |
+
};
|
web/src/pages/user-setting/setting-model/index.tsx
CHANGED
@@ -39,10 +39,10 @@ import SystemModelSettingModal from './system-model-setting-modal';
|
|
39 |
import styles from './index.less';
|
40 |
|
41 |
const IconMap = {
|
42 |
-
|
43 |
Moonshot: MoonshotIcon,
|
44 |
OpenAI: OpenAiIcon,
|
45 |
-
|
46 |
文心一言: WenXinIcon,
|
47 |
};
|
48 |
|
|
|
39 |
import styles from './index.less';
|
40 |
|
41 |
const IconMap = {
|
42 |
+
'Tongyi-Qianwen': TongYiIcon,
|
43 |
Moonshot: MoonshotIcon,
|
44 |
OpenAI: OpenAiIcon,
|
45 |
+
'ZHIPU-AI': ZhiPuIcon,
|
46 |
文心一言: WenXinIcon,
|
47 |
};
|
48 |
|
web/tsconfig.json
CHANGED
@@ -2,5 +2,5 @@
|
|
2 |
"extends": "./src/.umi/tsconfig.json",
|
3 |
"@@/*": [
|
4 |
"src/.umi/*"
|
5 |
-
]
|
6 |
}
|
|
|
2 |
"extends": "./src/.umi/tsconfig.json",
|
3 |
"@@/*": [
|
4 |
"src/.umi/*"
|
5 |
+
],
|
6 |
}
|