2025-05-16 17:47:08 +08:00
|
|
|
import { useMemo } from 'react'
|
2025-04-25 11:32:17 +08:00
|
|
|
import WorkflowWithDefaultContext from '@/app/components/workflow'
|
2025-04-18 14:56:34 +08:00
|
|
|
import {
|
|
|
|
WorkflowContextProvider,
|
|
|
|
} from '@/app/components/workflow/context'
|
2025-04-18 15:46:54 +08:00
|
|
|
import type { InjectWorkflowStoreSliceFn } from '@/app/components/workflow/store'
|
2025-04-29 16:11:54 +08:00
|
|
|
import {
|
2025-05-16 17:47:08 +08:00
|
|
|
initialEdges,
|
|
|
|
initialNodes,
|
|
|
|
} from '@/app/components/workflow/utils'
|
|
|
|
import Loading from '@/app/components/base/loading'
|
2025-04-18 15:46:54 +08:00
|
|
|
import { createRagPipelineSliceSlice } from './store'
|
2025-04-25 11:32:17 +08:00
|
|
|
import RagPipelineMain from './components/rag-pipeline-main'
|
2025-05-16 17:47:08 +08:00
|
|
|
import { usePipelineInit } from './hooks'
|
2025-04-18 14:56:34 +08:00
|
|
|
|
|
|
|
const RagPipeline = () => {
|
2025-05-16 17:47:08 +08:00
|
|
|
const {
|
|
|
|
data,
|
|
|
|
isLoading,
|
|
|
|
} = usePipelineInit()
|
|
|
|
const nodesData = useMemo(() => {
|
|
|
|
if (data)
|
|
|
|
return initialNodes(data.graph.nodes, data.graph.edges)
|
|
|
|
|
|
|
|
return []
|
|
|
|
}, [data])
|
|
|
|
const edgesData = useMemo(() => {
|
|
|
|
if (data)
|
|
|
|
return initialEdges(data.graph.edges, data.graph.nodes)
|
|
|
|
|
|
|
|
return []
|
|
|
|
}, [data])
|
|
|
|
|
|
|
|
if (!data || isLoading) {
|
|
|
|
return (
|
|
|
|
<div className='relative flex h-full w-full items-center justify-center'>
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<WorkflowWithDefaultContext
|
|
|
|
edges={edgesData}
|
|
|
|
nodes={nodesData}
|
|
|
|
>
|
|
|
|
<RagPipelineMain
|
|
|
|
edges={edgesData}
|
|
|
|
nodes={nodesData}
|
2025-05-22 16:43:04 +08:00
|
|
|
viewport={data.graph.viewport}
|
2025-05-16 17:47:08 +08:00
|
|
|
/>
|
|
|
|
</WorkflowWithDefaultContext>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const RagPipelineWrapper = () => {
|
2025-04-18 14:56:34 +08:00
|
|
|
return (
|
2025-04-18 15:46:54 +08:00
|
|
|
<WorkflowContextProvider
|
|
|
|
injectWorkflowStoreSliceFn={createRagPipelineSliceSlice as InjectWorkflowStoreSliceFn}
|
|
|
|
>
|
2025-05-16 17:47:08 +08:00
|
|
|
<RagPipeline />
|
2025-04-18 14:56:34 +08:00
|
|
|
</WorkflowContextProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-05-16 17:47:08 +08:00
|
|
|
export default RagPipelineWrapper
|