From 771a38434f86d0dcca974c570198f41d427e8147 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 26 Sep 2025 19:09:27 +0800 Subject: [PATCH] Feat: Bring the parser operator when creating a new data flow #9869 (#10309) ### What problem does this PR solve? Feat: Bring the parser operator when creating a new data flow #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/less/mixins.less | 2 +- web/src/locales/en.ts | 3 ++ web/src/locales/zh.ts | 3 ++ .../pages/agents/hooks/use-create-agent.ts | 37 ++++++++++++++++++- web/src/pages/agents/index.tsx | 6 +-- web/src/pages/data-flow/constant.tsx | 5 --- .../pages/data-flow/hooks/use-run-dataflow.ts | 3 ++ web/src/pages/data-flow/index.tsx | 15 +++++--- web/src/pages/data-flow/utils.ts | 8 ++++ 9 files changed, 66 insertions(+), 16 deletions(-) diff --git a/web/src/less/mixins.less b/web/src/less/mixins.less index 119c1a089..27049deea 100644 --- a/web/src/less/mixins.less +++ b/web/src/less/mixins.less @@ -5,7 +5,7 @@ .chunkText() { em { - color: red; + color: var(--accent-primary); font-style: normal; } table { diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 4726a704e..a46122da7 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -1583,6 +1583,9 @@ This delimiter is used to split the input text into several text pieces echo of 'Write your SQL query here. You can use variables, raw SQL, or mix both using variable syntax.', frameworkPrompts: 'Framework', release: 'Publish', + createFromBlank: 'Create from Blank', + createFromTemplate: 'Create from Template', + importJsonFile: 'Import json file', }, llmTools: { bad_calculator: { diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 2cc7eb472..a11fbbc0b 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -1494,6 +1494,9 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于 '在此处编写您的 SQL 查询。您可以使用变量、原始 SQL,或使用变量语法混合使用两者。', frameworkPrompts: '框架', release: '发布', + createFromBlank: '从空白创建', + createFromTemplate: '从模板创建', + importJsonFile: '导入 JSON 文件', }, footer: { profile: 'All rights reserved @ React', diff --git a/web/src/pages/agents/hooks/use-create-agent.ts b/web/src/pages/agents/hooks/use-create-agent.ts index 853756e7c..7ad835858 100644 --- a/web/src/pages/agents/hooks/use-create-agent.ts +++ b/web/src/pages/agents/hooks/use-create-agent.ts @@ -2,7 +2,11 @@ import { useSetModalState } from '@/hooks/common-hooks'; import { EmptyDsl, useSetAgent } from '@/hooks/use-agent-request'; import { DSL } from '@/interfaces/database/agent'; import { AgentCategory } from '@/pages/agent/constant'; -import { BeginId, Operator } from '@/pages/data-flow/constant'; +import { + BeginId, + Operator, + initialParserValues, +} from '@/pages/data-flow/constant'; import { useCallback } from 'react'; import { FlowType } from '../constant'; import { FormSchemaType } from '../create-agent-form'; @@ -24,8 +28,37 @@ export const DataflowEmptyDsl = { sourcePosition: 'left', targetPosition: 'right', }, + { + data: { + form: initialParserValues, + label: 'Parser', + name: 'Parser_0', + }, + dragging: false, + id: 'Parser:HipSignsRhyme', + measured: { + height: 57, + width: 200, + }, + position: { + x: 316.99524094206413, + y: 195.39629819663406, + }, + selected: true, + sourcePosition: 'right', + targetPosition: 'left', + type: 'parserNode', + }, + ], + edges: [ + { + id: 'xy-edge__Filestart-Parser:HipSignsRhymeend', + source: BeginId, + sourceHandle: 'start', + target: 'Parser:HipSignsRhyme', + targetHandle: 'end', + }, ], - edges: [], }, components: { [Operator.Begin]: { diff --git a/web/src/pages/agents/index.tsx b/web/src/pages/agents/index.tsx index 5889753dd..7ecc1ae39 100644 --- a/web/src/pages/agents/index.tsx +++ b/web/src/pages/agents/index.tsx @@ -79,21 +79,21 @@ export default function Agents() { onClick={showCreatingModal} > - Create from Blank + {t('flow.createFromBlank')} - Create from Template + {t('flow.createFromTemplate')} - Import json file + {t('flow.importJsonFile')} diff --git a/web/src/pages/data-flow/constant.tsx b/web/src/pages/data-flow/constant.tsx index 04d699ba4..6b2fd1094 100644 --- a/web/src/pages/data-flow/constant.tsx +++ b/web/src/pages/data-flow/constant.tsx @@ -268,11 +268,6 @@ export const initialParserValues = { fileFormat: FileType.PowerPoint, output_format: PptOutputFormat.Json, }, - { - fileFormat: FileType.Audio, - llm_id: '', - output_format: AudioOutputFormat.Text, - }, ], }; diff --git a/web/src/pages/data-flow/hooks/use-run-dataflow.ts b/web/src/pages/data-flow/hooks/use-run-dataflow.ts index 5144b80ff..d512009bf 100644 --- a/web/src/pages/data-flow/hooks/use-run-dataflow.ts +++ b/web/src/pages/data-flow/hooks/use-run-dataflow.ts @@ -1,3 +1,4 @@ +import message from '@/components/ui/message'; import { useSendMessageBySSE } from '@/hooks/use-send-message'; import api from '@/utils/api'; import { get } from 'lodash'; @@ -38,6 +39,8 @@ export function useRunDataflow( } return msgId; + } else { + message.error(get(res, 'data.message', '')); } }, [hideRunOrChatDrawer, id, saveGraph, send, setMessageId], diff --git a/web/src/pages/data-flow/index.tsx b/web/src/pages/data-flow/index.tsx index 8c97d6fac..7dff6ab2d 100644 --- a/web/src/pages/data-flow/index.tsx +++ b/web/src/pages/data-flow/index.tsx @@ -68,7 +68,8 @@ export default function DataFlow() { const { handleExportJson } = useHandleExportOrImportJsonFile(); const { saveGraph, loading } = useSaveGraph(); const { flowDetail: agentDetail } = useFetchDataOnMount(); - const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer); + const { handleRun, loading: running } = + useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer); const { visible: versionDialogVisible, @@ -136,14 +137,18 @@ export default function DataFlow() { > {t('flow.save')} - + {running || ( + + )} + + {isParsing || running ? t('dataflow.running') : t('flow.run')} +