diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts index de046868b1..3fcdde5abf 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts +++ b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts @@ -36,6 +36,7 @@ export const useDatasourceOptions = (pipelineNodes: Node[]) description: node.data.desc || '', docTitle: '', // todo: Add docTitle and docLink if needed, or remove these properties if not used docLink: '', + fileExtensions: node.data.fileExtensions || [], } }) }, [datasourceNodes]) diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx index 585ad93782..71170c019b 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx @@ -265,6 +265,7 @@ const TestRunPanel = () => { {datasource?.type === DatasourceType.localFile && ( void onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void onFileListUpdate?: (files: FileItem[]) => void @@ -29,6 +30,7 @@ type IFileUploaderProps = { const FileUploader = ({ fileList, + allowedExtensions, prepareFileList, onFileUpdate, onFileListUpdate, @@ -45,9 +47,7 @@ const FileUploader = ({ const hideUpload = notSupportBatchUpload && fileList.length > 0 const { data: fileUploadConfigResponse } = useFileUploadConfig() - const { data: supportFileTypesResponse } = useFileSupportTypes() // Todo: replace with extensions configured in node - const supportTypes = supportFileTypesResponse?.allowed_extensions || [] - const supportTypesShowNames = (() => { + const supportTypesShowNames = useMemo(() => { const extensionMap: { [key: string]: string } = { md: 'markdown', pptx: 'pptx', @@ -56,14 +56,14 @@ const FileUploader = ({ docx: 'docx', } - return [...supportTypes] + return allowedExtensions .map(item => extensionMap[item] || item) // map to standardized extension .map(item => item.toLowerCase()) // convert to lower case .filter((item, index, self) => self.indexOf(item) === index) // remove duplicates .map(item => item.toUpperCase()) // convert to upper case .join(locale !== LanguagesSupported[1] ? ', ' : '、 ') - })() - const ACCEPTS = supportTypes.map((ext: string) => `.${ext}`) + }, [locale, allowedExtensions]) + const ACCEPTS = allowedExtensions.map((ext: string) => `.${ext}`) const fileUploadConfig = useMemo(() => fileUploadConfigResponse ?? { file_size_limit: 15, batch_count_limit: 5, @@ -266,7 +266,7 @@ const FileUploader = ({ {t('datasetCreation.stepOne.uploader.button')} - {supportTypes.length > 0 && ( + {allowedExtensions.length > 0 && ( )} diff --git a/web/app/components/rag-pipeline/components/panel/test-run/data-source/local-file/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/data-source/local-file/index.tsx index 65adf409f1..1ed394a1c9 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/data-source/local-file/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/data-source/local-file/index.tsx @@ -3,6 +3,7 @@ import FileUploader from './file-uploader' type LocalFileProps = { files: FileItem[] + allowedExtensions: string[] updateFileList: (files: FileItem[]) => void updateFile: (fileItem: FileItem, progress: number, list: FileItem[]) => void onPreview?: (file: File) => void @@ -11,6 +12,7 @@ type LocalFileProps = { const LocalFile = ({ files, + allowedExtensions, updateFileList, updateFile, onPreview, @@ -19,6 +21,7 @@ const LocalFile = ({ return ( { nodeId: node.id, type: node.data.provider_type as DatasourceType, variables: node.data.variables || [], - description: node.data.desc || '', + description: '', // todo: Add description docTitle: '', // todo: Add docTitle and docLink docLink: '', + fileExtensions: node.data.fileExtensions || [], } }) }, [datasourceNodes]) diff --git a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx index bd6e9d1313..032be2da47 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx @@ -157,6 +157,7 @@ const TestRunPanel = () => { {datasource?.type === DatasourceType.localFile && (