Commit cb2a8142 authored by Joel's avatar Joel

feat: assign output

parent db78b91e
...@@ -2,6 +2,7 @@ import type { CodeNodeType } from '../../../code/types' ...@@ -2,6 +2,7 @@ import type { CodeNodeType } from '../../../code/types'
import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types' import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types'
import type { StartNodeType } from '@/app/components/workflow/nodes/start/types' import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
import type { NodeOutPutVar } from '@/app/components/workflow/types' import type { NodeOutPutVar } from '@/app/components/workflow/types'
import type { VariableAssignerNodeType } from '@/app/components/workflow/nodes/variable-assigner/types'
import { import {
CHAT_QUESTION_CLASSIFIER_OUTPUT_STRUCT, CHAT_QUESTION_CLASSIFIER_OUTPUT_STRUCT,
COMPLETION_QUESTION_CLASSIFIER_OUTPUT_STRUCT, COMPLETION_QUESTION_CLASSIFIER_OUTPUT_STRUCT,
...@@ -77,6 +78,18 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => { ...@@ -77,6 +78,18 @@ const formatItem = (item: any, isChatMode: boolean): NodeOutPutVar => {
res.vars = HTTP_REQUEST_OUTPUT_STRUCT res.vars = HTTP_REQUEST_OUTPUT_STRUCT
break break
} }
case BlockEnum.VariableAssigner: {
const {
output_type,
} = data as VariableAssignerNodeType
res.vars = [
{
variable: 'output',
type: output_type,
},
]
}
} }
return res return res
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import type { FC } from 'react' import type { FC } from 'react'
import React, { useState } from 'react' import React, { useState } from 'react'
import cn from 'classnames' import cn from 'classnames'
import { isArray } from 'lodash-es'
import VarReferencePopup from './var-reference-popup' import VarReferencePopup from './var-reference-popup'
import { toNodeOutputVars } from './utils' import { toNodeOutputVars } from './utils'
import type { ValueSelector } from '@/app/components/workflow/types' import type { ValueSelector } from '@/app/components/workflow/types'
...@@ -29,6 +30,9 @@ type Props = { ...@@ -29,6 +30,9 @@ type Props = {
} }
export const getNodeInfoById = (nodes: any, id: string) => { export const getNodeInfoById = (nodes: any, id: string) => {
if (!isArray(nodes))
return
return nodes.find((node: any) => node.id === id) return nodes.find((node: any) => node.id === id)
} }
......
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types' import type { CommonNodeType, ValueSelector, VarType } from '@/app/components/workflow/types'
export type VariableAssignerNodeType = CommonNodeType & { export type VariableAssignerNodeType = CommonNodeType & {
output_type: string output_type: VarType
variables: ValueSelector[] variables: ValueSelector[]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment