mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 17:09:23 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
87 lines
2.7 KiB
TypeScript
87 lines
2.7 KiB
TypeScript
import type { PanelProps } from '@/app/components/workflow/panel'
|
|
import {
|
|
memo,
|
|
useMemo,
|
|
} from 'react'
|
|
import Panel from '@/app/components/workflow/panel'
|
|
import { useStore } from '@/app/components/workflow/store'
|
|
import dynamic from '@/next/dynamic'
|
|
|
|
const Record = dynamic(() => import('@/app/components/workflow/panel/record'), {
|
|
ssr: false,
|
|
})
|
|
const TestRunPanel = dynamic(() => import('@/app/components/rag-pipeline/components/panel/test-run'), {
|
|
ssr: false,
|
|
})
|
|
const InputFieldPanel = dynamic(() => import('./input-field'), {
|
|
ssr: false,
|
|
})
|
|
const InputFieldEditorPanel = dynamic(() => import('./input-field/editor'), {
|
|
ssr: false,
|
|
})
|
|
const PreviewPanel = dynamic(() => import('./input-field/preview'), {
|
|
ssr: false,
|
|
})
|
|
const GlobalVariablePanel = dynamic(() => import('@/app/components/workflow/panel/global-variable-panel'), {
|
|
ssr: false,
|
|
})
|
|
const RagPipelinePanelOnRight = () => {
|
|
const historyWorkflowData = useStore(s => s.historyWorkflowData)
|
|
const showDebugAndPreviewPanel = useStore(s => s.showDebugAndPreviewPanel)
|
|
const showGlobalVariablePanel = useStore(s => s.showGlobalVariablePanel)
|
|
|
|
return (
|
|
<>
|
|
{historyWorkflowData && <Record />}
|
|
{showDebugAndPreviewPanel && <TestRunPanel />}
|
|
{showGlobalVariablePanel && <GlobalVariablePanel />}
|
|
</>
|
|
)
|
|
}
|
|
|
|
const RagPipelinePanelOnLeft = () => {
|
|
const showInputFieldPanel = useStore(s => s.showInputFieldPanel)
|
|
const showInputFieldPreviewPanel = useStore(s => s.showInputFieldPreviewPanel)
|
|
const inputFieldEditPanelProps = useStore(s => s.inputFieldEditPanelProps)
|
|
return (
|
|
<>
|
|
{showInputFieldPreviewPanel && <PreviewPanel />}
|
|
{inputFieldEditPanelProps && (
|
|
<InputFieldEditorPanel
|
|
{...inputFieldEditPanelProps}
|
|
/>
|
|
)}
|
|
{showInputFieldPanel && <InputFieldPanel />}
|
|
</>
|
|
)
|
|
}
|
|
|
|
const RagPipelinePanel = () => {
|
|
const pipelineId = useStore(s => s.pipelineId)
|
|
const versionHistoryPanelProps = useMemo(() => {
|
|
return {
|
|
getVersionListUrl: `/rag/pipelines/${pipelineId}/workflows`,
|
|
deleteVersionUrl: (versionId: string) => `/rag/pipelines/${pipelineId}/workflows/${versionId}`,
|
|
restoreVersionUrl: (versionId: string) => `/rag/pipelines/${pipelineId}/workflows/${versionId}/restore`,
|
|
updateVersionUrl: (versionId: string) => `/rag/pipelines/${pipelineId}/workflows/${versionId}`,
|
|
latestVersionId: '',
|
|
}
|
|
}, [pipelineId])
|
|
|
|
const panelProps: PanelProps = useMemo(() => {
|
|
return {
|
|
components: {
|
|
left: <RagPipelinePanelOnLeft />,
|
|
right: <RagPipelinePanelOnRight />,
|
|
},
|
|
versionHistoryPanelProps,
|
|
}
|
|
}, [versionHistoryPanelProps])
|
|
|
|
return (
|
|
<Panel {...panelProps} />
|
|
)
|
|
}
|
|
|
|
export default memo(RagPipelinePanel)
|