From fc4e644e5f174d0364eb3137fe31be0c78d91ee0 Mon Sep 17 00:00:00 2001 From: balibabu Date: Tue, 10 Dec 2024 16:36:16 +0800 Subject: [PATCH] Feat: Modify the data structure of the chunk in the conversation #3909 (#3955) ### What problem does this PR solve? Feat: Modify the data structure of the chunk in the conversation #3909 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- .../api-service/chat-api-key-modal/index.tsx | 2 +- .../chat-overview-modal/api-content.tsx | 17 +-- .../api-service/embed-modal/index.less | 4 + .../api-service/embed-modal/index.tsx | 35 +++++- web/src/components/api-service/hooks.ts | 55 ++++++--- web/src/components/message-item/index.tsx | 5 +- web/src/components/pdf-drawer/hooks.ts | 8 +- web/src/components/pdf-drawer/index.tsx | 3 +- web/src/components/pdf-previewer/index.tsx | 7 +- web/src/hooks/chat-hooks.ts | 8 +- web/src/hooks/document-hooks.ts | 5 +- web/src/hooks/logic-hooks.ts | 2 + web/src/hooks/user-setting-hooks.tsx | 24 +++- web/src/interfaces/database/chat.ts | 19 ++- web/src/locales/config.ts | 2 +- web/src/locales/en.ts | 1 + web/src/locales/ja.ts | 33 +++-- web/src/locales/zh-traditional.ts | 1 + web/src/locales/zh.ts | 1 + web/src/pages/chat/index.tsx | 35 +++--- web/src/pages/chat/markdown-content/index.tsx | 18 +-- web/src/pages/chat/share/large.tsx | 31 +++-- web/src/pages/chat/shared-hooks.ts | 113 ++++++------------ web/src/pages/flow/header/index.tsx | 47 ++++---- web/src/pages/flow/hooks.tsx | 14 +++ web/src/utils/authorization-util.ts | 6 +- web/src/utils/document-util.ts | 10 +- 27 files changed, 304 insertions(+), 202 deletions(-) diff --git a/web/src/components/api-service/chat-api-key-modal/index.tsx b/web/src/components/api-service/chat-api-key-modal/index.tsx index e586d372..2497f0fa 100644 --- a/web/src/components/api-service/chat-api-key-modal/index.tsx +++ b/web/src/components/api-service/chat-api-key-modal/index.tsx @@ -63,7 +63,7 @@ const ChatApiKeyModal = ({ diff --git a/web/src/components/api-service/chat-overview-modal/api-content.tsx b/web/src/components/api-service/chat-overview-modal/api-content.tsx index 033e28e8..cd00e69f 100644 --- a/web/src/components/api-service/chat-overview-modal/api-content.tsx +++ b/web/src/components/api-service/chat-overview-modal/api-content.tsx @@ -3,8 +3,7 @@ import apiDoc from '@parent/docs/references/http_api_reference.md'; import MarkdownPreview from '@uiw/react-markdown-preview'; import { Button, Card, Flex, Space } from 'antd'; import ChatApiKeyModal from '../chat-api-key-modal'; -import EmbedModal from '../embed-modal'; -import { usePreviewChat, useShowEmbedModal } from '../hooks'; +import { usePreviewChat } from '../hooks'; import BackendServiceApi from './backend-service-api'; const ApiContent = ({ @@ -22,10 +21,10 @@ const ApiContent = ({ hideModal: hideApiKeyModal, showModal: showApiKeyModal, } = useSetModalState(); - const { embedVisible, hideEmbedModal, showEmbedModal, embedToken } = - useShowEmbedModal(idKey, id); + // const { embedVisible, hideEmbedModal, showEmbedModal, embedToken } = + // useShowEmbedModal(idKey); - const { handlePreview } = usePreviewChat(idKey, id); + const { handlePreview } = usePreviewChat(idKey); return (
@@ -36,7 +35,9 @@ const ApiContent = ({ - + {/* */} @@ -50,13 +51,13 @@ const ApiContent = ({ idKey={idKey} > )} - {embedVisible && ( + {/* {embedVisible && ( - )} + )} */}
); }; diff --git a/web/src/components/api-service/embed-modal/index.less b/web/src/components/api-service/embed-modal/index.less index b2c0cfbb..cf393470 100644 --- a/web/src/components/api-service/embed-modal/index.less +++ b/web/src/components/api-service/embed-modal/index.less @@ -6,3 +6,7 @@ padding: 10px; background-color: #ffffff09; } + +.id { + .linkText(); +} diff --git a/web/src/components/api-service/embed-modal/index.tsx b/web/src/components/api-service/embed-modal/index.tsx index 7c142b72..1caee0a6 100644 --- a/web/src/components/api-service/embed-modal/index.tsx +++ b/web/src/components/api-service/embed-modal/index.tsx @@ -1,21 +1,33 @@ import CopyToClipboard from '@/components/copy-to-clipboard'; import HightLightMarkdown from '@/components/highlight-markdown'; +import { SharedFrom } from '@/constants/chat'; import { useTranslate } from '@/hooks/common-hooks'; import { IModalProps } from '@/interfaces/common'; -import { Card, Modal, Tabs, TabsProps } from 'antd'; +import { Card, Modal, Tabs, TabsProps, Typography } from 'antd'; + import styles from './index.less'; +const { Paragraph, Link } = Typography; + const EmbedModal = ({ visible, hideModal, token = '', -}: IModalProps & { token: string }) => { + form, + beta = '', + isAgent, +}: IModalProps & { + token: string; + form: SharedFrom; + beta: string; + isAgent: boolean; +}) => { const { t } = useTranslate('chat'); const text = ` ~~~ html