mirror of https://github.com/langgenius/dify.git
fix: output schema file type
This commit is contained in:
parent
60fafc524c
commit
c5ee6e09d4
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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<DataSourceNodeType> = {
|
|||
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',
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ export const getOutputVariableAlias = (variable: Record<string, any>) => {
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue