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)
This commit is contained in:
balibabu
2025-09-26 19:09:27 +08:00
committed by GitHub
parent 886d38620e
commit 771a38434f
9 changed files with 66 additions and 16 deletions

View File

@ -5,7 +5,7 @@
.chunkText() { .chunkText() {
em { em {
color: red; color: var(--accent-primary);
font-style: normal; font-style: normal;
} }
table { table {

View File

@ -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.', 'Write your SQL query here. You can use variables, raw SQL, or mix both using variable syntax.',
frameworkPrompts: 'Framework', frameworkPrompts: 'Framework',
release: 'Publish', release: 'Publish',
createFromBlank: 'Create from Blank',
createFromTemplate: 'Create from Template',
importJsonFile: 'Import json file',
}, },
llmTools: { llmTools: {
bad_calculator: { bad_calculator: {

View File

@ -1494,6 +1494,9 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
'在此处编写您的 SQL 查询。您可以使用变量、原始 SQL或使用变量语法混合使用两者。', '在此处编写您的 SQL 查询。您可以使用变量、原始 SQL或使用变量语法混合使用两者。',
frameworkPrompts: '框架', frameworkPrompts: '框架',
release: '发布', release: '发布',
createFromBlank: '从空白创建',
createFromTemplate: '从模板创建',
importJsonFile: '导入 JSON 文件',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

View File

@ -2,7 +2,11 @@ import { useSetModalState } from '@/hooks/common-hooks';
import { EmptyDsl, useSetAgent } from '@/hooks/use-agent-request'; import { EmptyDsl, useSetAgent } from '@/hooks/use-agent-request';
import { DSL } from '@/interfaces/database/agent'; import { DSL } from '@/interfaces/database/agent';
import { AgentCategory } from '@/pages/agent/constant'; 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 { useCallback } from 'react';
import { FlowType } from '../constant'; import { FlowType } from '../constant';
import { FormSchemaType } from '../create-agent-form'; import { FormSchemaType } from '../create-agent-form';
@ -24,8 +28,37 @@ export const DataflowEmptyDsl = {
sourcePosition: 'left', sourcePosition: 'left',
targetPosition: 'right', 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: { components: {
[Operator.Begin]: { [Operator.Begin]: {

View File

@ -79,21 +79,21 @@ export default function Agents() {
onClick={showCreatingModal} onClick={showCreatingModal}
> >
<Clipboard /> <Clipboard />
Create from Blank {t('flow.createFromBlank')}
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem <DropdownMenuItem
justifyBetween={false} justifyBetween={false}
onClick={navigateToAgentTemplates} onClick={navigateToAgentTemplates}
> >
<ClipboardPlus /> <ClipboardPlus />
Create from Template {t('flow.createFromTemplate')}
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem <DropdownMenuItem
justifyBetween={false} justifyBetween={false}
onClick={handleImportJson} onClick={handleImportJson}
> >
<FileInput /> <FileInput />
Import json file {t('flow.importJsonFile')}
</DropdownMenuItem> </DropdownMenuItem>
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>

View File

@ -268,11 +268,6 @@ export const initialParserValues = {
fileFormat: FileType.PowerPoint, fileFormat: FileType.PowerPoint,
output_format: PptOutputFormat.Json, output_format: PptOutputFormat.Json,
}, },
{
fileFormat: FileType.Audio,
llm_id: '',
output_format: AudioOutputFormat.Text,
},
], ],
}; };

View File

@ -1,3 +1,4 @@
import message from '@/components/ui/message';
import { useSendMessageBySSE } from '@/hooks/use-send-message'; import { useSendMessageBySSE } from '@/hooks/use-send-message';
import api from '@/utils/api'; import api from '@/utils/api';
import { get } from 'lodash'; import { get } from 'lodash';
@ -38,6 +39,8 @@ export function useRunDataflow(
} }
return msgId; return msgId;
} else {
message.error(get(res, 'data.message', ''));
} }
}, },
[hideRunOrChatDrawer, id, saveGraph, send, setMessageId], [hideRunOrChatDrawer, id, saveGraph, send, setMessageId],

View File

@ -68,7 +68,8 @@ export default function DataFlow() {
const { handleExportJson } = useHandleExportOrImportJsonFile(); const { handleExportJson } = useHandleExportOrImportJsonFile();
const { saveGraph, loading } = useSaveGraph(); const { saveGraph, loading } = useSaveGraph();
const { flowDetail: agentDetail } = useFetchDataOnMount(); const { flowDetail: agentDetail } = useFetchDataOnMount();
const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer); const { handleRun, loading: running } =
useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer);
const { const {
visible: versionDialogVisible, visible: versionDialogVisible,
@ -136,14 +137,18 @@ export default function DataFlow() {
> >
<LaptopMinimalCheck /> {t('flow.save')} <LaptopMinimalCheck /> {t('flow.save')}
</ButtonLoading> </ButtonLoading>
<Button <ButtonLoading
variant={'secondary'} variant={'secondary'}
onClick={handleRunAgent} onClick={handleRunAgent}
disabled={isParsing} disabled={isParsing}
loading={running}
> >
<CirclePlay className={isParsing ? 'animate-spin' : ''} /> {running || (
{isParsing ? t('dataflow.running') : t('flow.run')} <CirclePlay className={isParsing ? 'animate-spin' : ''} />
</Button> )}
{isParsing || running ? t('dataflow.running') : t('flow.run')}
</ButtonLoading>
<Button variant={'secondary'} onClick={showVersionDialog}> <Button variant={'secondary'} onClick={showVersionDialog}>
<History /> <History />
{t('flow.historyversion')} {t('flow.historyversion')}

View File

@ -14,6 +14,7 @@ import {
NodeHandleId, NodeHandleId,
Operator, Operator,
} from './constant'; } from './constant';
import { ExtractorFormSchemaType } from './form/extractor-form';
import { HierarchicalMergerFormSchemaType } from './form/hierarchical-merger-form'; import { HierarchicalMergerFormSchemaType } from './form/hierarchical-merger-form';
import { ParserFormSchemaType } from './form/parser-form'; import { ParserFormSchemaType } from './form/parser-form';
import { SplitterFormSchemaType } from './form/splitter-form'; import { SplitterFormSchemaType } from './form/splitter-form';
@ -143,6 +144,10 @@ function transformHierarchicalMergerParams(
return { ...params, hierarchy: Number(params.hierarchy), levels }; return { ...params, hierarchy: Number(params.hierarchy), levels };
} }
function transformExtractorParams(params: ExtractorFormSchemaType) {
return { ...params, prompts: [{ content: params.prompts, role: 'user' }] };
}
// construct a dsl based on the node information of the graph // construct a dsl based on the node information of the graph
export const buildDslComponentsByGraph = ( export const buildDslComponentsByGraph = (
nodes: RAGFlowNodeType[], nodes: RAGFlowNodeType[],
@ -174,6 +179,9 @@ export const buildDslComponentsByGraph = (
case Operator.HierarchicalMerger: case Operator.HierarchicalMerger:
params = transformHierarchicalMergerParams(params); params = transformHierarchicalMergerParams(params);
break; break;
case Operator.Extractor:
params = transformExtractorParams(params);
break;
default: default:
break; break;