balibabu commited on
Commit
68ed806
Β·
1 Parent(s): 3951bd3

feat: change all file names to lowercase #1574 (#1575)

Browse files

### What problem does this PR solve?

feat: change all file names to lowercase #1574

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. web/src/components/chunk-method-modal/hooks.ts +1 -1
  2. web/src/components/chunk-method-modal/index.tsx +1 -1
  3. web/src/components/copy-to-clipboard.tsx +1 -1
  4. web/src/components/file-upload-modal/index.tsx +1 -1
  5. web/src/components/knowledge-base-item.tsx +2 -2
  6. web/src/components/layout-recognize.tsx +1 -1
  7. web/src/components/llm-setting-items/index.tsx +2 -2
  8. web/src/components/max-token-number.tsx +1 -1
  9. web/src/components/message-item/index.tsx +3 -3
  10. web/src/components/operate-dropdown/index.tsx +1 -1
  11. web/src/components/parse-configuration/index.tsx +2 -2
  12. web/src/components/pdf-previewer/index.tsx +1 -1
  13. web/src/components/rename-modal/index.tsx +1 -1
  14. web/src/components/rerank.tsx +2 -2
  15. web/src/components/similarity-slider/index.tsx +1 -1
  16. web/src/components/top-n-item.tsx +1 -1
  17. web/src/hooks/{authHook.ts β†’ auth-hooks.ts} +0 -0
  18. web/src/hooks/{chatHooks.ts β†’ chat-hooks.ts} +0 -0
  19. web/src/hooks/{chunkHooks.ts β†’ chunk-hooks.ts} +1 -1
  20. web/src/hooks/{commonHooks.tsx β†’ common-hooks.tsx} +0 -0
  21. web/src/hooks/{documentHooks.ts β†’ document-hooks.ts} +2 -2
  22. web/src/hooks/{fileManagerHooks.ts β†’ file-manager-hooks.ts} +0 -0
  23. web/src/hooks/{knowledgeHook.ts β†’ knowledge-hooks.ts} +22 -3
  24. web/src/hooks/{llmHooks.ts β†’ llm-hooks.ts} +0 -0
  25. web/src/hooks/logic-hooks.ts +5 -5
  26. web/src/hooks/{loginHooks.ts β†’ login-hooks.ts} +0 -0
  27. web/src/hooks/{routeHook.ts β†’ route-hook.ts} +0 -0
  28. web/src/hooks/{storeHooks.ts β†’ store-hooks.ts} +0 -0
  29. web/src/hooks/{userSettingHook.ts β†’ user-setting-hooks.ts} +1 -1
  30. web/src/layouts/components/header/index.tsx +2 -2
  31. web/src/layouts/components/right-toolbar/index.tsx +1 -1
  32. web/src/layouts/components/user/index.tsx +33 -30
  33. web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/index.tsx +2 -2
  34. web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-toolbar/index.tsx +2 -2
  35. web/src/pages/add-knowledge/components/knowledge-chunk/components/document-preview/hooks.ts +1 -1
  36. web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts +1 -1
  37. web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx +2 -2
  38. web/src/pages/add-knowledge/components/knowledge-chunk/model.ts +1 -1
  39. web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +4 -4
  40. web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx +3 -3
  41. web/src/pages/add-knowledge/components/knowledge-file/hooks.ts +8 -8
  42. web/src/pages/add-knowledge/components/knowledge-file/index.tsx +2 -2
  43. web/src/pages/add-knowledge/components/knowledge-file/model.ts +276 -276
  44. web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +2 -2
  45. web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx +1 -1
  46. web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx +1 -1
  47. web/src/pages/add-knowledge/components/knowledge-file/web-crawl-modal.tsx +17 -4
  48. web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx +2 -2
  49. web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +1 -1
  50. web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts +5 -5
web/src/components/chunk-method-modal/hooks.ts CHANGED
@@ -1,7 +1,7 @@
1
  import {
2
  useFetchTenantInfo,
3
  useSelectParserList,
4
- } from '@/hooks/userSettingHook';
5
  import { useEffect, useMemo, useState } from 'react';
6
 
