dify/web/app/components/rag-pipeline/store/index.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

53 lines
2.5 KiB
TypeScript

import type { StateCreator } from 'zustand'
import type { InputFieldEditorProps } from '../components/panel/input-field/editor'
import type { DataSourceItem } from '@/app/components/workflow/block-selector/types'
import type { ToolWithProvider } from '@/app/components/workflow/types'
import type { IconInfo } from '@/models/datasets'
import type { RAGPipelineVariables } from '@/models/pipeline'
import { transformDataSourceToTool } from '@/app/components/workflow/block-selector/utils'
export type RagPipelineSliceShape = {
pipelineId: string
knowledgeName: string
knowledgeIcon?: IconInfo
showInputFieldPanel: boolean
setShowInputFieldPanel: (showInputFieldPanel: boolean) => void
showInputFieldPreviewPanel: boolean
setShowInputFieldPreviewPanel: (showInputFieldPreviewPanel: boolean) => void
inputFieldEditPanelProps: InputFieldEditorProps | null
setInputFieldEditPanelProps: (showInputFieldEditPanel: InputFieldEditorProps | null) => void
nodesDefaultConfigs: Record<string, any>
setNodesDefaultConfigs: (nodesDefaultConfigs: Record<string, any>) => void
ragPipelineVariables: RAGPipelineVariables
setRagPipelineVariables: (ragPipelineVariables: RAGPipelineVariables) => void
dataSourceList: ToolWithProvider[]
setDataSourceList: (dataSourceList: DataSourceItem[]) => void
isPreparingDataSource: boolean
setIsPreparingDataSource: (isPreparingDataSource: boolean) => void
}
export const createRagPipelineSliceSlice: StateCreator<RagPipelineSliceShape> = (set) => ({
pipelineId: '',
knowledgeName: '',
showInputFieldPanel: false,
setShowInputFieldPanel: (showInputFieldPanel) => set(() => ({ showInputFieldPanel })),
showInputFieldPreviewPanel: false,
setShowInputFieldPreviewPanel: (showInputFieldPreviewPanel) =>
set(() => ({ showInputFieldPreviewPanel })),
inputFieldEditPanelProps: null,
setInputFieldEditPanelProps: (inputFieldEditPanelProps) =>
set(() => ({ inputFieldEditPanelProps })),
nodesDefaultConfigs: {},
setNodesDefaultConfigs: (nodesDefaultConfigs) => set(() => ({ nodesDefaultConfigs })),
ragPipelineVariables: [],
setRagPipelineVariables: (ragPipelineVariables: RAGPipelineVariables) =>
set(() => ({ ragPipelineVariables })),
dataSourceList: [],
setDataSourceList: (dataSourceList: DataSourceItem[]) => {
const formattedDataSourceList = dataSourceList.map((item) => transformDataSourceToTool(item))
set(() => ({ dataSourceList: formattedDataSourceList }))
},
isPreparingDataSource: false,
setIsPreparingDataSource: (isPreparingDataSource) => set(() => ({ isPreparingDataSource })),
})