mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-04 03:25:30 +08:00
### What problem does this PR solve? Feat: Enables the message operator form to reference the data defined by the begin operator #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
30 lines
816 B
TypeScript
30 lines
816 B
TypeScript
import { useFetchAgent } from '@/hooks/use-agent-request';
|
|
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
|
import { useCallback } from 'react';
|
|
import useGraphStore from '../store';
|
|
import { buildDslComponentsByGraph } from '../utils';
|
|
|
|
export const useBuildDslData = () => {
|
|
const { data } = useFetchAgent();
|
|
const { nodes, edges } = useGraphStore((state) => state);
|
|
|
|
const buildDslData = useCallback(
|
|
(currentNodes?: RAGFlowNodeType[]) => {
|
|
const dslComponents = buildDslComponentsByGraph(
|
|
currentNodes ?? nodes,
|
|
edges,
|
|
data.dsl.components,
|
|
);
|
|
|
|
return {
|
|
...data.dsl,
|
|
graph: { nodes: currentNodes ?? nodes, edges },
|
|
components: dslComponents,
|
|
};
|
|
},
|
|
[data.dsl, edges, nodes],
|
|
);
|
|
|
|
return { buildDslData };
|
|
};
|