From 13e3f17493cd8f23a0d32d40ca46f5ef8b3b22f3 Mon Sep 17 00:00:00 2001 From: twwu Date: Mon, 26 May 2025 10:50:39 +0800 Subject: [PATCH] refactor: standardize terminology by renaming 'data-source' to 'datasource' across components and translations --- .../components/panel/test-run/index.tsx | 32 +++++++++++++------ .../components/workflow/nodes/_base/node.tsx | 2 +- web/app/components/workflow/types.ts | 4 +-- web/i18n/en-US/workflow.ts | 4 +-- web/i18n/zh-Hans/workflow.ts | 4 +-- web/service/use-pipeline.ts | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) 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 0f8cc46ab6..48353ec9d2 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 @@ -96,32 +96,44 @@ const TestRunPanel = () => { const handleProcess = useCallback((data: Record) => { if (!datasource) return - const datasourceInfo: Record = {} + const datasourceInfoList: Record[] = [] let datasource_type = '' if (datasource.type === DataSourceType.FILE) { datasource_type = 'local_file' - datasourceInfo.fileId = fileList.map(file => file.fileID) + const documentInfo = { + upload_file_id: fileList[0].file.id, + name: fileList[0].file.name, + type: fileList[0].file.type, + size: fileList[0].file.size, + extension: fileList[0].file.extension, + mime_type: fileList[0].file.mime_type, + } + datasourceInfoList.push(documentInfo) } if (datasource.type === DataSourceType.NOTION) { datasource_type = 'online_document' - datasourceInfo.workspaceId = notionPages[0].workspace_id - datasourceInfo.page = notionPages.map((page) => { - const { workspace_id, ...rest } = page - return rest - }) + const { workspace_id, ...rest } = notionPages[0] + const documentInfo = { + workspace_id, + page: rest, + } + datasourceInfoList.push(documentInfo) } if (datasource.type === DataSourceProvider.fireCrawl || datasource.type === DataSourceProvider.jinaReader || datasource.type === DataSourceProvider.waterCrawl) { datasource_type = 'website_crawl' - datasourceInfo.jobId = websiteCrawlJobId - datasourceInfo.result = websitePages + const documentInfo = { + job_id: websiteCrawlJobId, + result: websitePages[0], + } + datasourceInfoList.push(documentInfo) } handleRun({ inputs: data, start_node_id: datasource.nodeId, datasource_type, - datasource_info: datasourceInfo, + datasource_info_list: datasourceInfoList, }) }, [datasource, fileList, handleRun, notionPages, websiteCrawlJobId, websitePages]) diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx index 81e7e29e96..dba43ecb8f 100644 --- a/web/app/components/workflow/nodes/_base/node.tsx +++ b/web/app/components/workflow/nodes/_base/node.tsx @@ -146,7 +146,7 @@ const BaseNode: FC = ({ data.type === BlockEnum.DataSource && (
- {t('workflow.blocks.data-source')} + {t('workflow.blocks.datasource')}
) diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index cfe98c6f2a..cf3a55f895 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -45,7 +45,7 @@ export enum BlockEnum { Loop = 'loop', LoopStart = 'loop-start', LoopEnd = 'loop-end', - DataSource = 'data-source', + DataSource = 'datasource', KnowledgeBase = 'knowledge-index', } @@ -99,7 +99,7 @@ export type CommonNodeType = { retry_config?: WorkflowRetryConfig default_value?: DefaultValueForm[] } & T & Partial> -& Partial> + & Partial> export type CommonEdgeType = { _hovering?: boolean diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index d230f90dc1..6bb4ba07fe 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -256,7 +256,7 @@ const translation = { 'loop': 'Loop', 'loop-end': 'Exit Loop', 'knowledge-index': 'Knowledge Base', - 'data-source': 'Data Source', + 'datasource': 'Data Source', }, blocksAbout: { 'start': 'Define the initial parameters for launching a workflow', @@ -280,7 +280,7 @@ const translation = { 'list-operator': 'Used to filter or sort array content.', 'agent': 'Invoking large language models to answer questions or process natural language', 'knowledge-index': 'Knowledge Base About', - 'data-source': 'Data Source About', + 'datasource': 'Data Source About', }, operator: { zoomIn: 'Zoom In', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 667dd4bf62..34d5d91cd6 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -257,7 +257,7 @@ const translation = { 'loop': '循环', 'loop-end': '退出循环', 'knowledge-index': '知识库', - 'data-source': '数据源', + 'datasource': '数据源', }, blocksAbout: { 'start': '定义一个 workflow 流程启动的初始参数', @@ -281,7 +281,7 @@ const translation = { 'list-operator': '用于过滤或排序数组内容。', 'agent': '调用大型语言模型回答问题或处理自然语言', 'knowledge-index': '知识库节点', - 'data-source': '数据源节点', + 'datasource': '数据源节点', }, operator: { zoomIn: '放大', diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index 4f5b4383e4..9ab0697337 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -164,7 +164,7 @@ export const usePublishedPipelineProcessingParams = (params: PipelineProcessingP export const useDataSourceList = (enabled: boolean, onSuccess: (v: ToolWithProvider[]) => void) => { return useQuery({ enabled, - queryKey: [NAME_SPACE, 'data-source'], + queryKey: [NAME_SPACE, 'datasource'], queryFn: async () => { const data = await get('/rag/pipelines/datasource-plugins') onSuccess(data)