From f4ec7cfa76065ec0fb85f13694ac6697835a41e5 Mon Sep 17 00:00:00 2001 From: balibabu Date: Thu, 21 Mar 2024 16:45:03 +0800 Subject: [PATCH] feat: add image for chunk method (#139) * feat: add image of chunk method * feat: add image for chunk method --- web/package-lock.json | 13 +- web/package.json | 1 + web/src/assets/svg/chunk-method/book-01.svg | 80 +++++ web/src/assets/svg/chunk-method/book-02.svg | 80 +++++ web/src/assets/svg/chunk-method/book-03.svg | 81 +++++ web/src/assets/svg/chunk-method/book-04.svg | 81 +++++ .../assets/svg/chunk-method/chunk-empty.svg | 161 ++++++++++ web/src/assets/svg/chunk-method/law-01.svg | 80 +++++ web/src/assets/svg/chunk-method/law-02.svg | 80 +++++ web/src/assets/svg/chunk-method/law-03.svg | 80 +++++ web/src/assets/svg/chunk-method/law-04.svg | 81 +++++ web/src/assets/svg/chunk-method/manual-01.svg | 79 +++++ web/src/assets/svg/chunk-method/manual-02.svg | 79 +++++ web/src/assets/svg/chunk-method/manual-03.svg | 80 +++++ web/src/assets/svg/chunk-method/manual-04.svg | 79 +++++ web/src/assets/svg/chunk-method/media-01.svg | 79 +++++ web/src/assets/svg/chunk-method/media-02.svg | 94 ++++++ web/src/assets/svg/chunk-method/naive-01.svg | 101 ++++++ web/src/assets/svg/chunk-method/naive-02.svg | 100 ++++++ web/src/assets/svg/chunk-method/paper-01.svg | 102 ++++++ web/src/assets/svg/chunk-method/paper-02.svg | 82 +++++ .../svg/chunk-method/presentation-01.svg | 82 +++++ .../svg/chunk-method/presentation-02.svg | 81 +++++ web/src/assets/svg/chunk-method/qa-01.svg | 76 +++++ web/src/assets/svg/chunk-method/qa-02.svg | 97 ++++++ web/src/assets/svg/chunk-method/resume-01.svg | 79 +++++ web/src/assets/svg/chunk-method/resume-02.svg | 95 ++++++ web/src/assets/svg/chunk-method/table-01.svg | 81 +++++ web/src/assets/svg/chunk-method/table-02.svg | 151 +++++++++ web/src/components/svg-icon.tsx | 59 ++-- .../components/knowledge-file/index.tsx | 2 +- .../knowledge-setting/category-panel.tsx | 71 +++++ .../knowledge-setting/configuration.tsx | 297 +++++++++--------- .../components/knowledge-setting/hooks.ts | 18 +- .../components/knowledge-setting/index.less | 12 + .../components/knowledge-setting/index.tsx | 35 ++- .../components/knowledge-setting/utils.ts | 84 +++++ .../user-setting/setting-model/index.tsx | 4 +- web/tsconfig.json | 2 +- 39 files changed, 2823 insertions(+), 196 deletions(-) create mode 100644 web/src/assets/svg/chunk-method/book-01.svg create mode 100644 web/src/assets/svg/chunk-method/book-02.svg create mode 100644 web/src/assets/svg/chunk-method/book-03.svg create mode 100644 web/src/assets/svg/chunk-method/book-04.svg create mode 100644 web/src/assets/svg/chunk-method/chunk-empty.svg create mode 100644 web/src/assets/svg/chunk-method/law-01.svg create mode 100644 web/src/assets/svg/chunk-method/law-02.svg create mode 100644 web/src/assets/svg/chunk-method/law-03.svg create mode 100644 web/src/assets/svg/chunk-method/law-04.svg create mode 100644 web/src/assets/svg/chunk-method/manual-01.svg create mode 100644 web/src/assets/svg/chunk-method/manual-02.svg create mode 100644 web/src/assets/svg/chunk-method/manual-03.svg create mode 100644 web/src/assets/svg/chunk-method/manual-04.svg create mode 100644 web/src/assets/svg/chunk-method/media-01.svg create mode 100644 web/src/assets/svg/chunk-method/media-02.svg create mode 100644 web/src/assets/svg/chunk-method/naive-01.svg create mode 100644 web/src/assets/svg/chunk-method/naive-02.svg create mode 100644 web/src/assets/svg/chunk-method/paper-01.svg create mode 100644 web/src/assets/svg/chunk-method/paper-02.svg create mode 100644 web/src/assets/svg/chunk-method/presentation-01.svg create mode 100644 web/src/assets/svg/chunk-method/presentation-02.svg create mode 100644 web/src/assets/svg/chunk-method/qa-01.svg create mode 100644 web/src/assets/svg/chunk-method/qa-02.svg create mode 100644 web/src/assets/svg/chunk-method/resume-01.svg create mode 100644 web/src/assets/svg/chunk-method/resume-02.svg create mode 100644 web/src/assets/svg/chunk-method/table-01.svg create mode 100644 web/src/assets/svg/chunk-method/table-02.svg create mode 100644 web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx create mode 100644 web/src/pages/add-knowledge/components/knowledge-setting/utils.ts diff --git a/web/package-lock.json b/web/package-lock.json index b0ba3505c..318cc80d7 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -39,6 +39,7 @@ "@types/react-dom": "^18.0.11", "@types/react-syntax-highlighter": "^15.5.11", "@types/uuid": "^9.0.8", + "@types/webpack-env": "^1.18.4", "@umijs/lint": "^4.1.1", "@umijs/plugins": "^4.1.0", "cross-env": "^7.0.3", @@ -886,9 +887,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.23.7", - "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.23.7.tgz", - "integrity": "sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA==", + "version": "7.24.1", + "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.24.1.tgz", + "integrity": "sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -2993,6 +2994,12 @@ "integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==", "dev": true }, + "node_modules/@types/webpack-env": { + "version": "1.18.4", + "resolved": "https://registry.npmmirror.com/@types/webpack-env/-/webpack-env-1.18.4.tgz", + "integrity": "sha512-I6e+9+HtWADAWeeJWDFQtdk4EVSAbj6Rtz4q8fJ7mSr1M0jzlFcs8/HZ+Xb5SHzVm1dxH7aUiI+A8kA8Gcrm0A==", + "dev": true + }, "node_modules/@types/yargs": { "version": "16.0.9", "resolved": "https://registry.npmmirror.com/@types/yargs/-/yargs-16.0.9.tgz", diff --git a/web/package.json b/web/package.json index b693c932f..48a60b8d2 100644 --- a/web/package.json +++ b/web/package.json @@ -43,6 +43,7 @@ "@types/react-dom": "^18.0.11", "@types/react-syntax-highlighter": "^15.5.11", "@types/uuid": "^9.0.8", + "@types/webpack-env": "^1.18.4", "@umijs/lint": "^4.1.1", "@umijs/plugins": "^4.1.0", "cross-env": "^7.0.3", diff --git a/web/src/assets/svg/chunk-method/book-01.svg b/web/src/assets/svg/chunk-method/book-01.svg new file mode 100644 index 000000000..f8e9f62cc --- /dev/null +++ b/web/src/assets/svg/chunk-method/book-01.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/book-02.svg b/web/src/assets/svg/chunk-method/book-02.svg new file mode 100644 index 000000000..cf668bac3 --- /dev/null +++ b/web/src/assets/svg/chunk-method/book-02.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/book-03.svg b/web/src/assets/svg/chunk-method/book-03.svg new file mode 100644 index 000000000..2c35e0619 --- /dev/null +++ b/web/src/assets/svg/chunk-method/book-03.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/book-04.svg b/web/src/assets/svg/chunk-method/book-04.svg new file mode 100644 index 000000000..9fed0e7dc --- /dev/null +++ b/web/src/assets/svg/chunk-method/book-04.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/chunk-empty.svg b/web/src/assets/svg/chunk-method/chunk-empty.svg new file mode 100644 index 000000000..0193e34c4 --- /dev/null +++ b/web/src/assets/svg/chunk-method/chunk-empty.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/law-01.svg b/web/src/assets/svg/chunk-method/law-01.svg new file mode 100644 index 000000000..5b87a77de --- /dev/null +++ b/web/src/assets/svg/chunk-method/law-01.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/law-02.svg b/web/src/assets/svg/chunk-method/law-02.svg new file mode 100644 index 000000000..23a7f0f7b --- /dev/null +++ b/web/src/assets/svg/chunk-method/law-02.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/law-03.svg b/web/src/assets/svg/chunk-method/law-03.svg new file mode 100644 index 000000000..707a7a8a7 --- /dev/null +++ b/web/src/assets/svg/chunk-method/law-03.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/law-04.svg b/web/src/assets/svg/chunk-method/law-04.svg new file mode 100644 index 000000000..9a40f7c8b --- /dev/null +++ b/web/src/assets/svg/chunk-method/law-04.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/manual-01.svg b/web/src/assets/svg/chunk-method/manual-01.svg new file mode 100644 index 000000000..37f72baa5 --- /dev/null +++ b/web/src/assets/svg/chunk-method/manual-01.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/manual-02.svg b/web/src/assets/svg/chunk-method/manual-02.svg new file mode 100644 index 000000000..ed0fd7995 --- /dev/null +++ b/web/src/assets/svg/chunk-method/manual-02.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/manual-03.svg b/web/src/assets/svg/chunk-method/manual-03.svg new file mode 100644 index 000000000..11754e506 --- /dev/null +++ b/web/src/assets/svg/chunk-method/manual-03.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/manual-04.svg b/web/src/assets/svg/chunk-method/manual-04.svg new file mode 100644 index 000000000..a5ead4e90 --- /dev/null +++ b/web/src/assets/svg/chunk-method/manual-04.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/media-01.svg b/web/src/assets/svg/chunk-method/media-01.svg new file mode 100644 index 000000000..758997135 --- /dev/null +++ b/web/src/assets/svg/chunk-method/media-01.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/media-02.svg b/web/src/assets/svg/chunk-method/media-02.svg new file mode 100644 index 000000000..66517bf05 --- /dev/null +++ b/web/src/assets/svg/chunk-method/media-02.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/naive-01.svg b/web/src/assets/svg/chunk-method/naive-01.svg new file mode 100644 index 000000000..7c0e95ce3 --- /dev/null +++ b/web/src/assets/svg/chunk-method/naive-01.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/naive-02.svg b/web/src/assets/svg/chunk-method/naive-02.svg new file mode 100644 index 000000000..3289322c1 --- /dev/null +++ b/web/src/assets/svg/chunk-method/naive-02.svg @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/paper-01.svg b/web/src/assets/svg/chunk-method/paper-01.svg new file mode 100644 index 000000000..7619e0222 --- /dev/null +++ b/web/src/assets/svg/chunk-method/paper-01.svg @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/paper-02.svg b/web/src/assets/svg/chunk-method/paper-02.svg new file mode 100644 index 000000000..857994efb --- /dev/null +++ b/web/src/assets/svg/chunk-method/paper-02.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/presentation-01.svg b/web/src/assets/svg/chunk-method/presentation-01.svg new file mode 100644 index 000000000..34f124b16 --- /dev/null +++ b/web/src/assets/svg/chunk-method/presentation-01.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/presentation-02.svg b/web/src/assets/svg/chunk-method/presentation-02.svg new file mode 100644 index 000000000..3090a047e --- /dev/null +++ b/web/src/assets/svg/chunk-method/presentation-02.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/qa-01.svg b/web/src/assets/svg/chunk-method/qa-01.svg new file mode 100644 index 000000000..b61810c17 --- /dev/null +++ b/web/src/assets/svg/chunk-method/qa-01.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/assets/svg/chunk-method/qa-02.svg b/web/src/assets/svg/chunk-method/qa-02.svg new file mode 100644 index 000000000..bc0b9fb74 --- /dev/null +++ b/web/src/assets/svg/chunk-method/qa-02.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/resume-01.svg b/web/src/assets/svg/chunk-method/resume-01.svg new file mode 100644 index 000000000..e31d5f0f3 --- /dev/null +++ b/web/src/assets/svg/chunk-method/resume-01.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/resume-02.svg b/web/src/assets/svg/chunk-method/resume-02.svg new file mode 100644 index 000000000..a44d851c8 --- /dev/null +++ b/web/src/assets/svg/chunk-method/resume-02.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/table-01.svg b/web/src/assets/svg/chunk-method/table-01.svg new file mode 100644 index 000000000..2dd6baa1f --- /dev/null +++ b/web/src/assets/svg/chunk-method/table-01.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/assets/svg/chunk-method/table-02.svg b/web/src/assets/svg/chunk-method/table-02.svg new file mode 100644 index 000000000..b3fe562eb --- /dev/null +++ b/web/src/assets/svg/chunk-method/table-02.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/src/components/svg-icon.tsx b/web/src/components/svg-icon.tsx index d7c16f478..c0a625c30 100644 --- a/web/src/components/svg-icon.tsx +++ b/web/src/components/svg-icon.tsx @@ -1,34 +1,37 @@ -import { - UseDynamicSVGImportOptions, - useDynamicSVGImport, -} from '@/hooks/commonHooks'; +import Icon from '@ant-design/icons'; +import { IconComponentProps } from '@ant-design/icons/lib/components/Icon'; -interface IconProps extends React.SVGProps { - name: string; - onCompleted?: UseDynamicSVGImportOptions['onCompleted']; - onError?: UseDynamicSVGImportOptions['onError']; +const importAll = (requireContext: __WebpackModuleApi.RequireContext) => { + const list = requireContext.keys().map((key) => { + const name = key.replace(/\.\/(.*)\.\w+$/, '$1'); + console.log(name, requireContext(key)); + return { name, value: requireContext(key) }; + }); + return list; +}; + +let routeList: { name: string; value: string }[] = []; + +try { + routeList = importAll(require.context('@/assets/svg', true, /\.svg$/)); +} catch (error) { + console.warn(error); + routeList = []; } -const SvgIcon: React.FC = ({ - name, - onCompleted, - onError, - ...rest -}): React.ReactNode | null => { - const { error, loading, SvgIcon } = useDynamicSVGImport(name, { - onCompleted, - onError, - }); - if (error) { - return error.message; - } - if (loading) { - return 'Loading...'; - } - if (SvgIcon) { - return ; - } - return null; +interface IProps extends IconComponentProps { + name: string; + width: string | number; +} + +const SvgIcon = ({ name, width, ...restProps }: IProps) => { + const ListItem = routeList.find((item) => item.name === name); + return ( + } + {...(restProps as any)} + /> + ); }; export default SvgIcon; diff --git a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx index fe71ee363..02a159cf2 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx @@ -220,7 +220,7 @@ const KnowledgeFile = () => { key: 'create_date', }, { - title: 'Category', + title: 'Chunk Method', dataIndex: 'parser_id', key: 'parser_id', render: (text) => { diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx b/web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx new file mode 100644 index 000000000..1d0b7e0cc --- /dev/null +++ b/web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx @@ -0,0 +1,71 @@ +import SvgIcon from '@/components/svg-icon'; +import { useSelectParserList } from '@/hooks/userSettingHook'; +import { Col, Divider, Empty, Row, Typography } from 'antd'; +import { useMemo } from 'react'; +import styles from './index.less'; +import { ImageMap, TextMap } from './utils'; + +const { Title, Text } = Typography; + +const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => { + const parserList = useSelectParserList(); + + const item = useMemo(() => { + const item = parserList.find((x) => x.value === chunkMethod); + if (item) { + return { + title: item.label, + description: TextMap[item.value as keyof typeof TextMap]?.description, + }; + } + return { title: '', description: '' }; + }, [parserList, chunkMethod]); + + const imageList = useMemo(() => { + if (chunkMethod in ImageMap) { + return ImageMap[chunkMethod as keyof typeof ImageMap]; + } + return []; + }, [chunkMethod]); + + return ( +
+ {imageList.length > 0 ? ( + <> + + {item.title} Category + + {item.description} + {item.title} Image Examples + + We've prepared detailed visual guides to make understanding easier + for you. + + + {imageList.map((x) => ( + + + + ))} + + {item.title} Dialogue Examples + + + ) : ( + +

+ This will display a visual explanation of the knowledge base + categories +

+ +
+ )} +
+ ); +}; + +export default CategoryPanel; diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx index 890c66213..f69f631f7 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx @@ -2,7 +2,6 @@ import { normFile } from '@/utils/fileUtil'; import { PlusOutlined } from '@ant-design/icons'; import { Button, - Divider, Flex, Form, Input, @@ -11,8 +10,6 @@ import { Select, Slider, Space, - Spin, - Typography, Upload, } from 'antd'; import { @@ -20,174 +17,162 @@ import { useSubmitKnowledgeConfiguration, } from './hooks'; +import { FormInstance } from 'antd/lib'; import styles from './index.less'; -const { Title } = Typography; const { Option } = Select; -const Configuration = () => { +const ConfigurationForm = ({ form }: { form: FormInstance }) => { const { submitKnowledgeConfiguration, submitLoading } = useSubmitKnowledgeConfiguration(); - const { form, parserList, embeddingModelOptions, loading } = - useFetchKnowledgeConfigurationOnMount(); + const { parserList, embeddingModelOptions } = + useFetchKnowledgeConfigurationOnMount(form); const onFinishFailed = (errorInfo: any) => { console.log('Failed:', errorInfo); }; return ( -
- Configuration -

Update your knowledge base details especially parsing method here.

- - -
+ + + + + false} + showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }} > - - - - - false} - showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }} - > - - - - - - - - - - - - Only me - Team - - - - - - - - - - {({ getFieldValue }) => { - const parserId = getFieldValue('parser_id'); + + + + + + + + + + + + Only me + Team + + + + + + + + + + {({ getFieldValue }) => { + const parserId = getFieldValue('parser_id'); - if (parserId === 'naive') { - return ( - - - - - - - - - - - + if (parserId === 'naive') { + return ( + + + + + + + + + - ); - } - return null; - }} - - -
- - - - -
-
- -
-
+ + + ); + } + return null; + }} + + +
+ + + + +
+
+ ); }; -export default Configuration; +export default ConfigurationForm; diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts b/web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts index 008979d65..56d29a9b4 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts +++ b/web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts @@ -15,6 +15,7 @@ import { getUploadFileListFromBase64, } from '@/utils/fileUtil'; import { Form, UploadFile } from 'antd'; +import { FormInstance } from 'antd/lib'; import pick from 'lodash/pick'; import { useCallback, useEffect } from 'react'; import { LlmModelType } from '../../constant'; @@ -39,9 +40,8 @@ export const useSubmitKnowledgeConfiguration = () => { return { submitKnowledgeConfiguration, submitLoading }; }; -export const useFetchKnowledgeConfigurationOnMount = () => { - const [form] = Form.useForm(); - const loading = useOneNamespaceEffectsLoading('kSModel', ['getKbDetail']); +export const useFetchKnowledgeConfigurationOnMount = (form: FormInstance) => { + // const [form] = Form.useForm(); const knowledgeDetails = useSelectKnowledgeDetails(); const parserList = useSelectParserList(); @@ -69,5 +69,15 @@ export const useFetchKnowledgeConfigurationOnMount = () => { }); }, [form, knowledgeDetails]); - return { form, parserList, embeddingModelOptions, loading }; + return { parserList, embeddingModelOptions }; +}; + +export const useSelectKnowledgeDetailsLoading = () => + useOneNamespaceEffectsLoading('kSModel', ['getKbDetail']); + +export const useHandleChunkMethodChange = () => { + const [form] = Form.useForm(); + const chunkMethod = Form.useWatch('parser_id', form); + + return { form, chunkMethod }; }; diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/index.less b/web/src/pages/add-knowledge/components/knowledge-setting/index.less index 6592e1303..7386c3cd5 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/index.less +++ b/web/src/pages/add-knowledge/components/knowledge-setting/index.less @@ -31,3 +31,15 @@ width: 100%; } } + +.categoryPanelWrapper { + .topTitle { + margin-top: 0; + } + .imageRow { + margin-top: 16px; + } + .image { + width: 100%; + } +} diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/index.tsx b/web/src/pages/add-knowledge/components/knowledge-setting/index.tsx index 6f9b11a2d..fa2c37700 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-setting/index.tsx @@ -1,3 +1,36 @@ -import Configuration from './configuration'; +import { Col, Divider, Row, Spin, Typography } from 'antd'; +import CategoryPanel from './category-panel'; +import ConfigurationForm from './configuration'; +import { + useHandleChunkMethodChange, + useSelectKnowledgeDetailsLoading, +} from './hooks'; + +import styles from './index.less'; + +const { Title } = Typography; + +const Configuration = () => { + const loading = useSelectKnowledgeDetailsLoading(); + const { form, chunkMethod } = useHandleChunkMethodChange(); + + return ( +
+ Configuration +

Update your knowledge base details especially parsing method here.

+ + + + + + + + + + + +
+ ); +}; export default Configuration; diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/utils.ts b/web/src/pages/add-knowledge/components/knowledge-setting/utils.ts new file mode 100644 index 000000000..4edda9c77 --- /dev/null +++ b/web/src/pages/add-knowledge/components/knowledge-setting/utils.ts @@ -0,0 +1,84 @@ +const getImageName = (prefix: string, length: number) => + new Array(length) + .fill(0) + .map((x, idx) => `chunk-method/${prefix}-0${idx + 1}`); + +export const ImageMap = { + book: getImageName('book', 4), + laws: getImageName('law', 4), + manual: getImageName('manual', 4), + media: getImageName('media', 2), + naive: getImageName('naive', 2), + paper: getImageName('paper', 2), + presentation: getImageName('presentation', 2), + qa: getImageName('qa', 2), + resume: getImageName('resume', 2), + table: getImageName('table', 2), +}; + +export const TextMap = { + book: { + title: '', + description: `Supported file formats are docx, excel, pdf, txt. + Since a book is long and not all the parts are useful, if it's a PDF, + please setup the page ranges for every book in order eliminate negative effects and save computing time for analyzing.`, + }, + laws: { + title: '', + description: `Supported file formats are docx, pdf, txt.`, + }, + manual: { title: '', description: `Only pdf is supported.` }, + media: { title: '', description: '' }, + naive: { + title: '', + description: `Supported file formats are docx, pdf, txt. + This method apply the naive ways to chunk files. + Successive text will be sliced into pieces using 'delimiter'. + Next, these successive pieces are merge into chunks whose token number is no more than 'Max token number'.`, + }, + paper: { + title: '', + description: `Only pdf is supported. + The special part is that, the abstract of the paper will be sliced as an entire chunk, and will not be sliced partly.`, + }, + presentation: { + title: '', + description: `The supported file formats are pdf, pptx. + Every page will be treated as a chunk. And the thumbnail of every page will be stored. + PPT file will be parsed by using this method automatically, setting-up for every PPT file is not necessary.`, + }, + qa: { + title: '', + description: `Excel and csv(txt) format files are supported. + If the file is in excel format, there should be 2 column question and answer without header. + And question column is ahead of answer column. + And it's O.K if it has multiple sheets as long as the columns are rightly composed. + + If it's in csv format, it should be UTF-8 encoded. Use TAB as delimiter to separate question and answer. + + All the deformed lines will be ignored. + Every pair of Q&A will be treated as a chunk.`, + }, + resume: { + title: '', + description: `The supported file formats are pdf, docx and txt.`, + }, + table: { + title: '', + description: `Excel and csv(txt) format files are supported. + For csv or txt file, the delimiter between columns is TAB. + The first line must be column headers. + Column headers must be meaningful terms inorder to make our NLP model understanding. + It's good to enumerate some synonyms using slash '/' to separate, and even better to + enumerate values using brackets like 'gender/sex(male, female)'. + Here are some examples for headers: + 1. supplier/vendor\tcolor(yellow, red, brown)\tgender/sex(male, female)\tsize(M,L,XL,XXL) + 2. 姓名/名字\t电话/手机/微信\t最高学历(高中,职高,硕士,本科,博士,初中,中技,中专,专科,专升本,MPA,MBA,EMBA) + Every row in table will be treated as a chunk. + +visual: + Image files are supported. Video is comming soon. + If the picture has text in it, OCR is applied to extract the text as a description of it. + If the text extracted by OCR is not enough, visual LLM is used to get the descriptions.`, + }, +}; diff --git a/web/src/pages/user-setting/setting-model/index.tsx b/web/src/pages/user-setting/setting-model/index.tsx index 67b39a8bd..7186a5914 100644 --- a/web/src/pages/user-setting/setting-model/index.tsx +++ b/web/src/pages/user-setting/setting-model/index.tsx @@ -39,10 +39,10 @@ import SystemModelSettingModal from './system-model-setting-modal'; import styles from './index.less'; const IconMap = { - 通义千问: TongYiIcon, + 'Tongyi-Qianwen': TongYiIcon, Moonshot: MoonshotIcon, OpenAI: OpenAiIcon, - 智谱AI: ZhiPuIcon, + 'ZHIPU-AI': ZhiPuIcon, 文心一言: WenXinIcon, }; diff --git a/web/tsconfig.json b/web/tsconfig.json index 5f6aa1ebd..0080952d4 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -2,5 +2,5 @@ "extends": "./src/.umi/tsconfig.json", "@@/*": [ "src/.umi/*" - ] + ], } \ No newline at end of file