mirror of
https://github.com/langgenius/dify.git
synced 2025-12-28 02:22:15 +00:00
feat: add rag pipeline store slice
This commit is contained in:
parent
2d87823fc6
commit
a36436b585
@ -5,11 +5,15 @@ import Panel from '@/app/components/workflow/panel'
|
||||
import {
|
||||
WorkflowContextProvider,
|
||||
} from '@/app/components/workflow/context'
|
||||
import type { InjectWorkflowStoreSliceFn } from '@/app/components/workflow/store'
|
||||
import RagPipelineHeader from './components/rag-pipeline-header'
|
||||
import { createRagPipelineSliceSlice } from './store'
|
||||
|
||||
const RagPipeline = () => {
|
||||
return (
|
||||
<WorkflowContextProvider>
|
||||
<WorkflowContextProvider
|
||||
injectWorkflowStoreSliceFn={createRagPipelineSliceSlice as InjectWorkflowStoreSliceFn}
|
||||
>
|
||||
<WorkflowWithDefaultContext
|
||||
edges={[]}
|
||||
nodes={[]}
|
||||
|
||||
12
web/app/components/rag-pipeline/store/index.ts
Normal file
12
web/app/components/rag-pipeline/store/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
|
||||
export type RagPipelineSliceShape = {
|
||||
showInputFieldDialog: boolean
|
||||
setShowInputFieldDialog: (showInputFieldDialog: boolean) => void
|
||||
}
|
||||
|
||||
export type CreateRagPipelineSliceSlice = StateCreator<RagPipelineSliceShape>
|
||||
export const createRagPipelineSliceSlice: StateCreator<RagPipelineSliceShape> = set => ({
|
||||
showInputFieldDialog: false,
|
||||
setShowInputFieldDialog: showInputFieldDialog => set(() => ({ showInputFieldDialog })),
|
||||
})
|
||||
@ -2,18 +2,18 @@ import {
|
||||
createContext,
|
||||
useRef,
|
||||
} from 'react'
|
||||
import type { SliceFromInjection } from './store'
|
||||
import {
|
||||
createWorkflowStore,
|
||||
} from './store'
|
||||
import type { StateCreator } from 'zustand'
|
||||
import type { WorkflowSliceShape } from '@/app/components/workflow-app/store/workflow/workflow-slice'
|
||||
|
||||
type WorkflowStore = ReturnType<typeof createWorkflowStore>
|
||||
export const WorkflowContext = createContext<WorkflowStore | null>(null)
|
||||
|
||||
export type WorkflowProviderProps = {
|
||||
children: React.ReactNode
|
||||
injectWorkflowStoreSliceFn?: StateCreator<WorkflowSliceShape>
|
||||
injectWorkflowStoreSliceFn?: StateCreator<SliceFromInjection>
|
||||
}
|
||||
export const WorkflowContextProvider = ({ children, injectWorkflowStoreSliceFn }: WorkflowProviderProps) => {
|
||||
const storeRef = useRef<WorkflowStore | undefined>(undefined)
|
||||
|
||||
@ -30,6 +30,11 @@ import type { WorkflowSliceShape } from './workflow-slice'
|
||||
import { createWorkflowSlice } from './workflow-slice'
|
||||
import { WorkflowContext } from '@/app/components/workflow/context'
|
||||
import type { WorkflowSliceShape as WorkflowAppSliceShape } from '@/app/components/workflow-app/store/workflow/workflow-slice'
|
||||
import type { RagPipelineSliceShape } from '@/app/components/rag-pipeline/store'
|
||||
|
||||
export type SliceFromInjection =
|
||||
Partial<WorkflowAppSliceShape> &
|
||||
Partial<RagPipelineSliceShape>
|
||||
|
||||
export type Shape =
|
||||
ChatVariableSliceShape &
|
||||
@ -43,10 +48,12 @@ export type Shape =
|
||||
VersionSliceShape &
|
||||
WorkflowDraftSliceShape &
|
||||
WorkflowSliceShape &
|
||||
WorkflowAppSliceShape
|
||||
SliceFromInjection
|
||||
|
||||
export type InjectWorkflowStoreSliceFn = StateCreator<SliceFromInjection>
|
||||
|
||||
type CreateWorkflowStoreParams = {
|
||||
injectWorkflowStoreSliceFn?: StateCreator<WorkflowAppSliceShape>
|
||||
injectWorkflowStoreSliceFn?: InjectWorkflowStoreSliceFn
|
||||
}
|
||||
|
||||
export const createWorkflowStore = (params: CreateWorkflowStoreParams) => {
|
||||
@ -64,7 +71,7 @@ export const createWorkflowStore = (params: CreateWorkflowStoreParams) => {
|
||||
...createVersionSlice(...args),
|
||||
...createWorkflowDraftSlice(...args),
|
||||
...createWorkflowSlice(...args),
|
||||
...(injectWorkflowStoreSliceFn?.(...args) || {} as WorkflowAppSliceShape),
|
||||
...(injectWorkflowStoreSliceFn?.(...args) || {} as (SliceFromInjection)),
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user