From 2fdcf1756e8db4b81fd4722117c8f84f31f936b5 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 22 Feb 2024 11:04:14 +0800 Subject: [PATCH] feat: end node --- web/app/(commonLayout)/workflow/nodes/page.tsx | 4 ++-- web/app/components/workflow/nodes/end/mock.ts | 2 +- web/app/components/workflow/nodes/end/node.tsx | 17 ++++++++++++++++- web/i18n/lang/workflow.en.ts | 8 ++++++++ web/i18n/lang/workflow.zh.ts | 8 ++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/web/app/(commonLayout)/workflow/nodes/page.tsx b/web/app/(commonLayout)/workflow/nodes/page.tsx index e7402d9670..ad37e43649 100644 --- a/web/app/(commonLayout)/workflow/nodes/page.tsx +++ b/web/app/(commonLayout)/workflow/nodes/page.tsx @@ -7,11 +7,11 @@ 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.Tool, BlockEnum.End, ].map((item, i) => ({ id: `${i + 1}`, type: 'custom', - position: { x: 330, y: 30 + i * 200 }, + position: { x: 330, y: 30 + i * 300 }, data: { type: item, name: item }, })) const initialNodes = nodes diff --git a/web/app/components/workflow/nodes/end/mock.ts b/web/app/components/workflow/nodes/end/mock.ts index effe7c3182..b12d98cba9 100644 --- a/web/app/components/workflow/nodes/end/mock.ts +++ b/web/app/components/workflow/nodes/end/mock.ts @@ -6,7 +6,7 @@ export const mockData: EndNodeType = { desc: 'Test', type: 'Test', outputs: { - type: EndVarType.none, + type: EndVarType.plainText, plain_text_selector: ['test'], structured_variables: [ { diff --git a/web/app/components/workflow/nodes/end/node.tsx b/web/app/components/workflow/nodes/end/node.tsx index 58f3e653da..218c820649 100644 --- a/web/app/components/workflow/nodes/end/node.tsx +++ b/web/app/components/workflow/nodes/end/node.tsx @@ -1,8 +1,23 @@ import type { FC } from 'react' +import { useTranslation } from 'react-i18next' +import { mockData } from './mock' + +const i18nPrefix = 'workflow.nodes.end' const Node: FC = () => { + const { t } = useTranslation() + const { outputs } = mockData return ( -
end
+
+
+
+ {t(`${i18nPrefix}.outputs`)} +
+
+ {t(`${i18nPrefix}.type.${outputs.type}`)} +
+
+
) } diff --git a/web/i18n/lang/workflow.en.ts b/web/i18n/lang/workflow.en.ts index 221efc0c91..6f314a762a 100644 --- a/web/i18n/lang/workflow.en.ts +++ b/web/i18n/lang/workflow.en.ts @@ -7,6 +7,14 @@ const translation = { start: { required: 'required', }, + end: { + outputs: 'Outputs', + type: { + 'none': 'None', + 'plain-text': 'Plain Text', + 'structured': 'Structured', + }, + }, directAnswer: { answer: 'Answer', inputVars: 'Input Variables', diff --git a/web/i18n/lang/workflow.zh.ts b/web/i18n/lang/workflow.zh.ts index 76cd83c490..da4c0d3f68 100644 --- a/web/i18n/lang/workflow.zh.ts +++ b/web/i18n/lang/workflow.zh.ts @@ -7,6 +7,14 @@ const translation = { start: { required: '必填', }, + end: { + outputs: '输出', + type: { + 'none': '无', + 'plain-text': '纯文本', + 'structured': '结构化', + }, + }, directAnswer: { answer: '回复', inputVars: '输入变量',