diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx index 776ec7b6da..e6e3255dd5 100644 --- a/web/app/components/workflow/nodes/data-source/panel.tsx +++ b/web/app/components/workflow/nodes/data-source/panel.tsx @@ -15,6 +15,7 @@ import StructureOutputItem from '@/app/components/workflow/nodes/_base/component import TagInput from '@/app/components/base/tag-input' import { useNodesReadOnly } from '@/app/components/workflow/hooks' import { useConfig } from './hooks/use-config' +import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types' import { Type } from '@/app/components/workflow/nodes/llm/types' import { COMMON_OUTPUT, @@ -48,7 +49,24 @@ const Panel: FC> = ({ id, data }) => { const pipelineId = useStore(s => s.pipelineId) const setShowInputFieldPanel = useStore(s => s.setShowInputFieldPanel) - + const wrapStructuredVarItem = (outputItem: any): StructuredOutput => { + const dataType = outputItem.value?.properties?.dify_builtin_type ? outputItem.value?.properties?.dify_builtin_type.enum[0] : Type.object + const properties = Object.fromEntries( + Object.entries(outputItem.value?.properties || {}).filter(([key]) => key !== 'dify_builtin_type'), + ) as Record + return { + schema: { + type: dataType, + properties: { + [outputItem.name]: { + ...outputItem.value, + properties, + }, + }, + additionalProperties: false, + }, + } + } return (
{ @@ -123,15 +141,7 @@ const Panel: FC> = ({ id, data }) => { {outputItem.value?.type === 'object' ? ( + payload={wrapStructuredVarItem(outputItem)} /> ) : (