diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/page.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/page.tsx index 47dd36eb81..02dec23744 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/page.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/page.tsx @@ -3,6 +3,7 @@ import ChartView from './chartView' import CardView from './cardView' import TracingPanel from './tracing/panel' import ApikeyInfoPanel from '@/app/components/app/overview/apikey-info-panel' +import Test from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/test' export type IDevelopProps = { params: { appId: string } @@ -13,6 +14,7 @@ const Overview = async ({ }: IDevelopProps) => { return (
+ diff --git a/web/app/components/app/configuration/config/index.tsx b/web/app/components/app/configuration/config/index.tsx index ffa724f6a0..dd4a076dde 100644 --- a/web/app/components/app/configuration/config/index.tsx +++ b/web/app/components/app/configuration/config/index.tsx @@ -16,9 +16,6 @@ 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-child-tree-panel' - const Config: FC = () => { const { mode, @@ -62,13 +59,6 @@ const Config: FC = () => {
-
- { }} - /> -
{/* Template */} = ({
-
+
{depth === MAX_DEPTH + 1 ? ( diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker/index.tsx similarity index 91% rename from web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/index.tsx rename to web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker/index.tsx index b7307c0256..119ec1140a 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker/index.tsx @@ -1,7 +1,7 @@ 'use client' import type { FC } from 'react' import React from 'react' -import type { Field as FieldType, StructuredOutput } from '../../../../llm/types' +import type { Field as FieldType, StructuredOutput } from '../../../../../llm/types' import Field from './field' type Props = { @@ -10,7 +10,7 @@ type Props = { onSelect: (field: FieldType) => void } -const ObjectChildrenTreePanel: FC = ({ +const PickerPanel: FC = ({ root, payload, }) => { @@ -38,4 +38,4 @@ const ObjectChildrenTreePanel: FC = ({
) } -export default React.memo(ObjectChildrenTreePanel) +export default React.memo(PickerPanel) diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/field.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/field.tsx new file mode 100644 index 0000000000..e43084e0a9 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/field.tsx @@ -0,0 +1,58 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import { Type } from '../../../../../llm/types' +import { getFieldType } from '../../../../../llm/utils' +import type { Field as FieldType } from '../../../../../llm/types' +import cn from '@/utils/classnames' +import TreeIndentLine from '../tree-indent-line' +import { useTranslation } from 'react-i18next' + +const MAX_DEPTH = 10 + +type Props = { name: string, payload: FieldType, depth?: number } + +const Field: FC = ({ + name, + payload, + depth = 1, +}) => { + const { t } = useTranslation() + if (depth > MAX_DEPTH + 1) + return null + return ( +
+
+
+ +
+
+
{name}
+
{getFieldType(payload)}
+
Required
+
+ {payload.description && ( +
{payload.description}
+ )} +
+ +
+ +
+ + {payload.type === Type.object && payload.properties && ( +
+ {Object.keys(payload.properties).map(name => ( + + ))} +
+ )} +
+ ) +} +export default React.memo(Field) diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/index.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/index.tsx new file mode 100644 index 0000000000..82748e0ff7 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/index.tsx @@ -0,0 +1,28 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import type { StructuredOutput } from '../../../../../llm/types' +import Field from './field' + +type Props = { + payload: StructuredOutput +} + +const ShowPanel: FC = ({ + payload, +}) => { + const schema = payload.schema + const fieldNames = Object.keys(schema.properties) + return ( +
+ {fieldNames.map(name => ( + + ))} +
+ ) +} +export default React.memo(ShowPanel) diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/test.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/test.tsx new file mode 100644 index 0000000000..4ab6307e16 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/test.tsx @@ -0,0 +1,24 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import mockStructData from '@/app/components/workflow/nodes/llm/mock-struct-data' +import PickerPanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker' +import ShowPanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show' + +const Test: FC = () => { + return ( +
+
+ +
+ { }} + /> +
+ ) +} +export default React.memo(Test) diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/tree-indent-line.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/tree-indent-line.tsx index f919114c47..7c6a23f79c 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/tree-indent-line.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/tree-indent-line.tsx @@ -16,7 +16,7 @@ const TreeIndentLine: FC = ({ return (
{depthArray.map(d => ( -
+
))}
)