diff --git a/docSite/content/zh-cn/docs/development/upgrading/4813.md b/docSite/content/zh-cn/docs/development/upgrading/4813.md index 9855eadc8d84..198e38abac84 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4813.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4813.md @@ -39,6 +39,7 @@ weight: 811 14. 优化 - Markdown 组件自动空格,避免分割 url 中的中文。 15. 优化 - 工作流上下文拆分,性能优化。 16. 优化 - 语音播报,不支持 mediaSource 的浏览器可等待完全生成语音后输出。 -17. 修复 - Dockerfile pnpm install 支持代理。 -18. 修复 - BI 图表生成无法写入文件。同时优化其解析,支持数字类型数组。 -19. 修复 - 分享链接首次加载时,标题显示不正确。 +17. 优化 - 对话引导 csv 读取,自动识别编码。 +18. 修复 - Dockerfile pnpm install 支持代理。 +19. 修复 - BI 图表生成无法写入文件。同时优化其解析,支持数字类型数组。 +20. 修复 - 分享链接首次加载时,标题显示不正确。 diff --git a/packages/global/common/file/constants.ts b/packages/global/common/file/constants.ts index 4be4bab2211f..aa8e842174b4 100644 --- a/packages/global/common/file/constants.ts +++ b/packages/global/common/file/constants.ts @@ -16,7 +16,7 @@ export const bucketNameMap = { } }; -export const ReadFileBaseUrl = `${process.env.FE_DOMAIN || ''}${process.env.NEXT_PUBLIC_BASE_URL}/api/common/file/read`; +export const ReadFileBaseUrl = `${process.env.FE_DOMAIN || ''}${process.env.NEXT_PUBLIC_BASE_URL || ''}/api/common/file/read`; export const documentFileType = '.txt, .docx, .csv, .xlsx, .pdf, .md, .html, .pptx'; export const imageFileType = diff --git a/packages/global/core/workflow/template/system/datasetSearch.ts b/packages/global/core/workflow/template/system/datasetSearch.ts index 476d10287a13..69e15a679843 100644 --- a/packages/global/core/workflow/template/system/datasetSearch.ts +++ b/packages/global/core/workflow/template/system/datasetSearch.ts @@ -95,10 +95,10 @@ export const DatasetSearchModule: FlowNodeTemplateType = { }, { key: NodeInputKeyEnum.collectionFilterMatch, - renderTypeList: [FlowNodeInputTypeEnum.JSONEditor, FlowNodeInputTypeEnum.reference], + renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference], label: i18nT('workflow:collection_metadata_filter'), - valueType: WorkflowIOValueTypeEnum.object, + valueType: WorkflowIOValueTypeEnum.string, isPro: true, description: i18nT('workflow:filter_description') } diff --git a/packages/service/core/dataset/search/controller.ts b/packages/service/core/dataset/search/controller.ts index c5368726cff2..0667a2b1e7c2 100644 --- a/packages/service/core/dataset/search/controller.ts +++ b/packages/service/core/dataset/search/controller.ts @@ -118,7 +118,10 @@ export async function searchDatasetData(props: SearchDatasetDataProps) { let createTimeCollectionIdList: string[] | undefined = undefined; try { - const jsonMatch = json5.parse(collectionFilterMatch); + const jsonMatch = + typeof collectionFilterMatch === 'object' + ? collectionFilterMatch + : json5.parse(collectionFilterMatch); // Tag let andTags = jsonMatch?.tags?.$and as (string | null)[] | undefined; @@ -347,7 +350,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) { teamId: new Types.ObjectId(teamId), datasetId: new Types.ObjectId(id), $text: { $search: jiebaSplit({ text: query }) }, - ...(filterCollectionIdList && filterCollectionIdList.length > 0 + ...(filterCollectionIdList ? { collectionId: { $in: filterCollectionIdList.map((id) => new Types.ObjectId(id)) diff --git a/packages/service/core/workflow/dispatch/dataset/search.ts b/packages/service/core/workflow/dispatch/dataset/search.ts index 2691a487bf9f..213aa473cccc 100644 --- a/packages/service/core/workflow/dispatch/dataset/search.ts +++ b/packages/service/core/workflow/dispatch/dataset/search.ts @@ -76,8 +76,6 @@ export async function dispatchDatasetSearch( nodeDispatchUsages: [], [DispatchNodeResponseKeyEnum.toolResponses]: [] }; - - return Promise.reject(i18nT('common:core.chat.error.User input empty')); } // query extension diff --git a/packages/web/common/file/utils.ts b/packages/web/common/file/utils.ts index 9b8a1618f17a..7fd10744530f 100644 --- a/packages/web/common/file/utils.ts +++ b/packages/web/common/file/utils.ts @@ -81,26 +81,21 @@ export const readCsvRawText = async ({ file }: { file: File }) => { return csvArr; }; -interface EncodingDetectionResult { - encoding: string | null; -} - -function detectEncoding(buffer: ArrayBuffer): EncodingDetectionResult { - const encodings = ['utf-8', 'iso-8859-1', 'windows-1252']; - for (let encoding of encodings) { - try { - const decoder = new TextDecoder(encoding, { fatal: true }); - decoder.decode(buffer); - return { encoding }; // 如果解码成功,返回当前编码 - } catch (e) { - // continue to try next encoding - } - } - return { encoding: null }; // 如果没有编码匹配,返回null -} - async function detectFileEncoding(file: File): Promise { const buffer = await loadFile2Buffer({ file }); - const { encoding } = detectEncoding(buffer); - return encoding || 'unknown'; + const encoding = (() => { + const encodings = ['utf-8', 'iso-8859-1', 'windows-1252']; + for (let encoding of encodings) { + try { + const decoder = new TextDecoder(encoding, { fatal: true }); + decoder.decode(buffer); + return encoding; // 如果解码成功,返回当前编码 + } catch (e) { + // continue to try next encoding + } + } + return null; // 如果没有编码匹配,返回null + })(); + + return encoding || 'utf-8'; } diff --git a/packages/web/components/common/MySelect/MultipleRowSelect.tsx b/packages/web/components/common/MySelect/MultipleRowSelect.tsx index 6ab2710586be..c8d335b77941 100644 --- a/packages/web/components/common/MySelect/MultipleRowSelect.tsx +++ b/packages/web/components/common/MySelect/MultipleRowSelect.tsx @@ -245,13 +245,7 @@ export const MultipleRowArraySelect = ({ onClick={() => handleSelect(item)} {...(isSelected ? { color: 'primary.600' } : {})} > - {showCheckbox && ( - } - mr={1} - /> - )} + {showCheckbox && } {item.label} ); diff --git a/packages/web/components/common/Textarea/CodeEditor/Editor.tsx b/packages/web/components/common/Textarea/CodeEditor/Editor.tsx index 4177ef89780e..bb96bdd3c7e6 100644 --- a/packages/web/components/common/Textarea/CodeEditor/Editor.tsx +++ b/packages/web/components/common/Textarea/CodeEditor/Editor.tsx @@ -14,7 +14,6 @@ type EditorVariablePickerType = { }; export type Props = Omit & { - height?: number; resize?: boolean; defaultValue?: string; value?: string; @@ -111,7 +110,7 @@ const MyEditor = ({ borderWidth={'1px'} borderRadius={'md'} borderColor={'myGray.200'} - py={2} + py={1} height={height} position={'relative'} pl={2} @@ -132,8 +131,8 @@ const MyEditor = ({ {resize && ( { iconSrc="modal/edit" title={t('common:code_editor')} w={'full'} + h={'85vh'} + isCentered > - - + +