mirror of
https://github.com/langgenius/dify.git
synced 2025-12-13 03:11:05 +00:00
datasource variables
This commit is contained in:
parent
377093b776
commit
b320ebe2ba
@ -34,6 +34,7 @@ import {
|
||||
TOOL_OUTPUT_STRUCT,
|
||||
} from '@/app/components/workflow/constants'
|
||||
import DataSourceNodeDefault from '@/app/components/workflow/nodes/data-source/default'
|
||||
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
|
||||
import type { PromptItem } from '@/models/debug'
|
||||
import { VAR_REGEX } from '@/config'
|
||||
import type { AgentNodeType } from '../../../agent/types'
|
||||
@ -459,7 +460,7 @@ const formatItem = (
|
||||
}
|
||||
|
||||
case BlockEnum.DataSource: {
|
||||
res.vars = DataSourceNodeDefault.getOutputVars?.(data as any) || []
|
||||
res.vars = DataSourceNodeDefault.getOutputVars?.(data as DataSourceNodeType) || []
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import type { DataSourceNodeType } from './types'
|
||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { OUTPUT_VARIABLES_MAP } from './constants'
|
||||
import { inputVarTypeToVarType } from './utils'
|
||||
|
||||
const metaData = genNodeMetaData({
|
||||
sort: -1,
|
||||
@ -22,8 +23,12 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||
}
|
||||
},
|
||||
getOutputVars(payload) {
|
||||
const { provider_type } = payload
|
||||
const {
|
||||
provider_type,
|
||||
variables,
|
||||
} = payload
|
||||
const isLocalFile = provider_type === 'local_file'
|
||||
const hasUserInputFields = !!variables?.length
|
||||
return [
|
||||
{
|
||||
variable: OUTPUT_VARIABLES_MAP.datasource_type.name,
|
||||
@ -39,6 +44,17 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||
]
|
||||
: []
|
||||
),
|
||||
...(
|
||||
hasUserInputFields
|
||||
? variables.map((field) => {
|
||||
return {
|
||||
variable: field.variable,
|
||||
type: inputVarTypeToVarType(field.type),
|
||||
isUserInputField: true,
|
||||
}
|
||||
})
|
||||
: []
|
||||
),
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
10
web/app/components/workflow/nodes/data-source/utils.ts
Normal file
10
web/app/components/workflow/nodes/data-source/utils.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { PipelineInputVarType } from '@/models/pipeline'
|
||||
import { VarType } from '@/app/components/workflow/types'
|
||||
|
||||
export const inputVarTypeToVarType = (type: PipelineInputVarType): VarType => {
|
||||
return ({
|
||||
[PipelineInputVarType.number]: VarType.number,
|
||||
[PipelineInputVarType.singleFile]: VarType.file,
|
||||
[PipelineInputVarType.multiFiles]: VarType.arrayFile,
|
||||
} as any)[type] || VarType.string
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user