= ({
{itemData.variable.replace('conversation.', '')}
)}
{isRagVariable && (
- {itemData.variable.replace('rag.', '')}
+ {itemData.variable.split('.').slice(-1)[0]}
)}
{itemData.type}
diff --git a/web/app/components/workflow/nodes/data-source/constants.ts b/web/app/components/workflow/nodes/data-source/constants.ts
index 10aa058a71..5b6de604f1 100644
--- a/web/app/components/workflow/nodes/data-source/constants.ts
+++ b/web/app/components/workflow/nodes/data-source/constants.ts
@@ -23,13 +23,16 @@ export const DEFAULT_FILE_EXTENSIONS_IN_LOCAL_FILE_DATA_SOURCE = [
'html',
]
-export const OUTPUT_VARIABLES_MAP = {
- datasource_type: {
+export const COMMON_OUTPUT = [
+ {
name: 'datasource_type',
type: VarType.string,
description: 'local_file, online_document, website_crawl',
},
- file: {
+]
+
+export const FILE_OUTPUT = [
+ {
name: 'file',
type: VarType.file,
description: 'file',
@@ -76,4 +79,27 @@ export const OUTPUT_VARIABLES_MAP = {
},
],
},
-}
+]
+
+export const WEBSITE_OUTPUT = [
+ {
+ name: 'source_url',
+ type: VarType.string,
+ description: 'The URL of the crawled website',
+ },
+ {
+ name: 'content',
+ type: VarType.string,
+ description: 'The content of the crawled website',
+ },
+ {
+ name: 'title',
+ type: VarType.string,
+ description: 'The title of the crawled website',
+ },
+ {
+ name: 'description',
+ type: VarType.string,
+ description: 'The description of the crawled website',
+ },
+]
diff --git a/web/app/components/workflow/nodes/data-source/default.ts b/web/app/components/workflow/nodes/data-source/default.ts
index c6e73c5c34..5f46bed514 100644
--- a/web/app/components/workflow/nodes/data-source/default.ts
+++ b/web/app/components/workflow/nodes/data-source/default.ts
@@ -1,8 +1,13 @@
import type { NodeDefault } from '../../types'
import type { DataSourceNodeType } from './types'
+import { DataSourceClassification } from './types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
import { BlockEnum } from '@/app/components/workflow/types'
-import { OUTPUT_VARIABLES_MAP } from './constants'
+import {
+ COMMON_OUTPUT,
+ FILE_OUTPUT,
+ WEBSITE_OUTPUT,
+} from './constants'
const metaData = genNodeMetaData({
sort: -1,
@@ -24,20 +29,18 @@ const nodeDefault: NodeDefault = {
const {
provider_type,
} = payload
- const isLocalFile = provider_type === 'local_file'
+ const isLocalFile = provider_type === DataSourceClassification.file
+ const isWebsiteCrawl = provider_type === DataSourceClassification.website
return [
- {
- variable: OUTPUT_VARIABLES_MAP.datasource_type.name,
- type: OUTPUT_VARIABLES_MAP.datasource_type.type,
- },
+ ...COMMON_OUTPUT.map(item => ({ variable: item.name, type: item.type })),
...(
isLocalFile
- ? [
- {
- variable: OUTPUT_VARIABLES_MAP.file.name,
- type: OUTPUT_VARIABLES_MAP.file.type,
- },
- ]
+ ? FILE_OUTPUT.map(item => ({ variable: item.name, type: item.type }))
+ : []
+ ),
+ ...(
+ isWebsiteCrawl
+ ? WEBSITE_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 fb21678e53..c043de9df1 100644
--- a/web/app/components/workflow/nodes/data-source/panel.tsx
+++ b/web/app/components/workflow/nodes/data-source/panel.tsx
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next'
import { memo } from 'react'
import { useBoolean } from 'ahooks'
import type { DataSourceNodeType } from './types'
+import { DataSourceClassification } from './types'
import type { NodePanelProps } from '@/app/components/workflow/types'
import {
BoxGroupField,
@@ -17,7 +18,11 @@ import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/compo
import TagInput from '@/app/components/base/tag-input'
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import { useConfig } from './hooks/use-config'
-import { OUTPUT_VARIABLES_MAP } from './constants'
+import {
+ COMMON_OUTPUT,
+ FILE_OUTPUT,
+ WEBSITE_OUTPUT,
+} from './constants'
import { useStore } from '@/app/components/workflow/store'
import Button from '@/app/components/base/button'
import ConfigCredential from './components/config-credential'
@@ -35,7 +40,7 @@ const Panel: FC> = ({ id, data }) => {
const dataSourceList = useStore(s => s.dataSourceList)
const {
provider_type,
- provider_id,
+ plugin_id,
fileExtensions = [],
datasource_parameters,
} = data
@@ -43,8 +48,9 @@ const Panel: FC> = ({ id, data }) => {
handleFileExtensionsChange,
handleParametersChange,
} = useConfig(id)
- const isLocalFile = provider_type === 'local_file'
- const currentDataSource = dataSourceList?.find(ds => ds.plugin_id === provider_id)
+ const isLocalFile = provider_type === DataSourceClassification.file
+ const isWebsiteCrawl = provider_type === DataSourceClassification.website
+ const currentDataSource = dataSourceList?.find(ds => ds.plugin_id === plugin_id)
const isAuthorized = !!currentDataSource?.is_authorized
const [showAuthModal, {
setTrue: openAuthModal,
@@ -150,24 +156,37 @@ const Panel: FC> = ({ id, data }) => {
)
}
-
{
- isLocalFile && (
+ COMMON_OUTPUT.map(item => (
({
+ name={item.name}
+ type={item.type}
+ description={item.description}
+ />
+ ))
+ }
+ {
+ isLocalFile && FILE_OUTPUT.map(item => (
+ ({
name: item.name,
type: item.type,
description: item.description,
}))}
/>
- )
+ ))
+ }
+ {
+ isWebsiteCrawl && WEBSITE_OUTPUT.map(item => (
+
+ ))
}
{
diff --git a/web/app/components/workflow/nodes/data-source/types.ts b/web/app/components/workflow/nodes/data-source/types.ts
index c4b5559dfb..0c49a2019e 100644
--- a/web/app/components/workflow/nodes/data-source/types.ts
+++ b/web/app/components/workflow/nodes/data-source/types.ts
@@ -6,6 +6,11 @@ export enum VarType {
mixed = 'mixed',
}
+export enum DataSourceClassification {
+ file = 'local_file',
+ website = 'website_crawl',
+}
+
export type ToolVarInputs = Record {
+ if(isSystem)
+ return `sys.${variable[variable.length - 1]}`
+ if(isRagVar)
+ return variable[variable.length - 1]
+ return variable.slice(1).join('.')
+ }, [isRagVar, isSystem, variable])
const VariableIcon = useMemo(() => {
if (isEnv) {
diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts
index 33a7ce6665..9c393e64e7 100644
--- a/web/app/components/workflow/types.ts
+++ b/web/app/components/workflow/types.ts
@@ -100,7 +100,7 @@ export type CommonNodeType = {
retry_config?: WorkflowRetryConfig
default_value?: DefaultValueForm[]
} & T & Partial>
- & Partial>
+ & Partial>
export type CommonEdgeType = {
_hovering?: boolean