feat: assign output

This commit is contained in:
Joel 2024-03-13 15:57:47 +08:00
parent db78b91ec2
commit cb2a814296
3 changed files with 19 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import type { CodeNodeType } from '../../../code/types'
import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types'
import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
import type { NodeOutPutVar } from '@/app/components/workflow/types'
import type { VariableAssignerNodeType } from '@/app/components/workflow/nodes/variable-assigner/types'
import {
CHAT_QUESTION_CLASSIFIER_OUTPUT_STRUCT,
COMPLETION_QUESTION_CLASSIFIER_OUTPUT_STRUCT,
@ -77,6 +78,18 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
res.vars = HTTP_REQUEST_OUTPUT_STRUCT
break
}
case BlockEnum.VariableAssigner: {
const {
output_type,
} = data as VariableAssignerNodeType
res.vars = [
{
variable: 'output',
type: output_type,
},
]
}
}
return res

View File

@ -2,6 +2,7 @@
import type { FC } from 'react'
import React, { useState } from 'react'
import cn from 'classnames'
import { isArray } from 'lodash-es'
import VarReferencePopup from './var-reference-popup'
import { toNodeOutputVars } from './utils'
import type { ValueSelector } from '@/app/components/workflow/types'
@ -29,6 +30,9 @@ type Props = {
}
export const getNodeInfoById = (nodes: any, id: string) => {
if (!isArray(nodes))
return
return nodes.find((node: any) => node.id === id)
}

View File

@ -1,6 +1,6 @@
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
import type { CommonNodeType, ValueSelector, VarType } from '@/app/components/workflow/types'
export type VariableAssignerNodeType = CommonNodeType & {
output_type: string
output_type: VarType
variables: ValueSelector[]
}