feat: enhance output schema descriptions and remove unused constants

This commit is contained in:
Harry 2025-08-01 15:09:29 +08:00
parent facbe02cf7
commit 29da2e5c19
4 changed files with 14 additions and 32 deletions

View File

@ -523,17 +523,19 @@ const formatItem = (
const dynamicOutputSchema: any[] = [] const dynamicOutputSchema: any[] = []
Object.keys(payload.output_schema.properties).forEach((outputKey) => { Object.keys(payload.output_schema.properties).forEach((outputKey) => {
const output = payload.output_schema!.properties[outputKey] const output = payload.output_schema!.properties[outputKey]
const dataType = output.type const dataType = output?.properties?.dify_builtin_type ? output.properties.dify_builtin_type.enum[0] : output.type
dynamicOutputSchema.push({ dynamicOutputSchema.push({
variable: outputKey, variable: outputKey,
type: dataType === 'array' type: dataType === 'array'
? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]` ? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]`
: `${output.type.slice(0, 1).toLocaleLowerCase()}${output.type.slice(1)}`, : `${dataType.slice(0, 1).toLocaleLowerCase()}${dataType.slice(1)}`,
description: output.description, description: output.description,
children: output.type === 'object' ? { children: output.type === 'object' ? {
schema: { schema: {
type: 'object', type: 'object',
properties: output.properties, properties: Object.fromEntries(
Object.entries(output.properties).filter(([key]) => key !== 'dify_builtin_type'),
),
}, },
} : undefined, } : undefined,
}) })

View File

@ -39,42 +39,42 @@ export const LOCAL_FILE_OUTPUT = [
{ {
name: 'name', name: 'name',
type: VarType.string, type: VarType.string,
description: '', description: 'file name',
}, },
{ {
name: 'size', name: 'size',
type: VarType.number, type: VarType.number,
description: '', description: 'file size',
}, },
{ {
name: 'type', name: 'type',
type: VarType.string, type: VarType.string,
description: '', description: 'file type',
}, },
{ {
name: 'extension', name: 'extension',
type: VarType.string, type: VarType.string,
description: '', description: 'file extension',
}, },
{ {
name: 'mime_type', name: 'mime_type',
type: VarType.string, type: VarType.string,
description: '', description: 'file mime type',
}, },
{ {
name: 'transfer_method', name: 'transfer_method',
type: VarType.string, type: VarType.string,
description: '', description: 'file transfer method',
}, },
{ {
name: 'url', name: 'url',
type: VarType.string, type: VarType.string,
description: '', description: 'file url',
}, },
{ {
name: 'related_id', name: 'related_id',
type: VarType.string, type: VarType.string,
description: '', description: 'file related id',
}, },
], ],
}, },

View File

@ -6,9 +6,6 @@ import { BlockEnum } from '@/app/components/workflow/types'
import { import {
COMMON_OUTPUT, COMMON_OUTPUT,
LOCAL_FILE_OUTPUT, LOCAL_FILE_OUTPUT,
ONLINE_DOCUMENT_OUTPUT,
ONLINE_DRIVE_OUTPUT,
WEBSITE_CRAWL_OUTPUT,
} from './constants' } from './constants'
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
@ -61,9 +58,6 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
provider_type, provider_type,
} = payload } = payload
const isLocalFile = provider_type === DataSourceClassification.localFile 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 [ return [
...COMMON_OUTPUT.map(item => ({ variable: item.name, type: item.type })), ...COMMON_OUTPUT.map(item => ({ variable: item.name, type: item.type })),
...( ...(
@ -71,21 +65,6 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
? LOCAL_FILE_OUTPUT.map(item => ({ variable: item.name, type: item.type })) ? LOCAL_FILE_OUTPUT.map(item => ({ variable: item.name, type: item.type }))
: [] : []
), ),
...(
isWebsiteCrawl
? WEBSITE_CRAWL_OUTPUT.map(item => ({ variable: item.name, type: item.type }))
: []
),
...(
isOnlineDocument
? ONLINE_DOCUMENT_OUTPUT.map(item => ({ variable: item.name, type: item.type }))
: []
),
...(
isOnlineDrive
? ONLINE_DRIVE_OUTPUT.map(item => ({ variable: item.name, type: item.type }))
: []
),
...ragVars, ...ragVars,
] ]
}, },

View File

@ -28,6 +28,7 @@ export enum Type {
arrayString = 'array[string]', arrayString = 'array[string]',
arrayNumber = 'array[number]', arrayNumber = 'array[number]',
arrayObject = 'array[object]', arrayObject = 'array[object]',
file = 'file',
} }
export enum ArrayType { export enum ArrayType {