feat(web): 增加节点输出编辑
This commit is contained in:
@@ -1,12 +1,59 @@
|
|||||||
|
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||||
import {Handle, type NodeProps, Position} from '@xyflow/react'
|
import {Handle, type NodeProps, Position} from '@xyflow/react'
|
||||||
import type {Schema} from 'amis'
|
import type {Schema} from 'amis'
|
||||||
import {Card, Dropdown} from 'antd'
|
import {Card, Dropdown} from 'antd'
|
||||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
|
||||||
import {isEmpty, isEqual} from 'licia'
|
import {isEmpty, isEqual} from 'licia'
|
||||||
import type {JSX} from 'react'
|
import type {JSX} from 'react'
|
||||||
|
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||||
|
|
||||||
export type AmisNodeType = 'normal' | 'start' | 'end'
|
export type AmisNodeType = 'normal' | 'start' | 'end'
|
||||||
|
|
||||||
|
export function outputsFormColumns(editable: boolean = false, preload?: any): Schema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
disabled: !editable,
|
||||||
|
type: 'input-kvs',
|
||||||
|
name: 'outputs',
|
||||||
|
label: '输出变量',
|
||||||
|
value: preload,
|
||||||
|
addButtonText: '新增输出',
|
||||||
|
draggable: false,
|
||||||
|
keyItem: {
|
||||||
|
...horizontalFormOptions(),
|
||||||
|
label: '参数名称',
|
||||||
|
},
|
||||||
|
valueItems: [
|
||||||
|
{
|
||||||
|
...horizontalFormOptions(),
|
||||||
|
type: 'select',
|
||||||
|
name: 'type',
|
||||||
|
label: '参数',
|
||||||
|
required: true,
|
||||||
|
selectFirst: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '文本',
|
||||||
|
value: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '数字',
|
||||||
|
value: 'number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '文本数组',
|
||||||
|
value: 'array-string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '对象数组',
|
||||||
|
value: 'array-object',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const AmisNode = (
|
const AmisNode = (
|
||||||
props: NodeProps,
|
props: NodeProps,
|
||||||
type: AmisNodeType,
|
type: AmisNodeType,
|
||||||
@@ -67,10 +114,10 @@ const AmisNode = (
|
|||||||
placeholder: nodeDescription,
|
placeholder: nodeDescription,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'divider'
|
type: 'divider',
|
||||||
},
|
},
|
||||||
...(columnSchema ?? [])
|
...(columnSchema ?? []),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
case 'remove':
|
case 'remove':
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import AmisNode from './AmisNode.tsx'
|
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
||||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
|
||||||
|
|
||||||
const EndNode = (props: NodeProps) => AmisNode(
|
const EndNode = (props: NodeProps) => AmisNode(
|
||||||
props,
|
props,
|
||||||
@@ -8,30 +7,7 @@ const EndNode = (props: NodeProps) => AmisNode(
|
|||||||
'结束节点',
|
'结束节点',
|
||||||
'定义输出变量',
|
'定义输出变量',
|
||||||
undefined,
|
undefined,
|
||||||
[
|
outputsFormColumns(true),
|
||||||
{
|
|
||||||
type: 'input-kvs',
|
|
||||||
name: 'outputVariables',
|
|
||||||
label: '输出变量',
|
|
||||||
addButtonText: '新增输出',
|
|
||||||
draggable: false,
|
|
||||||
keyItem: {
|
|
||||||
...horizontalFormOptions(),
|
|
||||||
label: '参数名称',
|
|
||||||
},
|
|
||||||
valueItems: [
|
|
||||||
{
|
|
||||||
...horizontalFormOptions(),
|
|
||||||
type: 'select',
|
|
||||||
name: 'type',
|
|
||||||
label: '参数',
|
|
||||||
required: true,
|
|
||||||
selectFirst: true,
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export default EndNode
|
export default EndNode
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import AmisNode from './AmisNode.tsx'
|
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const LlmNode = (props: NodeProps) => AmisNode(
|
const LlmNode = (props: NodeProps) => AmisNode(
|
||||||
props,
|
props,
|
||||||
@@ -31,6 +31,10 @@ const LlmNode = (props: NodeProps) => AmisNode(
|
|||||||
label: '系统提示词',
|
label: '系统提示词',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
|
...outputsFormColumns(false, {text: {type: 'string'}}),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import AmisNode from './AmisNode.tsx'
|
|
||||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||||
|
import AmisNode from './AmisNode.tsx'
|
||||||
|
|
||||||
const StartNode = (props: NodeProps) => AmisNode(
|
const StartNode = (props: NodeProps) => AmisNode(
|
||||||
props,
|
props,
|
||||||
@@ -11,7 +11,7 @@ const StartNode = (props: NodeProps) => AmisNode(
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
type: 'input-kvs',
|
type: 'input-kvs',
|
||||||
name: 'inputVariables',
|
name: 'inputs',
|
||||||
label: '输入变量',
|
label: '输入变量',
|
||||||
addButtonText: '新增入参',
|
addButtonText: '新增入参',
|
||||||
draggable: false,
|
draggable: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user