From c5ee6e09d4a59d8e1a3ad2c802d4d2278e9d0533 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Thu, 21 Aug 2025 15:12:53 +0800 Subject: [PATCH] fix: output schema file type --- .../nodes/_base/components/variable/utils.ts | 14 ++++++++++---- .../workflow/nodes/data-source/default.ts | 14 +++++++++++--- web/app/components/workflow/utils/tool.ts | 2 ++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 1941c39ffe..c2a29c8620 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -408,13 +408,19 @@ const formatItem = ( Object.keys(output_schema.properties).forEach((outputKey) => { const output = output_schema.properties[outputKey] const dataType = output.type + const alias = getOutputVariableAlias(output.properties) + let type = dataType === 'array' + ? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]` + : `${output.type.slice(0, 1).toLocaleLowerCase()}${output.type.slice(1)}` + + if (type === VarType.object && alias === 'file') + type = VarType.file + outputSchema.push({ variable: outputKey, - type: dataType === 'array' - ? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]` - : `${output.type.slice(0, 1).toLocaleLowerCase()}${output.type.slice(1)}`, + type, description: output.description, - alias: getOutputVariableAlias(output.properties), + alias, children: output.type === 'object' ? { schema: { type: 'object', diff --git a/web/app/components/workflow/nodes/data-source/default.ts b/web/app/components/workflow/nodes/data-source/default.ts index de1974ff1f..579b3e6304 100644 --- a/web/app/components/workflow/nodes/data-source/default.ts +++ b/web/app/components/workflow/nodes/data-source/default.ts @@ -8,6 +8,7 @@ import { LOCAL_FILE_OUTPUT, } from './constants' import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' +import { getOutputVariableAlias } from '@/app/components/workflow/utils/tool' const i18nPrefix = 'workflow.errorMsg' @@ -63,12 +64,19 @@ const nodeDefault: NodeDefault = { Object.keys(payload.output_schema.properties).forEach((outputKey) => { const output = payload.output_schema!.properties[outputKey] const dataType = output.type + const alias = getOutputVariableAlias(output.properties) + let type = dataType === 'array' + ? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]` + : `${dataType.slice(0, 1).toLocaleLowerCase()}${dataType.slice(1)}` + + if (type === 'object' && alias === 'file') + type = 'file' + dynamicOutputSchema.push({ variable: outputKey, - type: dataType === 'array' - ? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]` - : `${dataType.slice(0, 1).toLocaleLowerCase()}${dataType.slice(1)}`, + type, description: output.description, + alias, children: output.type === 'object' ? { schema: { type: 'object', diff --git a/web/app/components/workflow/utils/tool.ts b/web/app/components/workflow/utils/tool.ts index 17494f704e..bad6680169 100644 --- a/web/app/components/workflow/utils/tool.ts +++ b/web/app/components/workflow/utils/tool.ts @@ -57,6 +57,8 @@ export const getOutputVariableAlias = (variable: Record) => { return CHUNK_TYPE_MAP.parent_child_chunks if (variable?.qa_chunks) return CHUNK_TYPE_MAP.qa_chunks + if (variable?.file_type) + return 'file' } export const wrapStructuredVarItem = (outputItem: any): StructuredOutput => { const dataType = Type.object