fix: json schema

This commit is contained in:
zxhlyh
2025-08-07 16:36:32 +08:00
parent 1b3860d012
commit d5f82d0d5f
5 changed files with 28 additions and 32 deletions

View File

@ -6,6 +6,8 @@ import type { ToolNodeType } from '../nodes/tool/types'
import { CollectionType } from '@/app/components/tools/types'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import { canFindTool } from '@/utils'
import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types'
import { Type } from '@/app/components/workflow/nodes/llm/types'
export const getToolCheckParams = (
toolData: ToolNodeType,
@ -41,3 +43,23 @@ export const getToolCheckParams = (
language,
}
}
export const wrapStructuredVarItem = (outputItem: any): StructuredOutput => {
const dataType = Type.object
const properties = Object.fromEntries(
Object.entries(outputItem.value?.properties || {}).filter(([key]) => key !== 'dify_builtin_type'),
) as Record<string, any>
return {
schema: {
type: dataType,
properties: {
[outputItem.name]: {
...outputItem.value,
properties,
alias: outputItem.value?.properties?.dify_builtin_type?.enum?.[0],
},
},
additionalProperties: false,
},
}
}