54 lines
1.7 KiB
TypeScript
Raw Normal View History

import type { RAGPipelineVariables } from '@/models/pipeline'
2025-04-18 15:46:54 +08:00
import type { StateCreator } from 'zustand'
import { InputVarType } from '../../workflow/types'
2025-04-18 15:46:54 +08:00
export type RagPipelineSliceShape = {
2025-05-07 16:30:24 +08:00
pipelineId: string
showInputFieldDialog: boolean
setShowInputFieldDialog: (showInputFieldPanel: boolean) => void
2025-04-21 17:49:26 +08:00
nodesDefaultConfigs: Record<string, any>
setNodesDefaultConfigs: (nodesDefaultConfigs: Record<string, any>) => void
ragPipelineVariables: RAGPipelineVariables
setRagPipelineVariables: (ragPipelineVariables: RAGPipelineVariables) => void
2025-04-18 15:46:54 +08:00
}
export type CreateRagPipelineSliceSlice = StateCreator<RagPipelineSliceShape>
export const createRagPipelineSliceSlice: StateCreator<RagPipelineSliceShape> = set => ({
2025-05-07 16:30:24 +08:00
pipelineId: '',
showInputFieldDialog: false,
setShowInputFieldDialog: showInputFieldDialog => set(() => ({ showInputFieldDialog })),
2025-04-21 17:49:26 +08:00
nodesDefaultConfigs: {},
setNodesDefaultConfigs: nodesDefaultConfigs => set(() => ({ nodesDefaultConfigs })),
ragPipelineVariables: [{
// TODO: delete mock data
nodeId: '123',
variables: [{
variable: 'name',
label: 'name',
type: InputVarType.textInput,
required: true,
max_length: 12,
}, {
variable: 'num',
label: 'num',
type: InputVarType.number,
required: true,
}],
}, {
nodeId: '',
variables: [{
variable: 'name',
label: 'name',
type: InputVarType.textInput,
required: true,
max_length: 12,
}, {
variable: 'num',
label: 'num',
type: InputVarType.number,
required: true,
}],
}],
setRagPipelineVariables: (ragPipelineVariables: RAGPipelineVariables) => set(() => ({ ragPipelineVariables })),
2025-04-18 15:46:54 +08:00
})