mirror of
https://github.com/langgenius/dify.git
synced 2026-01-08 07:14:14 +00:00
fix: json schema
This commit is contained in:
@@ -413,6 +413,7 @@ const formatItem = (
|
||||
? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]`
|
||||
: `${output.type.slice(0, 1).toLocaleLowerCase()}${output.type.slice(1)}`,
|
||||
description: output.description,
|
||||
alias: output?.properties?.dify_builtin_type?.enum?.[0],
|
||||
children: output.type === 'object' ? {
|
||||
schema: {
|
||||
type: 'object',
|
||||
|
||||
@@ -69,7 +69,7 @@ const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
||||
? `array[${output.items?.type.slice(0, 1).toLocaleLowerCase()}${output.items?.type.slice(1)}]`
|
||||
: `${dataType.slice(0, 1).toLocaleLowerCase()}${dataType.slice(1)}`,
|
||||
description: output.description,
|
||||
alias: output?.properties.dify_builtin_type?.enum?.[0],
|
||||
alias: output?.properties?.dify_builtin_type?.enum?.[0],
|
||||
children: output.type === 'object' ? {
|
||||
schema: {
|
||||
type: 'object',
|
||||
|
||||
@@ -15,14 +15,13 @@ import StructureOutputItem from '@/app/components/workflow/nodes/_base/component
|
||||
import TagInput from '@/app/components/base/tag-input'
|
||||
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
|
||||
import { useConfig } from './hooks/use-config'
|
||||
import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types'
|
||||
import { Type } from '@/app/components/workflow/nodes/llm/types'
|
||||
import {
|
||||
COMMON_OUTPUT,
|
||||
} from './constants'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
|
||||
import ToolForm from '../tool/components/tool-form'
|
||||
import { wrapStructuredVarItem } from '@/app/components/workflow/utils/tool'
|
||||
|
||||
const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
||||
const { t } = useTranslation()
|
||||
@@ -49,25 +48,7 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
||||
|
||||
const pipelineId = useStore(s => s.pipelineId)
|
||||
const setShowInputFieldPanel = useStore(s => s.setShowInputFieldPanel)
|
||||
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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div >
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||
import StructureOutputItem from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show'
|
||||
import { Type } from '../llm/types'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import { wrapStructuredVarItem } from '@/app/components/workflow/utils/tool'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.tool'
|
||||
|
||||
@@ -121,15 +121,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
||||
{outputItem.value?.type === 'object' ? (
|
||||
<StructureOutputItem
|
||||
rootClassName='code-sm-semibold text-text-secondary'
|
||||
payload={{
|
||||
schema: {
|
||||
type: Type.object,
|
||||
properties: {
|
||||
[outputItem.name]: outputItem.value,
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
}} />
|
||||
payload={wrapStructuredVarItem(outputItem)} />
|
||||
) : (
|
||||
<VarItem
|
||||
name={outputItem.name}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user