7
  const ParserListMap = new Map([
 
1
  import {
2
  useFetchTenantInfo,
3
  useSelectParserList,
4
+ } from '@/hooks/user-setting-hooks';
5
  import { useEffect, useMemo, useState } from 'react';
6
 
7
  const ParserListMap = new Map([
web/src/components/chunk-method-modal/index.tsx CHANGED
@@ -21,7 +21,7 @@ import omit from 'lodash/omit';
21
  import React, { useEffect, useMemo } from 'react';
22
  import { useFetchParserListOnMount } from './hooks';
23
 
24
- import { useTranslate } from '@/hooks/commonHooks';
25
  import LayoutRecognize from '../layout-recognize';
26
  import ParseConfiguration, {
27
  showRaptorParseConfiguration,
 
21
  import React, { useEffect, useMemo } from 'react';
22
  import { useFetchParserListOnMount } from './hooks';
23
 
24
+ import { useTranslate } from '@/hooks/common-hooks';
25
  import LayoutRecognize from '../layout-recognize';
26
  import ParseConfiguration, {
27
  showRaptorParseConfiguration,
web/src/components/copy-to-clipboard.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { CheckOutlined, CopyOutlined } from '@ant-design/icons';
3
  import { Tooltip } from 'antd';
4
  import { useState } from 'react';
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { CheckOutlined, CopyOutlined } from '@ant-design/icons';
3
  import { Tooltip } from 'antd';
4
  import { useState } from 'react';
web/src/components/file-upload-modal/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { IModalProps } from '@/interfaces/common';
3
  import { InboxOutlined } from '@ant-design/icons';
4
  import {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { IModalProps } from '@/interfaces/common';
3
  import { InboxOutlined } from '@ant-design/icons';
4
  import {
web/src/components/knowledge-base-item.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
- import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
3
  import { Form, Select } from 'antd';
4
 
5
  const KnowledgeBaseItem = () => {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
+ import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
3
  import { Form, Select } from 'antd';
4
 
5
  const KnowledgeBaseItem = () => {
web/src/components/layout-recognize.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { Form, Switch } from 'antd';
3
 
4
  const LayoutRecognize = () => {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { Form, Switch } from 'antd';
3
 
4
  const LayoutRecognize = () => {
web/src/components/llm-setting-items/index.tsx CHANGED
@@ -6,8 +6,8 @@ import {
6
  import { Divider, Flex, Form, InputNumber, Select, Slider, Switch } from 'antd';
7
  import camelCase from 'lodash/camelCase';
8
 
9
- import { useTranslate } from '@/hooks/commonHooks';
10
- import { useSelectLlmOptionsByModelType } from '@/hooks/llmHooks';
11
  import { useCallback, useMemo } from 'react';
12
  import styles from './index.less';
13
 
 
6
  import { Divider, Flex, Form, InputNumber, Select, Slider, Switch } from 'antd';
7
  import camelCase from 'lodash/camelCase';
8
 
9
+ import { useTranslate } from '@/hooks/common-hooks';
10
+ import { useSelectLlmOptionsByModelType } from '@/hooks/llm-hooks';
11
  import { useCallback, useMemo } from 'react';
12
  import styles from './index.less';
13
 
web/src/components/max-token-number.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { Flex, Form, InputNumber, Slider } from 'antd';
3
 
4
  const MaxTokenNumber = () => {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { Flex, Form, InputNumber, Slider } from 'antd';
3
 
4
  const MaxTokenNumber = () => {
web/src/components/message-item/index.tsx CHANGED
@@ -1,8 +1,8 @@
1
  import { ReactComponent as AssistantIcon } from '@/assets/svg/assistant.svg';
2
  import { MessageType } from '@/constants/chat';
3
- import { useTranslate } from '@/hooks/commonHooks';
4
- import { useGetDocumentUrl } from '@/hooks/documentHooks';
5
- import { useSelectFileThumbnails } from '@/hooks/knowledgeHook';
6
  import { IReference, Message } from '@/interfaces/database/chat';
7
  import { IChunk } from '@/interfaces/database/knowledge';
8
  import classNames from 'classnames';
 
1
  import { ReactComponent as AssistantIcon } from '@/assets/svg/assistant.svg';
2
  import { MessageType } from '@/constants/chat';
3
+ import { useTranslate } from '@/hooks/common-hooks';
4
+ import { useGetDocumentUrl } from '@/hooks/document-hooks';
5
+ import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
6
  import { IReference, Message } from '@/interfaces/database/chat';
7
  import { IChunk } from '@/interfaces/database/knowledge';
8
  import classNames from 'classnames';
web/src/components/operate-dropdown/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useShowDeleteConfirm } from '@/hooks/commonHooks';
2
  import { DeleteOutlined, MoreOutlined } from '@ant-design/icons';
3
  import { Dropdown, MenuProps, Space } from 'antd';
4
  import { useTranslation } from 'react-i18next';
 
1
+ import { useShowDeleteConfirm } from '@/hooks/common-hooks';
2
  import { DeleteOutlined, MoreOutlined } from '@ant-design/icons';
3
  import { Dropdown, MenuProps, Space } from 'antd';
4
  import { useTranslation } from 'react-i18next';
web/src/components/parse-configuration/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { PlusOutlined } from '@ant-design/icons';
3
  import {
4
  Button,
@@ -12,7 +12,7 @@ import {
12
  } from 'antd';
13
  import random from 'lodash/random';
14
 
15
- export const excludedParseMethods = ['table', 'resume', 'one',"picture"];
16
 
17
  export const showRaptorParseConfiguration = (parserId: string) => {
18
  return !excludedParseMethods.includes(parserId);
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { PlusOutlined } from '@ant-design/icons';
3
  import {
4
  Button,
 
12
  } from 'antd';
13
  import random from 'lodash/random';
14
 
15
+ export const excludedParseMethods = ['table', 'resume', 'one', 'picture'];
16
 
17
  export const showRaptorParseConfiguration = (parserId: string) => {
18
  return !excludedParseMethods.includes(parserId);
web/src/components/pdf-previewer/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import {
2
  useGetChunkHighlights,
3
  useGetDocumentUrl,
4
- } from '@/hooks/documentHooks';
5
  import { IChunk } from '@/interfaces/database/knowledge';
6
  import { Skeleton } from 'antd';
7
  import { useEffect, useRef, useState } from 'react';
 
1
  import {
2
  useGetChunkHighlights,
3
  useGetDocumentUrl,
4
+ } from '@/hooks/document-hooks';
5
  import { IChunk } from '@/interfaces/database/knowledge';
6
  import { Skeleton } from 'antd';
7
  import { useEffect, useRef, useState } from 'react';
web/src/components/rename-modal/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { Form, Input, Modal } from 'antd';
3
  import { useEffect } from 'react';
4
  import { IModalManagerChildrenProps } from '../modal-manager';
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { Form, Input, Modal } from 'antd';
3
  import { useEffect } from 'react';
4
  import { IModalManagerChildrenProps } from '../modal-manager';
web/src/components/rerank.tsx CHANGED
@@ -1,6 +1,6 @@
1
  import { LlmModelType } from '@/constants/knowledge';
2
- import { useTranslate } from '@/hooks/commonHooks';
3
- import { useSelectLlmOptionsByModelType } from '@/hooks/llmHooks';
4
  import { Form, Select, Slider } from 'antd';
5
 
6
  type FieldType = {
 
1
  import { LlmModelType } from '@/constants/knowledge';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
+ import { useSelectLlmOptionsByModelType } from '@/hooks/llm-hooks';
4
  import { Form, Select, Slider } from 'antd';
5
 
6
  type FieldType = {
web/src/components/similarity-slider/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { Form, Slider } from 'antd';
3
 
4
  type FieldType = {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { Form, Slider } from 'antd';
3
 
4
  type FieldType = {
web/src/components/top-n-item.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { Form, Slider } from 'antd';
3
 
4
  type FieldType = {
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { Form, Slider } from 'antd';
3
 
4
  type FieldType = {
web/src/hooks/{authHook.ts β†’ auth-hooks.ts} RENAMED
File without changes
web/src/hooks/{chatHooks.ts β†’ chat-hooks.ts} RENAMED
File without changes
web/src/hooks/{chunkHooks.ts β†’ chunk-hooks.ts} RENAMED
@@ -1,6 +1,6 @@
1
  import { useCallback } from 'react';
2
  import { useDispatch } from 'umi';
3
- import { useGetKnowledgeSearchParams } from './routeHook';
4
 
5
  interface PayloadType {
6
  doc_id: string;
 
1
  import { useCallback } from 'react';
2
  import { useDispatch } from 'umi';
3
+ import { useGetKnowledgeSearchParams } from './route-hook';
4
 
5
  interface PayloadType {
6
  doc_id: string;
web/src/hooks/{commonHooks.tsx β†’ common-hooks.tsx} RENAMED
File without changes
web/src/hooks/{documentHooks.ts β†’ document-hooks.ts} RENAMED
@@ -6,8 +6,8 @@ import { UploadFile } from 'antd';
6
  import { useCallback, useMemo, useState } from 'react';
7
  import { IHighlight } from 'react-pdf-highlighter';
8
  import { useDispatch, useSelector } from 'umi';
9
- import { useGetKnowledgeSearchParams } from './routeHook';
10
- import { useOneNamespaceEffectsLoading } from './storeHooks';
11
 
12
  export const useGetDocumentUrl = (documentId?: string) => {
13
  const getDocumentUrl = useCallback(
 
6
  import { useCallback, useMemo, useState } from 'react';
7
  import { IHighlight } from 'react-pdf-highlighter';
8
  import { useDispatch, useSelector } from 'umi';
9
+ import { useGetKnowledgeSearchParams } from './route-hook';
10
+ import { useOneNamespaceEffectsLoading } from './store-hooks';
11
 
12
  export const useGetDocumentUrl = (documentId?: string) => {
13
  const getDocumentUrl = useCallback(
web/src/hooks/{fileManagerHooks.ts β†’ file-manager-hooks.ts} RENAMED
File without changes
web/src/hooks/{knowledgeHook.ts β†’ knowledge-hooks.ts} RENAMED
@@ -1,9 +1,11 @@
1
- import { useShowDeleteConfirm } from '@/hooks/commonHooks';
2
  import { IKnowledge } from '@/interfaces/database/knowledge';
 
 
3
  import { useCallback, useEffect, useMemo } from 'react';
4
  import { useDispatch, useSearchParams, useSelector } from 'umi';
5
- import { useGetKnowledgeSearchParams } from './routeHook';
6
- import { useOneNamespaceEffectsLoading } from './storeHooks';
7
 
8
  export const useKnowledgeBaseId = (): string => {
9
  const [searchParams] = useSearchParams();
@@ -158,6 +160,23 @@ export const useFetchKnowledgeList = (
158
  return { list, loading, fetchList };
159
  };
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  export const useSelectFileThumbnails = () => {
162
  const fileThumbnails: Record<string, string> = useSelector(
163
  (state: any) => state.kFModel.fileThumbnails,
 
1
+ import { useShowDeleteConfirm } from '@/hooks/common-hooks';
2
  import { IKnowledge } from '@/interfaces/database/knowledge';
3
+ import kbService from '@/services/knowledge-service';
4
+ import { useQuery } from '@tanstack/react-query';
5
  import { useCallback, useEffect, useMemo } from 'react';
6
  import { useDispatch, useSearchParams, useSelector } from 'umi';
7
+ import { useGetKnowledgeSearchParams } from './route-hook';
8
+ import { useOneNamespaceEffectsLoading } from './store-hooks';
9
 
10
  export const useKnowledgeBaseId = (): string => {
11
  const [searchParams] = useSearchParams();
 
160
  return { list, loading, fetchList };
161
  };
162
 
163
+ export const useNextFetchKnowledgeList = (): {
164
+ data: any[];
165
+ loading: boolean;
166
+ } => {
167
+ const { data, isFetching: loading } = useQuery({
168
+ queryKey: ['fetchKnowledgeList'],
169
+ initialData: [],
170
+ queryFn: async () => {
171
+ const { data } = await kbService.getList();
172
+
173
+ return data?.data ?? [];
174
+ },
175
+ });
176
+
177
+ return { data, loading };
178
+ };
179
+
180
  export const useSelectFileThumbnails = () => {
181
  const fileThumbnails: Record<string, string> = useSelector(
182
  (state: any) => state.kFModel.fileThumbnails,
web/src/hooks/{llmHooks.ts β†’ llm-hooks.ts} RENAMED
File without changes
web/src/hooks/logic-hooks.ts CHANGED
@@ -20,15 +20,15 @@ import {
20
  } from 'react';
21
  import { useTranslation } from 'react-i18next';
22
  import { useDispatch } from 'umi';
23
- import { useSetModalState, useTranslate } from './commonHooks';
24
- import { useSetDocumentParser } from './documentHooks';
25
- import { useFetchLlmList } from './llmHooks';
26
- import { useOneNamespaceEffectsLoading } from './storeHooks';
27
  import {
28
  useFetchTenantInfo,
29
  useSaveSetting,
30
  useSelectTenantInfo,
31
- } from './userSettingHook';
32
 
33
  export const useChangeDocumentParser = (documentId: string) => {
34
  const setDocumentParser = useSetDocumentParser();
 
20
  } from 'react';
21
  import { useTranslation } from 'react-i18next';
22
  import { useDispatch } from 'umi';
23
+ import { useSetModalState, useTranslate } from './common-hooks';
24
+ import { useSetDocumentParser } from './document-hooks';
25
+ import { useFetchLlmList } from './llm-hooks';
26
+ import { useOneNamespaceEffectsLoading } from './store-hooks';
27
  import {
28
  useFetchTenantInfo,
29
  useSaveSetting,
30
  useSelectTenantInfo,
31
+ } from './user-setting-hooks';
32
 
33
  export const useChangeDocumentParser = (documentId: string) => {
34
  const setDocumentParser = useSetDocumentParser();
web/src/hooks/{loginHooks.ts β†’ login-hooks.ts} RENAMED
File without changes
web/src/hooks/{routeHook.ts β†’ route-hook.ts} RENAMED
File without changes
web/src/hooks/{storeHooks.ts β†’ store-hooks.ts} RENAMED
File without changes
web/src/hooks/{userSettingHook.ts β†’ user-setting-hooks.ts} RENAMED
@@ -1,6 +1,6 @@
1
  import { ITenantInfo } from '@/interfaces/database/knowledge';
2
  import { ISystemStatus, IUserInfo } from '@/interfaces/database/userSetting';
3
- import userService from '@/services/userService';
4
  import authorizationUtil from '@/utils/authorizationUtil';
5
  import { useCallback, useEffect, useMemo, useState } from 'react';
6
  import { history, useDispatch, useSelector } from 'umi';
 
1
  import { ITenantInfo } from '@/interfaces/database/knowledge';
2
  import { ISystemStatus, IUserInfo } from '@/interfaces/database/userSetting';
3
+ import userService from '@/services/user-service';
4
  import authorizationUtil from '@/utils/authorizationUtil';
5
  import { useCallback, useEffect, useMemo, useState } from 'react';
6
  import { history, useDispatch, useSelector } from 'umi';
web/src/layouts/components/header/index.tsx CHANGED
@@ -1,8 +1,8 @@
1
  import { ReactComponent as FileIcon } from '@/assets/svg/file-management.svg';
2
  import { ReactComponent as GraphIcon } from '@/assets/svg/graph.svg';
3
  import { ReactComponent as KnowledgeBaseIcon } from '@/assets/svg/knowledge-base.svg';
4
- import { useTranslate } from '@/hooks/commonHooks';
5
- import { useNavigateWithFromState } from '@/hooks/routeHook';
6
  import { Flex, Layout, Radio, Space, theme } from 'antd';
7
  import { useCallback, useMemo } from 'react';
8
  import { useLocation } from 'umi';
 
1
  import { ReactComponent as FileIcon } from '@/assets/svg/file-management.svg';
2
  import { ReactComponent as GraphIcon } from '@/assets/svg/graph.svg';
3
  import { ReactComponent as KnowledgeBaseIcon } from '@/assets/svg/knowledge-base.svg';
4
+ import { useTranslate } from '@/hooks/common-hooks';
5
+ import { useNavigateWithFromState } from '@/hooks/route-hook';
6
  import { Flex, Layout, Radio, Space, theme } from 'antd';
7
  import { useCallback, useMemo } from 'react';
8
  import { useLocation } from 'umi';
web/src/layouts/components/right-toolbar/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useTranslate } from '@/hooks/commonHooks';
2
  import { DownOutlined, GithubOutlined } from '@ant-design/icons';
3
  import { Dropdown, MenuProps, Space } from 'antd';
4
  import camelCase from 'lodash/camelCase';
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
  import { DownOutlined, GithubOutlined } from '@ant-design/icons';
3
  import { Dropdown, MenuProps, Space } from 'antd';
4
  import camelCase from 'lodash/camelCase';
web/src/layouts/components/user/index.tsx CHANGED
@@ -1,30 +1,33 @@
1
- import { useFetchUserInfo, useSelectUserInfo } from '@/hooks/userSettingHook';
2
- import { Avatar } from 'antd';
3
- import React from 'react';
4
- import { history } from 'umi';
5
-
6
- import styles from '../../index.less';
7
-
8
- const App: React.FC = () => {
9
- const userInfo = useSelectUserInfo();
10
-
11
- const toSetting = () => {
12
- history.push('/user-setting');
13
- };
14
-
15
- useFetchUserInfo();
16
-
17
- return (
18
- <Avatar
19
- size={32}
20
- onClick={toSetting}
21
- className={styles.clickAvailable}
22
- src={
23
- userInfo.avatar ??
24
- 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
25
- }
26
- />
27
- );
28
- };
29
-
30
- export default App;
 
 
 
 
1
+ import {
2
+ useFetchUserInfo,
3
+ useSelectUserInfo,
4
+ } from '@/hooks/user-setting-hooks';
5
+ import { Avatar } from 'antd';
6
+ import React from 'react';
7
+ import { history } from 'umi';
8
+
9
+ import styles from '../../index.less';
10
+
11
+ const App: React.FC = () => {
12
+ const userInfo = useSelectUserInfo();
13
+
14
+ const toSetting = () => {
15
+ history.push('/user-setting');
16
+ };
17
+
18
+ useFetchUserInfo();
19
+
20
+ return (
21
+ <Avatar
22
+ size={32}
23
+ onClick={toSetting}
24
+ className={styles.clickAvailable}
25
+ src={
26
+ userInfo.avatar ??
27
+ 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
28
+ }
29
+ />
30
+ );
31
+ };
32
+
33
+ export default App;
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { useDeleteChunkByIds } from '@/hooks/knowledgeHook';
2
- import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
3
  import { DeleteOutlined } from '@ant-design/icons';
4
  import { Checkbox, Divider, Form, Input, Modal, Space } from 'antd';
5
  import React, { useCallback, useEffect, useState } from 'react';
 
1
+ import { useDeleteChunkByIds } from '@/hooks/knowledge-hooks';
2
+ import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
3
  import { DeleteOutlined } from '@ant-design/icons';
4
  import { Checkbox, Divider, Form, Input, Modal, Space } from 'antd';
5
  import React, { useCallback, useEffect, useState } from 'react';
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-toolbar/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
2
  import { KnowledgeRouteKey } from '@/constants/knowledge';
3
- import { useTranslate } from '@/hooks/commonHooks';
4
- import { useKnowledgeBaseId } from '@/hooks/knowledgeHook';
5
  import {
6
  ArrowLeftOutlined,
7
  CheckCircleOutlined,
 
1
  import { ReactComponent as FilterIcon } from '@/assets/filter.svg';
2
  import { KnowledgeRouteKey } from '@/constants/knowledge';
3
+ import { useTranslate } from '@/hooks/common-hooks';
4
+ import { useKnowledgeBaseId } from '@/hooks/knowledge-hooks';
5
  import {
6
  ArrowLeftOutlined,
7
  CheckCircleOutlined,
web/src/pages/add-knowledge/components/knowledge-chunk/components/document-preview/hooks.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
2
  import { api_host } from '@/utils/api';
3
  import { useSize } from 'ahooks';
4
  import { CustomTextRenderer } from 'node_modules/react-pdf/dist/esm/shared/types';
 
1
+ import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
2
  import { api_host } from '@/utils/api';
3
  import { useSize } from 'ahooks';
4
  import { CustomTextRenderer } from 'node_modules/react-pdf/dist/esm/shared/types';
web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
2
  import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
3
  import { buildChunkHighlights } from '@/utils/documentUtils';
4
  import { useCallback, useMemo, useState } from 'react';
 
1
+ import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
2
  import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
3
  import { buildChunkHighlights } from '@/utils/documentUtils';
4
  import { useCallback, useMemo, useState } from 'react';
web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { useFetchChunkList } from '@/hooks/chunkHooks';
2
- import { useDeleteChunkByIds } from '@/hooks/knowledgeHook';
3
  import type { PaginationProps } from 'antd';
4
  import { Divider, Flex, Pagination, Space, Spin, message } from 'antd';
5
  import classNames from 'classnames';
 
1
+ import { useFetchChunkList } from '@/hooks/chunk-hooks';
2
+ import { useDeleteChunkByIds } from '@/hooks/knowledge-hooks';
3
  import type { PaginationProps } from 'antd';
4
  import { Divider, Flex, Pagination, Space, Spin, message } from 'antd';
5
  import classNames from 'classnames';
web/src/pages/add-knowledge/components/knowledge-chunk/model.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { BaseState } from '@/interfaces/common';
2
  import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
3
- import kbService from '@/services/kbService';
4
  import { message } from 'antd';
5
  import { pick } from 'lodash';
6
  // import { delay } from '@/utils/storeUtil';
 
1
  import { BaseState } from '@/interfaces/common';
2
  import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
3
+ import kbService from '@/services/knowledge-service';
4
  import { message } from 'antd';
5
  import { pick } from 'lodash';
6
  // import { delay } from '@/utils/storeUtil';
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx CHANGED
@@ -6,17 +6,17 @@ import {
6
  useRunDocument,
7
  useSelectDocumentList,
8
  useUploadDocument,
9
- } from '@/hooks/documentHooks';
10
  import {
11
  useDeleteDocumentById,
12
  useFetchKnowledgeDetail,
13
  useKnowledgeBaseId,
14
- } from '@/hooks/knowledgeHook';
15
  import {
16
  useChangeDocumentParser,
17
  useSetSelectedRecord,
18
  } from '@/hooks/logic-hooks';
19
- import { useFetchTenantInfo } from '@/hooks/userSettingHook';
20
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
21
  import { getExtension, isFileUploadDone } from '@/utils/documentUtils';
22
  import {
@@ -40,7 +40,7 @@ import classNames from 'classnames';
40
  import { ReactElement, useCallback, useMemo, useRef, useState } from 'react';
41
  import { Link, useNavigate } from 'umi';
42
 
43
- import { useTranslate } from '@/hooks/commonHooks';
44
  import styles from './index.less';
45
 
46
  const { Dragger } = Upload;
 
6
  useRunDocument,
7
  useSelectDocumentList,
8
  useUploadDocument,
9
+ } from '@/hooks/document-hooks';
10
  import {
11
  useDeleteDocumentById,
12
  useFetchKnowledgeDetail,
13
  useKnowledgeBaseId,
14
+ } from '@/hooks/knowledge-hooks';
15
  import {
16
  useChangeDocumentParser,
17
  useSetSelectedRecord,
18
  } from '@/hooks/logic-hooks';
19
+ import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
20
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
21
  import { getExtension, isFileUploadDone } from '@/utils/documentUtils';
22
  import {
 
40
  import { ReactElement, useCallback, useMemo, useRef, useState } from 'react';
41
  import { Link, useNavigate } from 'umi';
42
 
43
+ import { useTranslate } from '@/hooks/common-hooks';
44
  import styles from './index.less';
45
 
46
  const { Dragger } = Upload;
web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx CHANGED
@@ -3,13 +3,13 @@ import { ReactComponent as DeleteIcon } from '@/assets/svg/delete.svg';
3
  import { ReactComponent as DisableIcon } from '@/assets/svg/disable.svg';
4
  import { ReactComponent as EnableIcon } from '@/assets/svg/enable.svg';
5
  import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
6
- import { useShowDeleteConfirm, useTranslate } from '@/hooks/commonHooks';
7
  import {
8
  useRemoveDocument,
9
  useRunDocument,
10
  useSetDocumentStatus,
11
- } from '@/hooks/documentHooks';
12
- import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
13
  import {
14
  DownOutlined,
15
  FileOutlined,
 
3
  import { ReactComponent as DisableIcon } from '@/assets/svg/disable.svg';
4
  import { ReactComponent as EnableIcon } from '@/assets/svg/enable.svg';
5
  import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
6
+ import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
7
  import {
8
  useRemoveDocument,
9
  useRunDocument,
10
  useSetDocumentStatus,
11
+ } from '@/hooks/document-hooks';
12
+ import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
13
  import {
14
  DownOutlined,
15
  FileOutlined,
web/src/pages/add-knowledge/components/knowledge-file/hooks.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
2
  import {
3
  useCreateDocument,
4
  useFetchDocumentList,
@@ -8,10 +8,10 @@ import {
8
  useSetDocumentParser,
9
  useUploadDocument,
10
  useWebCrawl,
11
- } from '@/hooks/documentHooks';
12
- import { useGetKnowledgeSearchParams } from '@/hooks/routeHook';
13
- import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
14
- import { useFetchTenantInfo } from '@/hooks/userSettingHook';
15
  import { Pagination } from '@/interfaces/common';
16
  import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
17
  import { getUnSupportedFilesCount } from '@/utils/documentUtils';
@@ -296,13 +296,13 @@ export const useHandleWebCrawl = () => {
296
  const webCrawl = useWebCrawl();
297
 
298
  const onWebCrawlUploadOk = useCallback(
299
- async (name: string, url: string ) => {
300
  const ret = await webCrawl(name, url);
301
  if (ret === 0) {
302
  hideWebCrawlUploadModal();
303
- return 0
304
  }
305
- return -1
306
  },
307
  [webCrawl, hideWebCrawlUploadModal],
308
  );
 
1
+ import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
2
  import {
3
  useCreateDocument,
4
  useFetchDocumentList,
 
8
  useSetDocumentParser,
9
  useUploadDocument,
10
  useWebCrawl,
11
+ } from '@/hooks/document-hooks';
12
+ import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
13
+ import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
14
+ import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
15
  import { Pagination } from '@/interfaces/common';
16
  import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
17
  import { getUnSupportedFilesCount } from '@/utils/documentUtils';
 
296
  const webCrawl = useWebCrawl();
297
 
298
  const onWebCrawlUploadOk = useCallback(
299
+ async (name: string, url: string) => {
300
  const ret = await webCrawl(name, url);
301
  if (ret === 0) {
302
  hideWebCrawlUploadModal();
303
+ return 0;
304
  }
305
+ return -1;
306
  },
307
  [webCrawl, hideWebCrawlUploadModal],
308
  );
web/src/pages/add-knowledge/components/knowledge-file/index.tsx CHANGED
@@ -3,9 +3,9 @@ import SvgIcon from '@/components/svg-icon';
3
  import {
4
  useSelectDocumentList,
5
  useSetDocumentStatus,
6
- } from '@/hooks/documentHooks';
7
  import { useSetSelectedRecord } from '@/hooks/logic-hooks';
8
- import { useSelectParserList } from '@/hooks/userSettingHook';
9
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
10
  import { getExtension } from '@/utils/documentUtils';
11
  import { Divider, Flex, Switch, Table, Typography } from 'antd';
 
3
  import {
4
  useSelectDocumentList,
5
  useSetDocumentStatus,
6
+ } from '@/hooks/document-hooks';
7
  import { useSetSelectedRecord } from '@/hooks/logic-hooks';
8
+ import { useSelectParserList } from '@/hooks/user-setting-hooks';
9
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
10
  import { getExtension } from '@/utils/documentUtils';
11
  import { Divider, Flex, Switch, Table, Typography } from 'antd';
web/src/pages/add-knowledge/components/knowledge-file/model.ts CHANGED
@@ -1,276 +1,276 @@
1
- import { BaseState } from '@/interfaces/common';
2
- import { IKnowledgeFile } from '@/interfaces/database/knowledge';
3
- import i18n from '@/locales/config';
4
- import kbService, { getDocumentFile } from '@/services/kbService';
5
- import { message } from 'antd';
6
- import omit from 'lodash/omit';
7
- import pick from 'lodash/pick';
8
- import { DvaModel } from 'umi';
9
-
10
- export interface KFModelState extends BaseState {
11
- tenantIfo: any;
12
- data: IKnowledgeFile[];
13
- total: number;
14
- currentRecord: Nullable<IKnowledgeFile>;
15
- fileThumbnails: Record<string, string>;
16
- }
17
-
18
- const model: DvaModel<KFModelState> = {
19
- namespace: 'kFModel',
20
- state: {
21
- tenantIfo: {},
22
- data: [],
23
- total: 0,
24
- currentRecord: null,
25
- searchString: '',
26
- pagination: {
27
- current: 1,
28
- pageSize: 10,
29
- },
30
- fileThumbnails: {} as Record<string, string>,
31
- },
32
- reducers: {
33
- updateState(state, { payload }) {
34
- return {
35
- ...state,
36
- ...payload,
37
- };
38
- },
39
-
40
- setCurrentRecord(state, { payload }) {
41
- return { ...state, currentRecord: payload };
42
- },
43
- setSearchString(state, { payload }) {
44
- return { ...state, searchString: payload };
45
- },
46
- setPagination(state, { payload }) {
47
- return { ...state, pagination: { ...state.pagination, ...payload } };
48
- },
49
- setFileThumbnails(state, { payload }) {
50
- return { ...state, fileThumbnails: payload };
51
- },
52
- },
53
- effects: {
54
- *createKf({ payload = {} }, { call }) {
55
- const { data } = yield call(kbService.createKb, payload);
56
- const { retcode } = data;
57
- if (retcode === 0) {
58
- message.success(i18n.t('message.created'));
59
- }
60
- },
61
- *updateKf({ payload = {} }, { call }) {
62
- const { data } = yield call(kbService.updateKb, payload);
63
- const { retcode } = data;
64
- if (retcode === 0) {
65
- message.success(i18n.t('message.modified'));
66
- }
67
- },
68
- *getKfDetail({ payload = {} }, { call }) {
69
- const { data } = yield call(kbService.get_kb_detail, payload);
70
- },
71
- *getKfList({ payload = {} }, { call, put, select }) {
72
- const state: KFModelState = yield select((state: any) => state.kFModel);
73
- const requestBody = {
74
- ...payload,
75
- page: state.pagination.current,
76
- page_size: state.pagination.pageSize,
77
- };
78
- if (state.searchString) {
79
- requestBody['keywords'] = state.searchString;
80
- }
81
- const { data } = yield call(kbService.get_document_list, requestBody);
82
- const { retcode, data: res } = data;
83
-
84
- if (retcode === 0) {
85
- yield put({
86
- type: 'updateState',
87
- payload: {
88
- data: res.docs,
89
- total: res.total,
90
- },
91
- });
92
- }
93
- },
94
- throttledGetDocumentList: [
95
- function* ({ payload }, { call, put }) {
96
- yield put({ type: 'getKfList', payload: { kb_id: payload } });
97
- },
98
- { type: 'throttle', ms: 1000 }, // TODO: Provide type support for this effect
99
- ],
100
- pollGetDocumentList: [
101
- function* ({ payload }, { call, put }) {
102
- yield put({ type: 'getKfList', payload: { kb_id: payload } });
103
- },
104
- { type: 'poll', delay: 5000 }, // TODO: Provide type support for this effect
105
- ],
106
- *updateDocumentStatus({ payload = {} }, { call, put }) {
107
- const { data } = yield call(
108
- kbService.document_change_status,
109
- pick(payload, ['doc_id', 'status']),
110
- );
111
- const { retcode } = data;
112
- if (retcode === 0) {
113
- message.success(i18n.t('message.modified'));
114
- yield put({
115
- type: 'getKfList',
116
- payload: { kb_id: payload.kb_id },
117
- });
118
- }
119
- },
120
- *document_rm({ payload = {} }, { call, put }) {
121
- const { data } = yield call(kbService.document_rm, {
122
- doc_id: payload.doc_id,
123
- });
124
- const { retcode } = data;
125
- if (retcode === 0) {
126
- message.success(i18n.t('message.deleted'));
127
- yield put({
128
- type: 'getKfList',
129
- payload: { kb_id: payload.kb_id },
130
- });
131
- }
132
- return retcode;
133
- },
134
- *document_rename({ payload = {} }, { call, put }) {
135
- const { data } = yield call(
136
- kbService.document_rename,
137
- omit(payload, ['kb_id']),
138
- );
139
- const { retcode } = data;
140
- if (retcode === 0) {
141
- message.success(i18n.t('message.renamed'));
142
-
143
- yield put({
144
- type: 'getKfList',
145
- payload: { kb_id: payload.kb_id },
146
- });
147
- }
148
-
149
- return retcode;
150
- },
151
- *document_create({ payload = {} }, { call, put }) {
152
- const { data } = yield call(kbService.document_create, payload);
153
- const { retcode } = data;
154
- if (retcode === 0) {
155
- yield put({
156
- type: 'getKfList',
157
- payload: { kb_id: payload.kb_id },
158
- });
159
-
160
- message.success(i18n.t('message.created'));
161
- }
162
- return retcode;
163
- },
164
- *document_run({ payload = {} }, { call, put }) {
165
- const { data } = yield call(
166
- kbService.document_run,
167
- omit(payload, ['knowledgeBaseId']),
168
- );
169
- const { retcode } = data;
170
- if (retcode === 0) {
171
- if (payload.knowledgeBaseId) {
172
- yield put({
173
- type: 'getKfList',
174
- payload: { kb_id: payload.knowledgeBaseId },
175
- });
176
- }
177
- message.success(i18n.t('message.operated'));
178
- }
179
- return retcode;
180
- },
181
- *document_change_parser({ payload = {} }, { call, put }) {
182
- const { data } = yield call(
183
- kbService.document_change_parser,
184
- omit(payload, ['kb_id']),
185
- );
186
- const { retcode } = data;
187
- if (retcode === 0) {
188
- yield put({
189
- type: 'getKfList',
190
- payload: { kb_id: payload.kb_id },
191
- });
192
-
193
- message.success(i18n.t('message.modified'));
194
- }
195
- return retcode;
196
- },
197
- *fetch_document_thumbnails({ payload = {} }, { call, put }) {
198
- const { data } = yield call(kbService.document_thumbnails, payload);
199
- if (data.retcode === 0) {
200
- yield put({ type: 'setFileThumbnails', payload: data.data });
201
- }
202
- },
203
- *fetch_document_file({ payload = {} }, { call }) {
204
- const documentId = payload;
205
- try {
206
- const ret = yield call(getDocumentFile, documentId);
207
- return ret;
208
- } catch (error) {
209
- console.warn(error);
210
- }
211
- },
212
- *upload_document({ payload = {} }, { call, put }) {
213
- const fileList = payload.fileList;
214
- const formData = new FormData();
215
- formData.append('kb_id', payload.kb_id);
216
- fileList.forEach((file: any) => {
217
- formData.append('file', file);
218
- });
219
-
220
- const { data } = yield call(kbService.document_upload, formData);
221
-
222
- const succeed = data.retcode === 0;
223
-
224
- if (succeed) {
225
- message.success(i18n.t('message.uploaded'));
226
- }
227
- if (succeed || data.retcode === 500) {
228
- yield put({
229
- type: 'getKfList',
230
- payload: { kb_id: payload.kb_id },
231
- });
232
- }
233
- return data;
234
- },
235
- *web_crawl({ payload = {} }, { call, put }) {
236
- const formData = new FormData();
237
- formData.append('name', payload.name);
238
- formData.append('url', payload.url);
239
- formData.append('kb_id', payload.kb_id);
240
-
241
- const { data } = yield call(kbService.web_crawl, formData);
242
-
243
- const succeed = data.retcode === 0;
244
-
245
- if (succeed) {
246
- message.success(i18n.t('message.uploaded'));
247
- }
248
- if (succeed || data.retcode === 500) {
249
- yield put({
250
- type: 'getKfList',
251
- payload: { kb_id: payload.kb_id },
252
- });
253
- }
254
- return data.retcode;
255
- },
256
- },
257
- subscriptions: {
258
- setup({ dispatch, history }) {
259
- history.listen(({ location }) => {
260
- const state: { from: string } = (location.state ?? {
261
- from: '',
262
- }) as { from: string };
263
- if (
264
- state.from === '/knowledge' || // TODO: Just directly determine whether the current page is on the knowledge list page.
265
- location.pathname === '/knowledge/dataset/upload'
266
- ) {
267
- dispatch({
268
- type: 'setPagination',
269
- payload: { current: 1, pageSize: 10 },
270
- });
271
- }
272
- });
273
- },
274
- },
275
- };
276
- export default model;
 
1
+ import { BaseState } from '@/interfaces/common';
2
+ import { IKnowledgeFile } from '@/interfaces/database/knowledge';
3
+ import i18n from '@/locales/config';
4
+ import kbService, { getDocumentFile } from '@/services/knowledge-service';
5
+ import { message } from 'antd';
6
+ import omit from 'lodash/omit';
7
+ import pick from 'lodash/pick';
8
+ import { DvaModel } from 'umi';
9
+
10
+ export interface KFModelState extends BaseState {
11
+ tenantIfo: any;
12
+ data: IKnowledgeFile[];
13
+ total: number;
14
+ currentRecord: Nullable<IKnowledgeFile>;
15
+ fileThumbnails: Record<string, string>;
16
+ }
17
+
18
+ const model: DvaModel<KFModelState> = {
19
+ namespace: 'kFModel',
20
+ state: {
21
+ tenantIfo: {},
22
+ data: [],
23
+ total: 0,
24
+ currentRecord: null,
25
+ searchString: '',
26
+ pagination: {
27
+ current: 1,
28
+ pageSize: 10,
29
+ },
30
+ fileThumbnails: {} as Record<string, string>,
31
+ },
32
+ reducers: {
33
+ updateState(state, { payload }) {
34
+ return {
35
+ ...state,
36
+ ...payload,
37
+ };
38
+ },
39
+
40
+ setCurrentRecord(state, { payload }) {
41
+ return { ...state, currentRecord: payload };
42
+ },
43
+ setSearchString(state, { payload }) {
44
+ return { ...state, searchString: payload };
45
+ },
46
+ setPagination(state, { payload }) {
47
+ return { ...state, pagination: { ...state.pagination, ...payload } };
48
+ },
49
+ setFileThumbnails(state, { payload }) {
50
+ return { ...state, fileThumbnails: payload };
51
+ },
52
+ },
53
+ effects: {
54
+ *createKf({ payload = {} }, { call }) {
55
+ const { data } = yield call(kbService.createKb, payload);
56
+ const { retcode } = data;
57
+ if (retcode === 0) {
58
+ message.success(i18n.t('message.created'));
59
+ }
60
+ },
61
+ *updateKf({ payload = {} }, { call }) {
62
+ const { data } = yield call(kbService.updateKb, payload);
63
+ const { retcode } = data;
64
+ if (retcode === 0) {
65
+ message.success(i18n.t('message.modified'));
66
+ }
67
+ },
68
+ *getKfDetail({ payload = {} }, { call }) {
69
+ const { data } = yield call(kbService.get_kb_detail, payload);
70
+ },
71
+ *getKfList({ payload = {} }, { call, put, select }) {
72
+ const state: KFModelState = yield select((state: any) => state.kFModel);
73
+ const requestBody = {
74
+ ...payload,
75
+ page: state.pagination.current,
76
+ page_size: state.pagination.pageSize,
77
+ };
78
+ if (state.searchString) {
79
+ requestBody['keywords'] = state.searchString;
80
+ }
81
+ const { data } = yield call(kbService.get_document_list, requestBody);
82
+ const { retcode, data: res } = data;
83
+
84
+ if (retcode === 0) {
85
+ yield put({
86
+ type: 'updateState',
87
+ payload: {
88
+ data: res.docs,
89
+ total: res.total,
90
+ },
91
+ });
92
+ }
93
+ },
94
+ throttledGetDocumentList: [
95
+ function* ({ payload }, { call, put }) {
96
+ yield put({ type: 'getKfList', payload: { kb_id: payload } });
97
+ },
98
+ { type: 'throttle', ms: 1000 }, // TODO: Provide type support for this effect
99
+ ],
100
+ pollGetDocumentList: [
101
+ function* ({ payload }, { call, put }) {
102
+ yield put({ type: 'getKfList', payload: { kb_id: payload } });
103
+ },
104
+ { type: 'poll', delay: 5000 }, // TODO: Provide type support for this effect
105
+ ],
106
+ *updateDocumentStatus({ payload = {} }, { call, put }) {
107
+ const { data } = yield call(
108
+ kbService.document_change_status,
109
+ pick(payload, ['doc_id', 'status']),
110
+ );
111
+ const { retcode } = data;
112
+ if (retcode === 0) {
113
+ message.success(i18n.t('message.modified'));
114
+ yield put({
115
+ type: 'getKfList',
116
+ payload: { kb_id: payload.kb_id },
117
+ });
118
+ }
119
+ },
120
+ *document_rm({ payload = {} }, { call, put }) {
121
+ const { data } = yield call(kbService.document_rm, {
122
+ doc_id: payload.doc_id,
123
+ });
124
+ const { retcode } = data;
125
+ if (retcode === 0) {
126
+ message.success(i18n.t('message.deleted'));
127
+ yield put({
128
+ type: 'getKfList',
129
+ payload: { kb_id: payload.kb_id },
130
+ });
131
+ }
132
+ return retcode;
133
+ },
134
+ *document_rename({ payload = {} }, { call, put }) {
135
+ const { data } = yield call(
136
+ kbService.document_rename,
137
+ omit(payload, ['kb_id']),
138
+ );
139
+ const { retcode } = data;
140
+ if (retcode === 0) {
141
+ message.success(i18n.t('message.renamed'));
142
+
143
+ yield put({
144
+ type: 'getKfList',
145
+ payload: { kb_id: payload.kb_id },
146
+ });
147
+ }
148
+
149
+ return retcode;
150
+ },
151
+ *document_create({ payload = {} }, { call, put }) {
152
+ const { data } = yield call(kbService.document_create, payload);
153
+ const { retcode } = data;
154
+ if (retcode === 0) {
155
+ yield put({
156
+ type: 'getKfList',
157
+ payload: { kb_id: payload.kb_id },
158
+ });
159
+
160
+ message.success(i18n.t('message.created'));
161
+ }
162
+ return retcode;
163
+ },
164
+ *document_run({ payload = {} }, { call, put }) {
165
+ const { data } = yield call(
166
+ kbService.document_run,
167
+ omit(payload, ['knowledgeBaseId']),
168
+ );
169
+ const { retcode } = data;
170
+ if (retcode === 0) {
171
+ if (payload.knowledgeBaseId) {
172
+ yield put({
173
+ type: 'getKfList',
174
+ payload: { kb_id: payload.knowledgeBaseId },
175
+ });
176
+ }
177
+ message.success(i18n.t('message.operated'));
178
+ }
179
+ return retcode;
180
+ },
181
+ *document_change_parser({ payload = {} }, { call, put }) {
182
+ const { data } = yield call(
183
+ kbService.document_change_parser,
184
+ omit(payload, ['kb_id']),
185
+ );
186
+ const { retcode } = data;
187
+ if (retcode === 0) {
188
+ yield put({
189
+ type: 'getKfList',
190
+ payload: { kb_id: payload.kb_id },
191
+ });
192
+
193
+ message.success(i18n.t('message.modified'));
194
+ }
195
+ return retcode;
196
+ },
197
+ *fetch_document_thumbnails({ payload = {} }, { call, put }) {
198
+ const { data } = yield call(kbService.document_thumbnails, payload);
199
+ if (data.retcode === 0) {
200
+ yield put({ type: 'setFileThumbnails', payload: data.data });
201
+ }
202
+ },
203
+ *fetch_document_file({ payload = {} }, { call }) {
204
+ const documentId = payload;
205
+ try {
206
+ const ret = yield call(getDocumentFile, documentId);
207
+ return ret;
208
+ } catch (error) {
209
+ console.warn(error);
210
+ }
211
+ },
212
+ *upload_document({ payload = {} }, { call, put }) {
213
+ const fileList = payload.fileList;
214
+ const formData = new FormData();
215
+ formData.append('kb_id', payload.kb_id);
216
+ fileList.forEach((file: any) => {
217
+ formData.append('file', file);
218
+ });
219
+
220
+ const { data } = yield call(kbService.document_upload, formData);
221
+
222
+ const succeed = data.retcode === 0;
223
+
224
+ if (succeed) {
225
+ message.success(i18n.t('message.uploaded'));
226
+ }
227
+ if (succeed || data.retcode === 500) {
228
+ yield put({
229
+ type: 'getKfList',
230
+ payload: { kb_id: payload.kb_id },
231
+ });
232
+ }
233
+ return data;
234
+ },
235
+ *web_crawl({ payload = {} }, { call, put }) {
236
+ const formData = new FormData();
237
+ formData.append('name', payload.name);
238
+ formData.append('url', payload.url);
239
+ formData.append('kb_id', payload.kb_id);
240
+
241
+ const { data } = yield call(kbService.web_crawl, formData);
242
+
243
+ const succeed = data.retcode === 0;
244
+
245
+ if (succeed) {
246
+ message.success(i18n.t('message.uploaded'));
247
+ }
248
+ if (succeed || data.retcode === 500) {
249
+ yield put({
250
+ type: 'getKfList',
251
+ payload: { kb_id: payload.kb_id },
252
+ });
253
+ }
254
+ return data.retcode;
255
+ },
256
+ },
257
+ subscriptions: {
258
+ setup({ dispatch, history }) {
259
+ history.listen(({ location }) => {
260
+ const state: { from: string } = (location.state ?? {
261
+ from: '',
262
+ }) as { from: string };
263
+ if (
264
+ state.from === '/knowledge' || // TODO: Just directly determine whether the current page is on the knowledge list page.
265
+ location.pathname === '/knowledge/dataset/upload'
266
+ ) {
267
+ dispatch({
268
+ type: 'setPagination',
269
+ payload: { current: 1, pageSize: 10 },
270
+ });
271
+ }
272
+ });
273
+ },
274
+ },
275
+ };
276
+ export default model;
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { useShowDeleteConfirm, useTranslate } from '@/hooks/commonHooks';
2
- import { useRemoveDocument } from '@/hooks/documentHooks';
3
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
4
  import { api_host } from '@/utils/api';
5
  import { downloadFile } from '@/utils/fileUtil';
 
1
+ import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
2
+ import { useRemoveDocument } from '@/hooks/document-hooks';
3
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
4
  import { api_host } from '@/utils/api';
5
  import { downloadFile } from '@/utils/fileUtil';
web/src/pages/add-knowledge/components/knowledge-file/parsing-status-cell/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import { ReactComponent as CancelIcon } from '@/assets/svg/cancel.svg';
2
  import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg';
3
  import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
4
- import { useTranslate } from '@/hooks/commonHooks';
5
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
6
  import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
7
  import classNames from 'classnames';
 
1
  import { ReactComponent as CancelIcon } from '@/assets/svg/cancel.svg';
2
  import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg';
3
  import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
4
+ import { useTranslate } from '@/hooks/common-hooks';
5
  import { IKnowledgeFile } from '@/interfaces/database/knowledge';
6
  import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
7
  import classNames from 'classnames';
web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
- import { useTranslate } from '@/hooks/commonHooks';
3
  import { Form, Input, Modal } from 'antd';
4
  import { useEffect } from 'react';
5
 
 
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
  import { Form, Input, Modal } from 'antd';
4
  import { useEffect } from 'react';
5
 
web/src/pages/add-knowledge/components/knowledge-file/web-crawl-modal.tsx CHANGED
@@ -1,8 +1,7 @@
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
 
2
  import { Form, Input, Modal } from 'antd';
3
  import React from 'react';
4
- import {useTranslate} from "@/hooks/commonHooks";
5
-
6
 
7
  interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
8
  loading: boolean;
@@ -36,14 +35,28 @@ const WebCrawlModal: React.FC<IProps> = ({ visible, hideModal, onOk }) => {
36
  <Form.Item
37
  label="Name"
38
  name="name"
39
- rules={[{ required: true, message: 'Please input name!' },{ max: 10, message: 'The maximum length of name is 128 characters' }]}
 
 
 
 
 
 
40
  >
41
  <Input placeholder="Document name" />
42
  </Form.Item>
43
  <Form.Item
44
  label="URL"
45
  name="url"
46
- rules={[{ required: true, message: 'Please input url!' },{pattern: new RegExp('(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]'), message: 'Please enter a valid URL!'}]}
 
 
 
 
 
 
 
 
47
  >
48
  <Input placeholder="https://www.baidu.com" />
49
  </Form.Item>
 
1
  import { IModalManagerChildrenProps } from '@/components/modal-manager';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
  import { Form, Input, Modal } from 'antd';
4
  import React from 'react';
 
 
5
 
6
  interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
7
  loading: boolean;
 
35
  <Form.Item
36
  label="Name"
37
  name="name"
38
+ rules={[
39
+ { required: true, message: 'Please input name!' },
40
+ {
41
+ max: 10,
42
+ message: 'The maximum length of name is 128 characters',
43
+ },
44
+ ]}
45
  >
46
  <Input placeholder="Document name" />
47
  </Form.Item>
48
  <Form.Item
49
  label="URL"
50
  name="url"
51
+ rules={[
52
+ { required: true, message: 'Please input url!' },
53
+ {
54
+ pattern: new RegExp(
55
+ '(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]',
56
+ ),
57
+ message: 'Please enter a valid URL!',
58
+ },
59
+ ]}
60
  >
61
  <Input placeholder="https://www.baidu.com" />
62
  </Form.Item>
web/src/pages/add-knowledge/components/knowledge-setting/category-panel.tsx CHANGED
@@ -1,6 +1,6 @@
1
  import SvgIcon from '@/components/svg-icon';
2
- import { useTranslate } from '@/hooks/commonHooks';
3
- import { useSelectParserList } from '@/hooks/userSettingHook';
4
  import { Col, Divider, Empty, Row, Typography } from 'antd';
5
  import DOMPurify from 'dompurify';
6
  import { useMemo } from 'react';
 
1
  import SvgIcon from '@/components/svg-icon';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
+ import { useSelectParserList } from '@/hooks/user-setting-hooks';
4
  import { Col, Divider, Empty, Row, Typography } from 'antd';
5
  import DOMPurify from 'dompurify';
6
  import { useMemo } from 'react';
web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx CHANGED
@@ -11,7 +11,7 @@ import MaxTokenNumber from '@/components/max-token-number';
11
  import ParseConfiguration, {
12
  showRaptorParseConfiguration,
13
  } from '@/components/parse-configuration';
14
- import { useTranslate } from '@/hooks/commonHooks';
15
  import { FormInstance } from 'antd/lib';
16
  import styles from './index.less';
17
 
 
11
  import ParseConfiguration, {
12
  showRaptorParseConfiguration,
13
  } from '@/components/parse-configuration';
14
+ import { useTranslate } from '@/hooks/common-hooks';
15
  import { FormInstance } from 'antd/lib';
16
  import styles from './index.less';
17
 
web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts CHANGED
@@ -3,14 +3,14 @@ import {
3
  useKnowledgeBaseId,
4
  useSelectKnowledgeDetails,
5
  useUpdateKnowledge,
6
- } from '@/hooks/knowledgeHook';
7
- import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks';
8
- import { useNavigateToDataset } from '@/hooks/routeHook';
9
- import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
10
  import {
11
  useFetchTenantInfo,
12
  useSelectParserList,
13
- } from '@/hooks/userSettingHook';
14
  import {
15
  getBase64FromUploadFileList,
16
  getUploadFileListFromBase64,
 
3
  useKnowledgeBaseId,
4
  useSelectKnowledgeDetails,
5
  useUpdateKnowledge,
6
+ } from '@/hooks/knowledge-hooks';
7
+ import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llm-hooks';
8
+ import { useNavigateToDataset } from '@/hooks/route-hook';
9
+ import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
10
  import {
11
  useFetchTenantInfo,
12
  useSelectParserList,
13
+ } from '@/hooks/user-setting-hooks';
14
  import {
15
  getBase64FromUploadFileList,
16
  getUploadFileListFromBase64,