mirror of https://github.com/langgenius/dify.git
feat: enhance output schema descriptions and remove unused constants
This commit is contained in:
parent
facbe02cf7
commit
29da2e5c19
|
|
@ -523,17 +523,19 @@ const formatItem = (
|
|||
const dynamicOutputSchema: any[] = []
|
||||
Object.keys(payload.output_schema.properties).forEach((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({
|
||||
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)}`,
|
||||
: `${dataType.slice(0, 1).toLocaleLowerCase()}${dataType.slice(1)}`,
|
||||
description: output.description,
|
||||
children: output.type === 'object' ? {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: output.properties,
|
||||
properties: Object.fromEntries(
|
||||
Object.entries(output.properties).filter(([key]) => key !== 'dify_builtin_type'),
|
||||
),
|
||||
},
|
||||
} : undefined,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,42 +39,42 @@ export const LOCAL_FILE_OUTPUT = [
|
|||
{
|
||||
name: 'name',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file name',
|
||||
},
|
||||
{
|
||||
name: 'size',
|
||||
type: VarType.number,
|
||||
description: '',
|
||||
description: 'file size',
|
||||
},
|
||||
{
|
||||
name: 'type',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file type',
|
||||
},
|
||||
{
|
||||
name: 'extension',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file extension',
|
||||
},
|
||||
{
|
||||
name: 'mime_type',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file mime type',
|
||||
},
|
||||
{
|
||||
name: 'transfer_method',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file transfer method',
|
||||
},
|
||||
{
|
||||
name: 'url',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file url',
|
||||
},
|
||||
{
|
||||
name: 'related_id',
|
||||
type: VarType.string,
|
||||
description: '',
|
||||
description: 'file related id',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||
import {
|
||||
COMMON_OUTPUT,
|
||||
LOCAL_FILE_OUTPUT,
|
||||
ONLINE_DOCUMENT_OUTPUT,
|
||||
ONLINE_DRIVE_OUTPUT,
|
||||
WEBSITE_CRAWL_OUTPUT,
|
||||
} from './constants'
|
||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
|
||||
|
|
@ -61,9 +58,6 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
|||
provider_type,
|
||||
} = payload
|
||||
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 [
|
||||
...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 }))
|
||||
: []
|
||||
),
|
||||
...(
|
||||
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,
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export enum Type {
|
|||
arrayString = 'array[string]',
|
||||
arrayNumber = 'array[number]',
|
||||
arrayObject = 'array[object]',
|
||||
file = 'file',
|
||||
}
|
||||
|
||||
export enum ArrayType {
|
||||
|
|
|
|||
Loading…
Reference in New Issue