diff --git a/docSite/content/zh-cn/docs/development/upgrading/484.md b/docSite/content/zh-cn/docs/development/upgrading/484.md new file mode 100644 index 000000000..fd551cd42 --- /dev/null +++ b/docSite/content/zh-cn/docs/development/upgrading/484.md @@ -0,0 +1,22 @@ +--- +title: 'V4.8.4(进行中)' +description: 'FastGPT V4.8.4 更新说明' +icon: 'upgrade' +draft: false +toc: true +weight: 821 +--- + + + +## V4.8.4 更新说明 + +1. 新增 - 应用使用新权限系统。 +2. 优化 - 文本分割增加连续换行、制表符清除,避免大文本性能问题。 +3. 修复 - Debug 模式下,相同 source 和 target 内容,导致连线显示异常。 +4. 修复 - 定时执行初始化错误。 +5. 调整组件库全局theme。 \ No newline at end of file diff --git a/packages/global/common/string/textSplitter.ts b/packages/global/common/string/textSplitter.ts index 7ef609a74..41c09df5a 100644 --- a/packages/global/common/string/textSplitter.ts +++ b/packages/global/common/string/textSplitter.ts @@ -102,6 +102,8 @@ const commonSplit = (props: SplitProps): SplitResponse => { text = text.replace(/(```[\s\S]*?```|~~~[\s\S]*?~~~)/g, function (match) { return match.replace(/\n/g, codeBlockMarker); }); + // replace invalid \n + text = text.replace(/(\r?\n|\r){3,}/g, '\n\n\n'); // The larger maxLen is, the next sentence is less likely to trigger splitting const stepReges: { reg: RegExp; maxLen: number }[] = [ @@ -338,7 +340,7 @@ const commonSplit = (props: SplitProps): SplitResponse => { */ export const splitText2Chunks = (props: SplitProps): SplitResponse => { let { text = '' } = props; - + const start = Date.now(); const splitWithCustomSign = text.split(CUSTOM_SPLIT_SIGN); const splitResult = splitWithCustomSign.map((item) => { @@ -348,7 +350,7 @@ export const splitText2Chunks = (props: SplitProps): SplitResponse => { return commonSplit(props); }); - + console.log(Date.now() - start); return { chunks: splitResult.map((item) => item.chunks).flat(), chars: splitResult.reduce((sum, item) => sum + item.chars, 0) diff --git a/packages/global/core/workflow/template/system/systemConfig.ts b/packages/global/core/workflow/template/system/systemConfig.ts index fbaffe118..c563dbefd 100644 --- a/packages/global/core/workflow/template/system/systemConfig.ts +++ b/packages/global/core/workflow/template/system/systemConfig.ts @@ -1,6 +1,6 @@ import { FlowNodeTypeEnum } from '../../node/constant'; import { FlowNodeTemplateType } from '../../type/index.d'; -import { FlowNodeTemplateTypeEnum, WorkflowIOValueTypeEnum } from '../../constants'; +import { FlowNodeTemplateTypeEnum } from '../../constants'; import { getHandleConfig } from '../utils'; export const SystemConfigNode: FlowNodeTemplateType = { diff --git a/packages/service/common/file/gridfs/controller.ts b/packages/service/common/file/gridfs/controller.ts index 88242d2bb..147cb4656 100644 --- a/packages/service/common/file/gridfs/controller.ts +++ b/packages/service/common/file/gridfs/controller.ts @@ -8,7 +8,7 @@ import { detectFileEncoding } from '@fastgpt/global/common/file/tools'; import { CommonErrEnum } from '@fastgpt/global/common/error/code/common'; import { MongoRawTextBuffer } from '../../buffer/rawText/schema'; import { readRawContentByFileBuffer } from '../read/utils'; -import { PassThrough } from 'stream'; +import { gridFsStream2Buffer } from './utils'; export function getGFSCollection(bucket: `${BucketNameEnum}`) { MongoFileSchema; @@ -113,35 +113,16 @@ export async function getDownloadStream({ fileId: string; }) { const bucket = getGridBucket(bucketName); - const stream = bucket.openDownloadStream(new Types.ObjectId(fileId)); - const copyStream = stream.pipe(new PassThrough()); + const encodeStream = bucket.openDownloadStream(new Types.ObjectId(fileId), { end: 100 }); + const rawStream = bucket.openDownloadStream(new Types.ObjectId(fileId)); /* get encoding */ - const buffer = await (() => { - return new Promise((resolve, reject) => { - let tmpBuffer: Buffer = Buffer.from([]); - - stream.on('data', (chunk) => { - if (tmpBuffer.length < 20) { - tmpBuffer = Buffer.concat([tmpBuffer, chunk]); - } - if (tmpBuffer.length >= 20) { - resolve(tmpBuffer); - } - }); - stream.on('end', () => { - resolve(tmpBuffer); - }); - stream.on('error', (err) => { - reject(err); - }); - }); - })(); + const buffer = await gridFsStream2Buffer(encodeStream); const encoding = detectFileEncoding(buffer); return { - fileStream: copyStream, + fileStream: rawStream, encoding // encoding: 'utf-8' }; @@ -169,32 +150,21 @@ export const readFileContentFromMongo = async ({ filename: fileBuffer.metadata?.filename || '' }; } + const start = Date.now(); const [file, { encoding, fileStream }] = await Promise.all([ getFileById({ bucketName, fileId }), getDownloadStream({ bucketName, fileId }) ]); - + // console.log('get file stream', Date.now() - start); if (!file) { return Promise.reject(CommonErrEnum.fileNotFound); } const extension = file?.filename?.split('.')?.pop()?.toLowerCase() || ''; - const fileBuffers = await (() => { - return new Promise((resolve, reject) => { - let buffer = Buffer.from([]); - fileStream.on('data', (chunk) => { - buffer = Buffer.concat([buffer, chunk]); - }); - fileStream.on('end', () => { - resolve(buffer); - }); - fileStream.on('error', (err) => { - reject(err); - }); - }); - })(); + const fileBuffers = await gridFsStream2Buffer(fileStream); + // console.log('get file buffer', Date.now() - start); const { rawText } = await readRawContentByFileBuffer({ extension, diff --git a/packages/service/common/file/gridfs/utils.ts b/packages/service/common/file/gridfs/utils.ts new file mode 100644 index 000000000..27ccafb48 --- /dev/null +++ b/packages/service/common/file/gridfs/utils.ts @@ -0,0 +1,15 @@ +export const gridFsStream2Buffer = (stream: NodeJS.ReadableStream) => { + return new Promise((resolve, reject) => { + let tmpBuffer: Buffer = Buffer.from([]); + + stream.on('data', (chunk) => { + tmpBuffer = Buffer.concat([tmpBuffer, chunk]); + }); + stream.on('end', () => { + resolve(tmpBuffer); + }); + stream.on('error', (err) => { + reject(err); + }); + }); +}; diff --git a/packages/web/components/common/DateRangePicker/index.tsx b/packages/web/components/common/DateRangePicker/index.tsx index ce9dfe81d..4fc096c86 100644 --- a/packages/web/components/common/DateRangePicker/index.tsx +++ b/packages/web/components/common/DateRangePicker/index.tsx @@ -49,11 +49,13 @@ const DateRangePicker = ({ py={1} borderRadius={'sm'} cursor={'pointer'} - bg={'myWhite.600'} + bg={'myGray.100'} fontSize={'sm'} onClick={() => setShowSelected(true)} > - {formatSelected} + + {formatSelected} + {showSelected && ( diff --git a/packages/web/components/common/DndDrag/DragIcon.tsx b/packages/web/components/common/DndDrag/DragIcon.tsx index 36eedd13c..687d14199 100644 --- a/packages/web/components/common/DndDrag/DragIcon.tsx +++ b/packages/web/components/common/DndDrag/DragIcon.tsx @@ -5,7 +5,7 @@ import { DraggableProvided } from 'react-beautiful-dnd'; const DragIcon = ({ provided, ...props }: { provided: DraggableProvided } & BoxProps) => { return ( - + ); diff --git a/packages/web/components/common/EmptyTip/index.tsx b/packages/web/components/common/EmptyTip/index.tsx index e91294353..fd78c8440 100644 --- a/packages/web/components/common/EmptyTip/index.tsx +++ b/packages/web/components/common/EmptyTip/index.tsx @@ -12,7 +12,7 @@ const EmptyTip = ({ text, ...props }: Props) => { return ( - + {text || t('common.empty.Common Tip')} diff --git a/packages/web/components/common/MyBox/FormLabel.tsx b/packages/web/components/common/MyBox/FormLabel.tsx new file mode 100644 index 000000000..bea971fa4 --- /dev/null +++ b/packages/web/components/common/MyBox/FormLabel.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { Box, BoxProps } from '@chakra-ui/react'; + +const FormLabel = ({ + children, + ...props +}: BoxProps & { + children: React.ReactNode; +}) => { + return ( + + {children} + + ); +}; + +export default FormLabel; diff --git a/packages/web/components/common/MyDrawer/CustomRightDrawer.tsx b/packages/web/components/common/MyDrawer/CustomRightDrawer.tsx index 911e62072..14d2dceb1 100644 --- a/packages/web/components/common/MyDrawer/CustomRightDrawer.tsx +++ b/packages/web/components/common/MyDrawer/CustomRightDrawer.tsx @@ -56,7 +56,7 @@ const CustomRightDrawer = ({ )} )} - + {title} diff --git a/packages/web/components/common/MyDrawer/MyRightDrawer.tsx b/packages/web/components/common/MyDrawer/MyRightDrawer.tsx index fe6e22793..e16a15176 100644 --- a/packages/web/components/common/MyDrawer/MyRightDrawer.tsx +++ b/packages/web/components/common/MyDrawer/MyRightDrawer.tsx @@ -61,7 +61,7 @@ const MyRightDrawer = ({ )} )} - + {title} diff --git a/packages/web/components/common/MyMenu/index.tsx b/packages/web/components/common/MyMenu/index.tsx index 02876ca1e..ddd70f5b4 100644 --- a/packages/web/components/common/MyMenu/index.tsx +++ b/packages/web/components/common/MyMenu/index.tsx @@ -9,6 +9,7 @@ import { MenuItemProps } from '@chakra-ui/react'; import MyIcon from '../Icon'; +import MyDivider from '../MyDivider'; type MenuItemType = 'primary' | 'danger'; @@ -18,11 +19,14 @@ export type Props = { Button: React.ReactNode; trigger?: 'hover' | 'click'; menuList: { - isActive?: boolean; - label: string | React.ReactNode; - icon?: string; - type?: MenuItemType; - onClick: () => any; + label?: string; + children: { + isActive?: boolean; + type?: MenuItemType; + icon?: string; + label: string | React.ReactNode; + onClick: () => any; + }[]; }[]; }; @@ -49,9 +53,11 @@ const MyMenu = ({ }; const menuItemStyles: MenuItemProps = { borderRadius: 'sm', - py: 3, + py: 2, + px: 3, display: 'flex', - alignItems: 'center' + alignItems: 'center', + fontSize: 'sm' }; const ref = useRef(null); const closeTimer = useRef(); @@ -109,23 +115,32 @@ const MyMenu = ({ '0px 2px 4px rgba(161, 167, 179, 0.25), 0px 0px 1px rgba(121, 141, 159, 0.25);' } > - {menuList.map((item, i) => ( - { - e.stopPropagation(); - setIsOpen(false); - item.onClick && item.onClick(); - }} - color={item.isActive ? 'primary.700' : 'myGray.600'} - whiteSpace={'pre-wrap'} - > - {!!item.icon && } - {item.label} - - ))} + {menuList.map((item, i) => { + return ( + + {item.label && {item.label}} + {i !== 0 && } + {item.children.map((child, index) => ( + { + e.stopPropagation(); + setIsOpen(false); + child.onClick && child.onClick(); + }} + color={child.isActive ? 'primary.700' : 'myGray.600'} + whiteSpace={'pre-wrap'} + _notLast={{ mb: 0.5 }} + > + {!!child.icon && } + {child.label} + + ))} + + ); + })} diff --git a/packages/web/components/common/MyModal/index.tsx b/packages/web/components/common/MyModal/index.tsx index 2cfd10b6a..8b9ac6837 100644 --- a/packages/web/components/common/MyModal/index.tsx +++ b/packages/web/components/common/MyModal/index.tsx @@ -64,6 +64,7 @@ const MyModal = ({ borderBottom={'1px solid #F4F6F8'} roundedTop={'lg'} py={'10px'} + fontSize={'md'} > {iconSrc && ( <> diff --git a/packages/web/components/common/MySelect/MultipleSelect.tsx b/packages/web/components/common/MySelect/MultipleSelect.tsx index be74e8f08..282d9ba71 100644 --- a/packages/web/components/common/MySelect/MultipleSelect.tsx +++ b/packages/web/components/common/MySelect/MultipleSelect.tsx @@ -1,7 +1,7 @@ import { Box, Flex, useDisclosure, useOutsideClick } from '@chakra-ui/react'; import React, { useRef } from 'react'; import { useTranslation } from 'next-i18next'; -import FillTag from '../Tag/index'; +import MyTag from '../Tag/index'; import MyIcon from '../Icon'; export type SelectProps = { @@ -51,7 +51,7 @@ const MultipleSelect = ({ if (!listItem) return null; return ( - + {listItem.alias || listItem.label} i !== item)); }} /> - + ); })} {value.length === 0 && placeholder && ( diff --git a/packages/web/components/common/MySelect/index.tsx b/packages/web/components/common/MySelect/index.tsx index 05bebfadb..aa1afb2a0 100644 --- a/packages/web/components/common/MySelect/index.tsx +++ b/packages/web/components/common/MySelect/index.tsx @@ -135,6 +135,7 @@ const MySelect = ( } }} whiteSpace={'pre-wrap'} + fontSize={'sm'} > {item.label} diff --git a/packages/web/components/common/MyTooltip/QuestionTip.tsx b/packages/web/components/common/MyTooltip/QuestionTip.tsx index 205245c8a..57a449165 100644 --- a/packages/web/components/common/MyTooltip/QuestionTip.tsx +++ b/packages/web/components/common/MyTooltip/QuestionTip.tsx @@ -9,7 +9,7 @@ type Props = IconProps & { const QuestionTip = ({ label, maxW, ...props }: Props) => { return ( - + ); }; diff --git a/packages/web/components/common/MyTooltip/index.tsx b/packages/web/components/common/MyTooltip/index.tsx index 25982258d..a33e57639 100644 --- a/packages/web/components/common/MyTooltip/index.tsx +++ b/packages/web/components/common/MyTooltip/index.tsx @@ -17,7 +17,7 @@ const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ... })} > {typeof item.title === 'string' ? t(item.title) : item.title} diff --git a/packages/web/components/common/Tabs/RowTabs.tsx b/packages/web/components/common/Tabs/RowTabs.tsx index 9246836d7..846387000 100644 --- a/packages/web/components/common/Tabs/RowTabs.tsx +++ b/packages/web/components/common/Tabs/RowTabs.tsx @@ -23,6 +23,7 @@ const RowTabs = ({ list, value, onChange, py = '7px', px = '12px', ...props }: P borderColor={'borderColor.base'} bg={'myGray.50'} gap={'4px'} + fontSize={'sm'} {...props} > {list.map((item) => ( diff --git a/packages/web/components/common/Tag/index.tsx b/packages/web/components/common/Tag/index.tsx index bb22d79b9..b8fa9a18a 100644 --- a/packages/web/components/common/Tag/index.tsx +++ b/packages/web/components/common/Tag/index.tsx @@ -1,69 +1,78 @@ import React, { useMemo } from 'react'; import { Flex, type FlexProps } from '@chakra-ui/react'; +type ColorSchemaType = 'blue' | 'green' | 'red' | 'yellow' | 'gray' | 'purple' | 'adora'; + interface Props extends FlexProps { children: React.ReactNode | React.ReactNode[]; - colorSchema?: 'blue' | 'green' | 'gray' | 'purple'; - type?: 'fill' | 'solid'; + colorSchema?: ColorSchemaType; + type?: 'fill' | 'borderFill' | 'borderSolid'; } +const colorMap: Record< + ColorSchemaType, + { + borderColor: string; + bg: string; + color: string; + } +> = { + yellow: { + borderColor: 'yellow.200', + bg: 'yellow.50', + color: 'yellow.600' + }, + green: { + borderColor: 'green.200', + bg: 'green.50', + color: 'green.600' + }, + red: { + borderColor: 'red.200', + bg: 'red.50', + color: 'red.600' + }, + gray: { + borderColor: 'myGray.200', + bg: 'myGray.50', + color: 'myGray.700' + }, + blue: { + borderColor: 'primary.200', + bg: 'primary.50', + color: 'primary.600' + }, + purple: { + borderColor: '#ECF', + bg: '#F6EEFA', + color: '#A558C9' + }, + adora: { + borderColor: '#D3CAFF', + bg: '#F0EEFF', + color: '#6F5DD7' + } +}; + const MyTag = ({ children, colorSchema = 'blue', type = 'fill', ...props }: Props) => { const theme = useMemo(() => { - const fillMap = { - blue: { - borderColor: 'primary.200', - bg: 'primary.50', - color: 'primary.700' - }, - green: { - borderColor: 'green.200', - bg: 'green.50', - color: 'green.600' - }, - purple: { - borderColor: '#ECF', - bg: '#F6EEFA', - color: '#A558C9' - }, - gray: { - borderColor: 'myGray.200', - bg: 'myGray.50', - color: 'myGray.700' - } - }; - const solidMap = { - blue: { - borderColor: 'primary.200', - color: 'primary.600' - }, - green: { - borderColor: 'green.200', - color: 'green.600' - }, - purple: { - borderColor: '#ECF', - color: '#9E53C1' - }, - gray: { - borderColor: 'myGray.200', - color: 'myGray.700' - } - }; - return type === 'fill' ? fillMap[colorSchema] : solidMap[colorSchema]; + return colorMap[colorSchema]; }, [colorSchema]); return ( {children} diff --git a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx index be8bcfe44..6203c3fea 100644 --- a/packages/web/components/common/Textarea/PromptEditor/Editor.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/Editor.tsx @@ -105,7 +105,7 @@ export default function Editor({ > {renderTypeData.title} } - menuList={filterMenuList} + menuList={[{ children: filterMenuList }]} /> ); }; diff --git a/packages/web/hooks/useScrollPagination.tsx b/packages/web/hooks/useScrollPagination.tsx index 40de950ef..78eaeb75f 100644 --- a/packages/web/hooks/useScrollPagination.tsx +++ b/packages/web/hooks/useScrollPagination.tsx @@ -115,7 +115,7 @@ export function useScrollPagination< {children} {noMore.current && list.length > 0 && ( - + {t('common.No more data')} )} diff --git a/packages/web/hooks/useToast.ts b/packages/web/hooks/useToast.tsx similarity index 90% rename from packages/web/hooks/useToast.ts rename to packages/web/hooks/useToast.tsx index 734563578..533cd4a8b 100644 --- a/packages/web/hooks/useToast.ts +++ b/packages/web/hooks/useToast.tsx @@ -5,6 +5,9 @@ export const useToast = (props?: UseToastOptions) => { const toast = uToast({ position: 'top', duration: 2000, + containerStyle: { + fontSize: 'sm' + }, ...props }); diff --git a/packages/web/styles/theme.ts b/packages/web/styles/theme.ts index 8748f64d2..be514200a 100644 --- a/packages/web/styles/theme.ts +++ b/packages/web/styles/theme.ts @@ -4,13 +4,14 @@ import { switchAnatomy, selectAnatomy, numberInputAnatomy, - checkboxAnatomy + checkboxAnatomy, + tableAnatomy, + radioAnatomy } from '@chakra-ui/anatomy'; import { createMultiStyleConfigHelpers, defineStyle } from '@chakra-ui/styled-system'; -const { definePartsStyle, defineMultiStyleConfig } = createMultiStyleConfigHelpers( - modalAnatomy.keys -); +const { definePartsStyle: modalPart, defineMultiStyleConfig: modalMultiStyle } = + createMultiStyleConfigHelpers(modalAnatomy.keys); const { definePartsStyle: switchPart, defineMultiStyleConfig: switchMultiStyle } = createMultiStyleConfigHelpers(switchAnatomy.keys); const { definePartsStyle: selectPart, defineMultiStyleConfig: selectMultiStyle } = @@ -19,6 +20,10 @@ const { definePartsStyle: numInputPart, defineMultiStyleConfig: numInputMultiSty createMultiStyleConfigHelpers(numberInputAnatomy.keys); const { definePartsStyle: checkBoxPart, defineMultiStyleConfig: checkBoxMultiStyle } = createMultiStyleConfigHelpers(checkboxAnatomy.keys); +const { definePartsStyle: tablePart, defineMultiStyleConfig: tableMultiStyle } = + createMultiStyleConfigHelpers(tableAnatomy.keys); +const { definePartsStyle: radioParts, defineMultiStyleConfig: radioStyle } = + createMultiStyleConfigHelpers(radioAnatomy.keys); const shadowLight = '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)'; @@ -65,7 +70,7 @@ const Button = defineStyleConfig({ borderRadius: '8px' }, md: { - fontSize: 'md', + fontSize: 'sm', px: '20px', py: 0, h: '36px', @@ -73,7 +78,7 @@ const Button = defineStyleConfig({ borderRadius: '8px' }, mdSquare: { - fontSize: 'md', + fontSize: 'sm', px: '0', py: 0, h: '36px', @@ -267,9 +272,6 @@ const Button = defineStyleConfig({ }); const Input: ComponentStyleConfig = { - baseStyle: { - fontsize: '1rem' - }, sizes: { sm: defineStyle({ field: { @@ -312,13 +314,15 @@ const NumberInput = numInputMultiStyle({ sm: defineStyle({ field: { h: '32px', - borderRadius: 'md' + borderRadius: 'md', + fontsize: 'sm' } }), md: defineStyle({ field: { h: '40px', - borderRadius: 'md' + borderRadius: 'md', + fontsize: 'sm' } }) }, @@ -359,6 +363,7 @@ const Textarea: ComponentStyleConfig = { border: '1px solid', borderRadius: 'md', borderColor: 'myGray.200', + fontSize: 'sm', _hover: { borderColor: '' }, @@ -406,12 +411,34 @@ const Select = selectMultiStyle({ } }); +const Radio = radioStyle({ + baseStyle: radioParts({ + control: { + _hover: { + borderColor: 'primary.300', + bg: 'primary.50' + }, + _checked: { + borderColor: 'primary.600', + bg: 'primary.50', + boxShadow: shadowLight, + _before: { + bg: 'primary.600' + }, + _hover: { + bg: 'primary.50' + } + } + } + }) +}); const Checkbox = checkBoxMultiStyle({ baseStyle: checkBoxPart({ label: { fontFamily: 'mono' // change the font family of the label }, control: { + borderRadius: 'xs', bg: 'none', _checked: { bg: 'primary.50', @@ -429,10 +456,10 @@ const Checkbox = checkBoxMultiStyle({ }) }); -const Modal = defineMultiStyleConfig({ - baseStyle: definePartsStyle({ +const Modal = modalMultiStyle({ + baseStyle: modalPart({ body: { - py: [3, 5], + py: [2, 4], px: [5, 7] }, footer: { @@ -441,20 +468,62 @@ const Modal = defineMultiStyleConfig({ }) }); +const Table = tableMultiStyle({ + sizes: { + md: defineStyle({ + table: { + fontsize: 'sm' + }, + thead: { + tr: { + bg: 'myGray.100', + fontSize: 'sm', + th: { + borderBottom: 'none', + overflow: 'hidden', + '&:first-of-type': { + borderLeftRadius: 'md' + }, + '&:last-of-type': { + borderRightRadius: 'md' + } + } + } + }, + tbody: { + tr: { + td: { + overflow: 'hidden', + '&:first-of-type': { + borderLeftRadius: 'md' + }, + '&:last-of-type': { + borderRightRadius: 'md' + } + } + } + } + }) + }, + defaultProps: { + size: 'md' + } +}); + // 全局主题 export const theme = extendTheme({ styles: { global: { 'html, body': { - fontSize: '14px', - color: 'myGray.900', - fontWeight: 400, + color: 'myGray.600', + fontWeight: 'normal', height: '100%', overflow: 'hidden' }, a: { color: 'primary.600' }, + '*': { _focusVisible: { boxShadow: 'none' @@ -586,16 +655,17 @@ export const theme = extendTheme({ body: 'PingFang,Noto Sans,-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"' }, fontSizes: { + mini: '0.75rem', xs: '0.8rem', - sm: '0.93rem', + sm: '0.875rem', md: '1rem', - lg: '1.15rem', - xl: '1.3rem', - '2xl': '1.45rem', - '3xl': '1.6rem', - '4xl': '1.75rem', - '5xl': '1.9rem', - '6xl': '2.05rem' + lg: '1.25rem', + xl: '1.5rem', + '2xl': '1.75rem', + '3xl': '2rem', + '4xl': '2.25rem', + '5xl': '2.8rem', + '6xl': '3.6rem' }, borders: { sm: '1px solid #E8EBF0', @@ -644,6 +714,8 @@ export const theme = extendTheme({ Select, NumberInput, Checkbox, - Modal + Modal, + Table, + Radio } }); diff --git a/projects/app/i18n/zh/common.json b/projects/app/i18n/zh/common.json index 02e211a7a..60301e8c8 100644 --- a/projects/app/i18n/zh/common.json +++ b/projects/app/i18n/zh/common.json @@ -532,6 +532,7 @@ "Go Dataset": "前往知识库", "Intro Placeholder": "这个知识库还没有介绍~", "Manual collection": "手动数据集", + "externalFile": "外部文件库", "My Dataset": "我的知识库", "Name": "知识库名称", "Query extension intro": "开启问题优化功能,可以提高提高连续对话时,知识库搜索的精度。开启该功能后,在进行知识库搜索时,会根据对话记录,利用 AI 补全问题缺失的信息。", @@ -585,8 +586,7 @@ "success": "开始同步" } }, - "training": { - } + "training": {} }, "data": { "Auxiliary Data": "辅助数据", diff --git a/projects/app/src/components/ChatBox/Input/ChatInput.tsx b/projects/app/src/components/ChatBox/Input/ChatInput.tsx index 35166c147..190b5a535 100644 --- a/projects/app/src/components/ChatBox/Input/ChatInput.tsx +++ b/projects/app/src/components/ChatBox/Input/ChatInput.tsx @@ -3,7 +3,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import { Box, Flex, Image, Spinner, Textarea } from '@chakra-ui/react'; import React, { useRef, useEffect, useCallback } from 'react'; import { useTranslation } from 'next-i18next'; -import MyTooltip from '../../MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useSelectFile } from '@/web/common/file/hooks/useSelectFile'; import { compressImgFileAndUpload } from '@/web/common/file/controller'; diff --git a/projects/app/src/components/ChatBox/components/ResponseTags.tsx b/projects/app/src/components/ChatBox/components/ResponseTags.tsx index b695a9216..71594c5b9 100644 --- a/projects/app/src/components/ChatBox/components/ResponseTags.tsx +++ b/projects/app/src/components/ChatBox/components/ResponseTags.tsx @@ -7,7 +7,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type'; import dynamic from 'next/dynamic'; import MyTag from '@fastgpt/web/components/common/Tag/index'; -import MyTooltip from '../../MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant'; import { getSourceNameIcon } from '@fastgpt/global/core/dataset/utils'; import ChatBoxDivider from '@/components/core/chat/Divider'; @@ -108,9 +108,9 @@ const ResponseTags = ({ setQuoteModalData({ rawSearch: quoteList })} > @@ -164,7 +164,7 @@ const ResponseTags = ({ setContextModalData(historyPreview)} > {historyPreview.length}条上下文 @@ -174,20 +174,25 @@ const ResponseTags = ({ )} {llmModuleAccount > 1 && ( - + 多组 AI 对话 )} {isPc && runningTime > 0 && ( - + {runningTime}s )} - + {t('core.chat.response.Read complete response')} diff --git a/projects/app/src/components/ChatBox/components/SelectMarkCollection.tsx b/projects/app/src/components/ChatBox/components/SelectMarkCollection.tsx index 46166eeb8..bcc4255b5 100644 --- a/projects/app/src/components/ChatBox/components/SelectMarkCollection.tsx +++ b/projects/app/src/components/ChatBox/components/SelectMarkCollection.tsx @@ -8,6 +8,7 @@ import DatasetSelectModal, { useDatasetSelect } from '@/components/core/dataset/ import dynamic from 'next/dynamic'; import { AdminFbkType } from '@fastgpt/global/core/chat/type.d'; import SelectCollections from '@/web/core/dataset/components/SelectCollections'; +import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; const InputDataModal = dynamic(() => import('@/pages/dataset/detail/components/InputDataModal')); @@ -76,7 +77,7 @@ const SelectMarkCollection = ({ > - + {item.name} @@ -89,14 +90,7 @@ const SelectMarkCollection = ({ })() )} - {datasets.length === 0 && ( - - - - 这个目录已经没东西可选了~ - - - )} + {datasets.length === 0 && } )} diff --git a/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx b/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx index dbb7dcd06..ee4a7fc98 100644 --- a/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx +++ b/projects/app/src/components/ChatBox/components/WholeResponseModal.tsx @@ -6,13 +6,13 @@ import { moduleTemplatesFlat } from '@fastgpt/global/core/workflow/template/cons import Tabs from '../../Tabs'; import MyModal from '@fastgpt/web/components/common/MyModal'; -import MyTooltip from '../../MyTooltip'; -import { QuestionOutlineIcon } from '@chakra-ui/icons'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import Markdown from '../../Markdown'; import { QuoteList } from './QuoteModal'; import { DatasetSearchModeMap } from '@fastgpt/global/core/dataset/constants'; import { formatNumber } from '@fastgpt/global/common/math/tools'; import { useI18n } from '@/web/context/I18n'; +import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; function RowRender({ children, @@ -22,10 +22,10 @@ function RowRender({ }: { children: React.ReactNode; label: string } & BoxProps) { return ( - + {label}: - + {children} @@ -98,9 +98,7 @@ const WholeResponseModal = ({ title={ {t('core.chat.response.Complete Response')} - - - + } > diff --git a/projects/app/src/components/ChatBox/index.tsx b/projects/app/src/components/ChatBox/index.tsx index fc1e568c8..f0a81df81 100644 --- a/projects/app/src/components/ChatBox/index.tsx +++ b/projects/app/src/components/ChatBox/index.tsx @@ -32,7 +32,7 @@ import { } from '@/web/core/chat/api'; import type { AdminMarkType } from './components/SelectMarkCollection'; -import MyTooltip from '../MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { postQuestionGuide } from '@/web/core/ai/api'; import type { diff --git a/projects/app/src/components/Layout/navbar.tsx b/projects/app/src/components/Layout/navbar.tsx index aed0aff0c..6ea1cda7f 100644 --- a/projects/app/src/components/Layout/navbar.tsx +++ b/projects/app/src/components/Layout/navbar.tsx @@ -10,7 +10,7 @@ import Avatar from '../Avatar'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { useSystemStore } from '@/web/common/system/useSystemStore'; -import MyTooltip from '../MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { getDocPath } from '@/web/common/system/doc'; export enum NavbarTypeEnum { diff --git a/projects/app/src/components/Markdown/chat/QuestionGuide.tsx b/projects/app/src/components/Markdown/chat/QuestionGuide.tsx index a955048d2..91b0c8b58 100644 --- a/projects/app/src/components/Markdown/chat/QuestionGuide.tsx +++ b/projects/app/src/components/Markdown/chat/QuestionGuide.tsx @@ -4,7 +4,7 @@ import 'katex/dist/katex.min.css'; import ChatBoxDivider from '@/components/core/chat/Divider'; import { useTranslation } from 'next-i18next'; import { EventNameEnum, eventBus } from '@/web/common/utils/eventbus'; -import MyTooltip from '@/components/MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyIcon from '@fastgpt/web/components/common/Icon'; const QuestionGuide = ({ text }: { text: string }) => { @@ -31,7 +31,7 @@ const QuestionGuide = ({ text }: { text: string }) => { key={text} alignItems={'center'} flexWrap={'wrap'} - fontSize={'sm'} + fontSize={'xs'} border={theme.borders.sm} py={'1px'} px={3} diff --git a/projects/app/src/components/Markdown/index.module.scss b/projects/app/src/components/Markdown/index.module.scss index 684e63fde..298b34ce5 100644 --- a/projects/app/src/components/Markdown/index.module.scss +++ b/projects/app/src/components/Markdown/index.module.scss @@ -105,16 +105,16 @@ font-size: inherit; } .markdown h1 { - font-size: 28px; + font-size: var(--chakra-fontSizes-2xl); } .markdown h2 { - font-size: 24px; + font-size: var(--chakra-fontSizes-xl); } .markdown h3 { - font-size: 18px; + font-size: var(--chakra-fontSizes-lg); } .markdown h4 { - font-size: 16px; + font-size: var(--chakra-fontSizes-md); } .markdown h5 { font-size: 14px; @@ -346,6 +346,7 @@ tab-size: 4; word-spacing: normal; width: 100%; + font-size: var(--chakra-fontSizes-sm); * { word-break: break-word; diff --git a/projects/app/src/components/Markdown/index.tsx b/projects/app/src/components/Markdown/index.tsx index 7f809755b..9052a4e5d 100644 --- a/projects/app/src/components/Markdown/index.tsx +++ b/projects/app/src/components/Markdown/index.tsx @@ -10,7 +10,7 @@ import styles from './index.module.scss'; import dynamic from 'next/dynamic'; import { Link, Button } from '@chakra-ui/react'; -import MyTooltip from '../MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { useTranslation } from 'next-i18next'; import { EventNameEnum, eventBus } from '@/web/common/utils/eventbus'; import MyIcon from '@fastgpt/web/components/common/Icon'; diff --git a/projects/app/src/components/MyTooltip/index.tsx b/projects/app/src/components/MyTooltip/index.tsx deleted file mode 100644 index 8c25d9216..000000000 --- a/projects/app/src/components/MyTooltip/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { Tooltip, TooltipProps } from '@chakra-ui/react'; -import { useSystemStore } from '@/web/common/system/useSystemStore'; - -interface Props extends TooltipProps { - forceShow?: boolean; -} - -const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ...props }: Props) => { - const { isPc } = useSystemStore(); - return isPc || forceShow ? ( - - {children} - - ) : ( - <>{children} - ); -}; - -export default MyTooltip; diff --git a/projects/app/src/components/PromptTemplate/index.tsx b/projects/app/src/components/PromptTemplate/index.tsx index 46e38b14f..3a3bd352f 100644 --- a/projects/app/src/components/PromptTemplate/index.tsx +++ b/projects/app/src/components/PromptTemplate/index.tsx @@ -37,9 +37,9 @@ const PromptTemplate = ({ : {})} onClick={() => setSelectTemplateTitle(item)} > - {item.title} + {item.title} - + {item.desc} diff --git a/projects/app/src/components/SideTabs/index.tsx b/projects/app/src/components/SideTabs/index.tsx index 5209c8aeb..ffb7d4628 100644 --- a/projects/app/src/components/SideTabs/index.tsx +++ b/projects/app/src/components/SideTabs/index.tsx @@ -17,17 +17,17 @@ const SideTabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => switch (size) { case 'sm': return { - fontSize: 'sm', + fontSize: 'xs', inlineP: 1 }; case 'md': return { - fontSize: 'md', + fontSize: 'sm', inlineP: 2 }; case 'lg': return { - fontSize: 'lg', + fontSize: 'md', inlineP: 3 }; } @@ -55,7 +55,8 @@ const SideTabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => color: 'myGray.600' })} _hover={{ - bg: 'myGray.05' + color: 'primary.600', + bg: 'myGray.100' }} onClick={() => { if (activeId === item.id) return; diff --git a/projects/app/src/components/Slider/index.tsx b/projects/app/src/components/Slider/index.tsx index fd53180b0..20b7ab97e 100644 --- a/projects/app/src/components/Slider/index.tsx +++ b/projects/app/src/components/Slider/index.tsx @@ -47,7 +47,6 @@ const MySlider = ({ max={max} min={min} step={step} - size={'lg'} value={value} width={width} onChange={onChange} diff --git a/projects/app/src/components/Tabs/index.tsx b/projects/app/src/components/Tabs/index.tsx index 0e03550d7..40a57cfdb 100644 --- a/projects/app/src/components/Tabs/index.tsx +++ b/projects/app/src/components/Tabs/index.tsx @@ -18,19 +18,19 @@ const Tabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => { switch (size) { case 'sm': return { - fontSize: 'sm', + fontSize: 'xs', outP: '3px', inlineP: 1 }; case 'md': return { - fontSize: ['sm', 'md'], + fontSize: 'sm', outP: '4px', inlineP: 1 }; case 'lg': return { - fontSize: ['md', 'lg'], + fontSize: ['sm', 'md'], outP: '5px', inlineP: 2 }; diff --git a/projects/app/src/components/common/MyRadio/index.tsx b/projects/app/src/components/common/MyRadio/index.tsx index 18d8ce447..207bdc8a4 100644 --- a/projects/app/src/components/common/MyRadio/index.tsx +++ b/projects/app/src/components/common/MyRadio/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Box, Flex, useTheme, Grid, type GridProps, theme, Image } from '@chakra-ui/react'; +import { Box, Flex, useTheme, Grid, type GridProps, theme, Image, Radio } from '@chakra-ui/react'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { useToast } from '@fastgpt/web/hooks/useToast'; @@ -36,7 +36,7 @@ const MyRadio = ({ const { toast } = useToast(); return ( - + {list.map((item) => ( { if (item.forbidTip) { toast({ @@ -103,14 +81,17 @@ const MyRadio = ({ )} )} - - {typeof item.title === 'string' ? t(item.title) : item.title} + + + {typeof item.title === 'string' ? t(item.title) : item.title} + {!!item.desc && ( - + {t(item.desc)} )} + ))} diff --git a/projects/app/src/components/common/ParentPaths/index.tsx b/projects/app/src/components/common/ParentPaths/index.tsx index b18d24ee4..31b4fe137 100644 --- a/projects/app/src/components/common/ParentPaths/index.tsx +++ b/projects/app/src/components/common/ParentPaths/index.tsx @@ -37,7 +37,7 @@ const ParentPaths = (props: { {concatPaths.map((item, i) => ( {item.icon && } - {item.label} + {item.label} ))} diff --git a/projects/app/src/components/common/Textarea/MyTextarea/index.tsx b/projects/app/src/components/common/Textarea/MyTextarea/index.tsx index 5553c55dd..0566b8d8c 100644 --- a/projects/app/src/components/common/Textarea/MyTextarea/index.tsx +++ b/projects/app/src/components/common/Textarea/MyTextarea/index.tsx @@ -9,7 +9,7 @@ import { TextareaProps, useDisclosure } from '@chakra-ui/react'; -import MyTooltip from '@/components/MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyModal from '@fastgpt/web/components/common/MyModal'; diff --git a/projects/app/src/components/core/ai/AISettingModal/index.tsx b/projects/app/src/components/core/ai/AISettingModal/index.tsx index a31a95874..709e3e3f2 100644 --- a/projects/app/src/components/core/ai/AISettingModal/index.tsx +++ b/projects/app/src/components/core/ai/AISettingModal/index.tsx @@ -19,8 +19,6 @@ import type { SettingAIDataType } from '@fastgpt/global/core/app/type.d'; import { getDocPath } from '@/web/common/system/doc'; import AIModelSelector from '@/components/Select/AIModelSelector'; import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; -import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; -import { QuestionOutlineIcon } from '@chakra-ui/icons'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; const AIChatSettingsModal = ({ @@ -65,7 +63,8 @@ const AIChatSettingsModal = ({ const LabelStyles: BoxProps = { display: 'flex', alignItems: 'center', - fontSize: ['sm', 'md'], + fontSize: 'sm', + color: 'myGray.900', width: ['80px', '90px'] }; @@ -209,14 +208,14 @@ const AIChatSettingsModal = ({ {t('core.app.Ai response')} - - - + { const value = e.target.checked; setValue(NodeInputKeyEnum.aiChatIsResponseText, value); diff --git a/projects/app/src/components/core/app/DatasetParamsModal.tsx b/projects/app/src/components/core/app/DatasetParamsModal.tsx index 25ec5655e..2326b6bcd 100644 --- a/projects/app/src/components/core/app/DatasetParamsModal.tsx +++ b/projects/app/src/components/core/app/DatasetParamsModal.tsx @@ -12,9 +12,8 @@ import { useTheme } from '@chakra-ui/react'; import { useForm } from 'react-hook-form'; -import { QuestionOutlineIcon } from '@chakra-ui/icons'; import MySlider from '@/components/Slider'; -import MyTooltip from '@/components/MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import MyModal from '@fastgpt/web/components/common/MyModal'; import { DatasetSearchModeEnum } from '@fastgpt/global/core/dataset/constants'; import { useTranslation } from 'next-i18next'; @@ -29,6 +28,8 @@ import PromptEditor from '@fastgpt/web/components/common/Textarea/PromptEditor'; import { useUserStore } from '@/web/support/user/useUserStore'; import { useToast } from '@fastgpt/web/hooks/useToast'; import SelectAiModel from '@/components/Select/AIModelSelector'; +import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; +import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; export type DatasetParamsProps = { searchMode: `${DatasetSearchModeEnum}`; @@ -158,8 +159,7 @@ const DatasetParamsModal = ({ cursor={'pointer'} userSelect={'none'} py={3} - pl={'14px'} - pr={'16px'} + px={4} border={theme.borders.sm} borderWidth={'1.5px'} borderRadius={'md'} @@ -191,8 +191,8 @@ const DatasetParamsModal = ({ > - {t('core.dataset.search.ReRank')} - + {t('core.dataset.search.ReRank')} + {t('core.dataset.search.ReRank desc')} @@ -208,12 +208,13 @@ const DatasetParamsModal = ({ {limit !== undefined && ( - - {t('core.dataset.search.Max Tokens')} - - - - + + {t('core.dataset.search.Max Tokens')} + + )} - - {t('core.dataset.search.Min Similarity')} - - - - + + {t('core.dataset.search.Min Similarity')} + + {showSimilarity ? ( - + {t('core.dataset.Query extension intro')} @@ -274,8 +276,8 @@ const DatasetParamsModal = ({ {datasetSearchUsingCfrForm === true && ( <> - {t('core.ai.Model')} - + {t('core.ai.Model')} + - {t('core.app.edit.Query extension background prompt')} - - - + {t('core.app.edit.Query extension background prompt')} + {item.name} diff --git a/projects/app/src/components/core/app/InputGuideConfig.tsx b/projects/app/src/components/core/app/InputGuideConfig.tsx index b84ba7e99..a0b1b10cf 100644 --- a/projects/app/src/components/core/app/InputGuideConfig.tsx +++ b/projects/app/src/components/core/app/InputGuideConfig.tsx @@ -1,5 +1,5 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; -import MyTooltip from '@/components/MyTooltip'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { Box, Button, @@ -34,10 +34,10 @@ import { useToast } from '@fastgpt/web/hooks/useToast'; import { useSelectFile } from '@/web/common/file/hooks/useSelectFile'; import { readCsvRawText } from '@fastgpt/web/common/file/utils'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; -import { useRequest } from 'ahooks'; import HighlightText from '@fastgpt/web/components/common/String/HighlightText'; import { defaultChatInputGuideConfig } from '@fastgpt/global/core/app/constants'; import ChatFunctionTip from './Tip'; +import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; const csvTemplate = `"第一列内容" "只会将第一列内容导入,其余列会被忽略" @@ -85,10 +85,10 @@ const InputGuideConfig = ({ return ( - - {chatT('Input guide')} + + {chatT('Input guide')} - +