From 0d9991ec88966982d914f429e0b779866352e56c Mon Sep 17 00:00:00 2001 From: twwu Date: Fri, 4 Jul 2025 18:04:47 +0800 Subject: [PATCH] feat: Add ONLINE_DRIVE_OUTPUT and integrate into DataSource components for online drive support --- .../workflow/nodes/data-source/constants.ts | 50 +++++++++++++++++++ .../workflow/nodes/data-source/default.ts | 7 +++ .../workflow/nodes/data-source/panel.tsx | 12 +++++ .../workflow/nodes/data-source/types.ts | 1 + 4 files changed, 70 insertions(+) diff --git a/web/app/components/workflow/nodes/data-source/constants.ts b/web/app/components/workflow/nodes/data-source/constants.ts index e18879be9e..70bc7b0fb5 100644 --- a/web/app/components/workflow/nodes/data-source/constants.ts +++ b/web/app/components/workflow/nodes/data-source/constants.ts @@ -120,3 +120,53 @@ export const ONLINE_DOCUMENT_OUTPUT = [ description: 'The content of the online document', }, ] + +export const ONLINE_DRIVE_OUTPUT = [ + { + name: 'file', + type: VarType.file, + description: 'file', + subItems: [ + { + name: 'name', + type: VarType.string, + description: '', + }, + { + name: 'size', + type: VarType.number, + description: '', + }, + { + name: 'type', + type: VarType.string, + description: '', + }, + { + name: 'extension', + type: VarType.string, + description: '', + }, + { + name: 'mime_type', + type: VarType.string, + description: '', + }, + { + name: 'transfer_method', + type: VarType.string, + description: '', + }, + { + name: 'url', + type: VarType.string, + description: '', + }, + { + name: 'related_id', + type: VarType.string, + description: '', + }, + ], + }, +] diff --git a/web/app/components/workflow/nodes/data-source/default.ts b/web/app/components/workflow/nodes/data-source/default.ts index 2319757d48..835e4a1dfa 100644 --- a/web/app/components/workflow/nodes/data-source/default.ts +++ b/web/app/components/workflow/nodes/data-source/default.ts @@ -7,6 +7,7 @@ import { COMMON_OUTPUT, LOCAL_FILE_OUTPUT, ONLINE_DOCUMENT_OUTPUT, + ONLINE_DRIVE_OUTPUT, WEBSITE_CRAWL_OUTPUT, } from './constants' import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' @@ -62,6 +63,7 @@ const nodeDefault: NodeDefault = { const isLocalFile = provider_type === DataSourceClassification.localFile const isWebsiteCrawl = provider_type === DataSourceClassification.websiteCrawl const isOnlineDocument = provider_type === DataSourceClassification.onlineDocument + const isOnlineDrive = provider_type === DataSourceClassification.onlineDrive return [ ...COMMON_OUTPUT.map(item => ({ variable: item.name, type: item.type })), ...( @@ -79,6 +81,11 @@ const nodeDefault: NodeDefault = { ? ONLINE_DOCUMENT_OUTPUT.map(item => ({ variable: item.name, type: item.type })) : [] ), + ...( + isOnlineDrive + ? ONLINE_DRIVE_OUTPUT.map(item => ({ variable: item.name, type: item.type })) + : [] + ), ...ragVars, ] }, diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx index d7de1b80a6..617640438b 100644 --- a/web/app/components/workflow/nodes/data-source/panel.tsx +++ b/web/app/components/workflow/nodes/data-source/panel.tsx @@ -22,6 +22,7 @@ import { COMMON_OUTPUT, LOCAL_FILE_OUTPUT, ONLINE_DOCUMENT_OUTPUT, + ONLINE_DRIVE_OUTPUT, WEBSITE_CRAWL_OUTPUT, } from './constants' import { useStore } from '@/app/components/workflow/store' @@ -52,6 +53,7 @@ const Panel: FC> = ({ id, data }) => { const isLocalFile = provider_type === DataSourceClassification.localFile const isWebsiteCrawl = provider_type === DataSourceClassification.websiteCrawl const isOnlineDocument = provider_type === DataSourceClassification.onlineDocument + const isOnlineDrive = provider_type === DataSourceClassification.onlineDrive const currentDataSource = dataSourceList?.find(ds => ds.plugin_id === plugin_id) const isAuthorized = !!currentDataSource?.is_authorized const [showAuthModal, { @@ -204,6 +206,16 @@ const Panel: FC> = ({ id, data }) => { /> )) } + { + isOnlineDrive && ONLINE_DRIVE_OUTPUT.map((item, index) => ( + + )) + } { showAuthModal && !isLocalFile && ( diff --git a/web/app/components/workflow/nodes/data-source/types.ts b/web/app/components/workflow/nodes/data-source/types.ts index cdf1b5bf7e..a13b5c0fd7 100644 --- a/web/app/components/workflow/nodes/data-source/types.ts +++ b/web/app/components/workflow/nodes/data-source/types.ts @@ -10,6 +10,7 @@ export enum DataSourceClassification { localFile = 'local_file', websiteCrawl = 'website_crawl', onlineDocument = 'online_document', + onlineDrive = 'online_drive', } export type ToolVarInputs = Record