mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 17:38:04 +08:00
feat: Add sub-graph component for workflow
This commit is contained in:
49
web/app/components/sub-graph/store/index.ts
Normal file
49
web/app/components/sub-graph/store/index.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import type { CreateSubGraphSlice, SubGraphSliceShape } from '../types'
|
||||
|
||||
const initialState: Omit<SubGraphSliceShape, 'setSubGraphContext' | 'setSubGraphNodes' | 'setSubGraphEdges' | 'setSelectedOutputVar' | 'setWhenOutputNone' | 'setDefaultValue' | 'setShowDebugPanel' | 'setIsRunning' | 'setParentAvailableVars' | 'resetSubGraph'> = {
|
||||
parentToolNodeId: '',
|
||||
parameterKey: '',
|
||||
sourceAgentNodeId: '',
|
||||
sourceVariable: [],
|
||||
|
||||
subGraphNodes: [],
|
||||
subGraphEdges: [],
|
||||
|
||||
selectedOutputVar: [],
|
||||
whenOutputNone: 'skip',
|
||||
defaultValue: '',
|
||||
|
||||
showDebugPanel: false,
|
||||
isRunning: false,
|
||||
|
||||
parentAvailableVars: [],
|
||||
}
|
||||
|
||||
export const createSubGraphSlice: CreateSubGraphSlice = set => ({
|
||||
...initialState,
|
||||
|
||||
setSubGraphContext: context => set(() => ({
|
||||
parentToolNodeId: context.parentToolNodeId,
|
||||
parameterKey: context.parameterKey,
|
||||
sourceAgentNodeId: context.sourceAgentNodeId,
|
||||
sourceVariable: context.sourceVariable,
|
||||
})),
|
||||
|
||||
setSubGraphNodes: nodes => set(() => ({ subGraphNodes: nodes })),
|
||||
|
||||
setSubGraphEdges: edges => set(() => ({ subGraphEdges: edges })),
|
||||
|
||||
setSelectedOutputVar: selector => set(() => ({ selectedOutputVar: selector })),
|
||||
|
||||
setWhenOutputNone: option => set(() => ({ whenOutputNone: option })),
|
||||
|
||||
setDefaultValue: value => set(() => ({ defaultValue: value })),
|
||||
|
||||
setShowDebugPanel: show => set(() => ({ showDebugPanel: show })),
|
||||
|
||||
setIsRunning: running => set(() => ({ isRunning: running })),
|
||||
|
||||
setParentAvailableVars: vars => set(() => ({ parentAvailableVars: vars })),
|
||||
|
||||
resetSubGraph: () => set(() => ({ ...initialState })),
|
||||
})
|
||||
Reference in New Issue
Block a user