fix(workflow): tool plugin output_schema array type not selectable in subsequent nodes (#29035)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||
import { BlockEnum, VarType } from '@/app/components/workflow/types'
|
||||
import type { NodeDefault, ToolWithProvider } from '../../types'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type { NodeDefault, ToolWithProvider, Var } from '../../types'
|
||||
import type { ToolNodeType } from './types'
|
||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
import { TOOL_OUTPUT_STRUCT } from '../../constants'
|
||||
import { CollectionType } from '@/app/components/tools/types'
|
||||
import { canFindTool } from '@/utils'
|
||||
import { getMatchedSchemaType } from '../_base/components/variable/use-match-schema-type'
|
||||
import { Type } from '../llm/types'
|
||||
import { resolveVarType } from './output-schema-utils'
|
||||
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
|
||||
@@ -88,32 +89,26 @@ const nodeDefault: NodeDefault<ToolNodeType> = {
|
||||
const currCollection = currentTools.find(item => canFindTool(item.id, provider_id))
|
||||
const currTool = currCollection?.tools.find(tool => tool.name === payload.tool_name)
|
||||
const output_schema = currTool?.output_schema
|
||||
let res: any[] = []
|
||||
let res: Var[] = []
|
||||
if (!output_schema || !output_schema.properties) {
|
||||
res = TOOL_OUTPUT_STRUCT
|
||||
}
|
||||
else {
|
||||
const outputSchema: any[] = []
|
||||
const outputSchema: Var[] = []
|
||||
Object.keys(output_schema.properties).forEach((outputKey) => {
|
||||
const output = output_schema.properties[outputKey]
|
||||
const dataType = output.type
|
||||
const schemaType = getMatchedSchemaType(output, schemaTypeDefinitions)
|
||||
let type = dataType === 'array'
|
||||
? `Array[${output.items?.type ? output.items.type.slice(0, 1).toLocaleLowerCase() + output.items.type.slice(1) : 'Unknown'}]`
|
||||
: `${output.type ? output.type.slice(0, 1).toLocaleLowerCase() + output.type.slice(1) : 'Unknown'}`
|
||||
|
||||
if (type === VarType.object && schemaType === 'file')
|
||||
type = VarType.file
|
||||
const { type, schemaType } = resolveVarType(output, schemaTypeDefinitions)
|
||||
|
||||
outputSchema.push({
|
||||
variable: outputKey,
|
||||
type,
|
||||
description: output.description,
|
||||
des: output.description,
|
||||
schemaType,
|
||||
children: output.type === 'object' ? {
|
||||
schema: {
|
||||
type: 'object',
|
||||
type: Type.object,
|
||||
properties: output.properties,
|
||||
additionalProperties: false,
|
||||
},
|
||||
} : undefined,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user