diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-children-tree-panel.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-children-tree-panel.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web/app/components/workflow/nodes/llm/mock-struct-data.ts b/web/app/components/workflow/nodes/llm/mock-struct-data.ts new file mode 100644 index 0000000000..f9c4f2e4cc --- /dev/null +++ b/web/app/components/workflow/nodes/llm/mock-struct-data.ts @@ -0,0 +1,54 @@ +import { type StructuredOutput, Type } from './types' + +const data: StructuredOutput = { + schema: { + type: Type.object, + properties: { + string_field: { + type: Type.string, + description: '可为空', + }, + obj_field: { + type: Type.object, + properties: { + string_field_1: { + type: Type.string, + description: '描述可为空', + }, + number_field_2: { + type: Type.number, + description: '描述可为空', + }, + array_field_4: { + type: Type.array, + items: { + type: Type.string, + }, + }, + boolean_field_5: { + type: Type.boolean, + description: '描述可为空', + }, + }, + required: [ + 'string_field_1', + 'number_field_2', + 'enum_field_3', + 'array_field_4', + 'boolean_field_5', + ], + additionalProperties: false, + }, + }, + required: [ + 'string_field_1', + 'number_field_2', + 'enum_field_3', + 'array_field_4', + 'boolean_field_5', + ], + additionalProperties: false, + }, +} + +export default data diff --git a/web/app/components/workflow/nodes/llm/types.ts b/web/app/components/workflow/nodes/llm/types.ts index a7774fca2e..e96cd55e20 100644 --- a/web/app/components/workflow/nodes/llm/types.ts +++ b/web/app/components/workflow/nodes/llm/types.ts @@ -16,3 +16,35 @@ export type LLMNodeType = CommonNodeType & { configs?: VisionSetting } } + +export enum Type { + string = 'string', + number = 'number', + boolean = 'boolean', + object = 'object', + array = 'array', +} + +type ArrayItemType = Exclude + +export type Field = { + type: Type + properties?: { // Object has properties + [key: string]: Field + } + required?: string[] // Key of required properties in object + description?: string + items?: { // Array has items. Define the item type + type: ArrayItemType + } + additionalProperties?: false // Required in object by api. Just set false +} + +export type StructuredOutput = { + schema: { + type: Type.object, + properties: Record + required: string[] + additionalProperties: false + } +}