diff --git a/web/app/components/app/configuration/config/index.tsx b/web/app/components/app/configuration/config/index.tsx index dd4a076dde..b0aed6babf 100644 --- a/web/app/components/app/configuration/config/index.tsx +++ b/web/app/components/app/configuration/config/index.tsx @@ -16,6 +16,9 @@ import type { ModelConfig, PromptVariable } from '@/models/debug' import type { AppType } from '@/types/app' import { ModelModeType } from '@/types/app' +import mockStructData from '@/app/components/workflow/nodes/llm/mock-struct-data' +import ObjectChildrenTreePanel from '@/app/components/workflow/nodes/_base/components/variable/object-children-tree-panel' + const Config: FC = () => { const { mode, @@ -59,6 +62,7 @@ const Config: FC = () => {
+ { }} /> {/* Template */} void +} + +// TODO: depth can be depth 10. item 12 +const indentClassName: Record = { + 0: 'pl-[10px]', + 1: 'pl-[22px]', + 2: 'pl-[30px]', + 3: 'pl-[40px]', + 4: 'pl-[50px]', +} + +const Field: FC<{ name: string, payload: FieldType, depth?: number }> = ({ + name, + payload, + depth = 0, +}) => { + return ( +
+
+ {/* indent line */} +
+
{name}
+
{getFieldType(payload)}
+
+ {payload.type === Type.object && payload.properties && ( +
+ {Object.keys(payload.properties).map(name => ( + + ))} +
+ )} +
+ ) +} + +const ObjectChildrenTreePanel: FC = ({ + payload, +}) => { + const schema = payload.schema + const fieldNames = Object.keys(schema.properties) + return ( +
+ {fieldNames.map(name => ( + + ))} +
+ ) +} +export default React.memo(ObjectChildrenTreePanel) diff --git a/web/app/components/workflow/nodes/llm/types.ts b/web/app/components/workflow/nodes/llm/types.ts index e96cd55e20..7eaf547b5f 100644 --- a/web/app/components/workflow/nodes/llm/types.ts +++ b/web/app/components/workflow/nodes/llm/types.ts @@ -25,6 +25,15 @@ export enum Type { array = 'array', } +export enum ArrayType { + string = 'array[string]', + number = 'array[number]', + boolean = 'array[boolean]', + object = 'array[object]', +} + +export type TypeWithArray = Type | ArrayType + type ArrayItemType = Exclude export type Field = { diff --git a/web/app/components/workflow/nodes/llm/utils.ts b/web/app/components/workflow/nodes/llm/utils.ts index 5f6b0864d6..d3454e2083 100644 --- a/web/app/components/workflow/nodes/llm/utils.ts +++ b/web/app/components/workflow/nodes/llm/utils.ts @@ -1,5 +1,14 @@ -import type { LLMNodeType } from './types' +import { ArrayType, Type } from './types' +import type { Field, LLMNodeType } from './types' export const checkNodeValid = (payload: LLMNodeType) => { return true } + +export const getFieldType = (field: Field) => { + const { type, items } = field + if (type !== Type.array || !items) + return type + + return ArrayType[items.type] +}