mirror of https://github.com/langgenius/dify.git
feat: var assigner node struct
This commit is contained in:
parent
2fdcf1756e
commit
6057ba0988
|
|
@ -6,8 +6,8 @@ import Workflow from '@/app/components/workflow'
|
|||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
const nodes = [
|
||||
BlockEnum.Start, BlockEnum.DirectAnswer, BlockEnum.LLM, BlockEnum.KnowledgeRetrieval, BlockEnum.QuestionClassifier,
|
||||
BlockEnum.IfElse, BlockEnum.Code, BlockEnum.TemplateTransform, BlockEnum.HttpRequest,
|
||||
BlockEnum.Tool, BlockEnum.End,
|
||||
BlockEnum.IfElse, BlockEnum.Code, BlockEnum.TemplateTransform, BlockEnum.HttpRequest, BlockEnum.Tool,
|
||||
BlockEnum.VariableAssigner, BlockEnum.End,
|
||||
].map((item, i) => ({
|
||||
id: `${i + 1}`,
|
||||
type: 'custom',
|
||||
|
|
@ -43,12 +43,7 @@ const Page: FC = () => {
|
|||
<Workflow
|
||||
nodes={initialNodes}
|
||||
edges={initialEdges}
|
||||
/*
|
||||
* TODO: for debug.
|
||||
* 2 directAnswer 3: llm 5: questionClassifier
|
||||
* 6 if else 7 Code, 8 TemplateTransform 9 http
|
||||
*/
|
||||
selectedNodeId='6'
|
||||
selectedNodeId='1'
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import HttpNode from './http/node'
|
|||
import HttpPanel from './http/panel'
|
||||
import ToolNode from './tool/node'
|
||||
import ToolPanel from './tool/panel'
|
||||
import VariableAssignerNode from './variable-assigner/node'
|
||||
import VariableAssignerPanel from './variable-assigner/panel'
|
||||
|
||||
export const NodeComponentMap: Record<string, ComponentType> = {
|
||||
[BlockEnum.Start]: StartNode,
|
||||
|
|
@ -35,6 +37,7 @@ export const NodeComponentMap: Record<string, ComponentType> = {
|
|||
[BlockEnum.TemplateTransform]: TemplateTransformNode,
|
||||
[BlockEnum.HttpRequest]: HttpNode,
|
||||
[BlockEnum.Tool]: ToolNode,
|
||||
[BlockEnum.VariableAssigner]: VariableAssignerNode,
|
||||
}
|
||||
|
||||
export const PanelComponentMap: Record<string, ComponentType> = {
|
||||
|
|
@ -49,4 +52,5 @@ export const PanelComponentMap: Record<string, ComponentType> = {
|
|||
[BlockEnum.TemplateTransform]: TemplateTransformPanel,
|
||||
[BlockEnum.HttpRequest]: HttpPanel,
|
||||
[BlockEnum.Tool]: ToolPanel,
|
||||
[BlockEnum.VariableAssigner]: VariableAssignerPanel,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import type { VariableAssignerNodeType } from './types'
|
||||
|
||||
export const mockData: VariableAssignerNodeType = {
|
||||
title: 'Test',
|
||||
desc: 'Test',
|
||||
type: 'Test',
|
||||
output_type: 'string',
|
||||
variables: [
|
||||
['aaa', 'name'],
|
||||
['bbb', 'b', 'c'],
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import type { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
// import { mockData } from './mock'
|
||||
const i18nPrefix = 'workflow.nodes.variableAssigner'
|
||||
|
||||
const Node: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
// const { variables } = mockData
|
||||
return (
|
||||
<div className='px-3'>
|
||||
<div className='leading-4 text-xs font-medium text-gray-500 uppercase'>{t(`${i18nPrefix}.title`)}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Node
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import type { FC } from 'react'
|
||||
|
||||
const Panel: FC = () => {
|
||||
return (
|
||||
<div>start panel inputs</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Panel
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
|
||||
|
||||
export type VariableAssignerNodeType = CommonNodeType & {
|
||||
output_type: string
|
||||
variables: ValueSelector[]
|
||||
}
|
||||
|
|
@ -71,6 +71,9 @@ const translation = {
|
|||
'not null': 'is not null',
|
||||
},
|
||||
},
|
||||
variableAssigner: {
|
||||
title: 'Assign variables',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ const translation = {
|
|||
'not null': '不为空',
|
||||
},
|
||||
},
|
||||
variableAssigner: {
|
||||
title: '变量赋值',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue