mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
refactor: update variable naming for consistency and improve data source handling in pipeline components
This commit is contained in:
parent
314a2f9be8
commit
14a9052d60
@ -48,7 +48,7 @@ const InputFieldEditor = ({
|
|||||||
options,
|
options,
|
||||||
placeholder,
|
placeholder,
|
||||||
unit,
|
unit,
|
||||||
default: defaultValue,
|
default_value: defaultValue,
|
||||||
allowed_file_upload_methods: allowedFileUploadMethods,
|
allowed_file_upload_methods: allowedFileUploadMethods,
|
||||||
allowed_file_types: allowedTypesAndExtensions.allowedFileTypes,
|
allowed_file_types: allowedTypesAndExtensions.allowedFileTypes,
|
||||||
allowed_file_extensions: allowedTypesAndExtensions.allowedFileExtensions,
|
allowed_file_extensions: allowedTypesAndExtensions.allowedFileExtensions,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export const convertToInputFieldFormData = (data?: InputVar): FormData => {
|
|||||||
label,
|
label,
|
||||||
variable,
|
variable,
|
||||||
max_length,
|
max_length,
|
||||||
'default': defaultValue,
|
default_value,
|
||||||
required,
|
required,
|
||||||
tooltips,
|
tooltips,
|
||||||
options,
|
options,
|
||||||
@ -30,7 +30,7 @@ export const convertToInputFieldFormData = (data?: InputVar): FormData => {
|
|||||||
label,
|
label,
|
||||||
variable,
|
variable,
|
||||||
maxLength: max_length,
|
maxLength: max_length,
|
||||||
default: defaultValue,
|
default: default_value,
|
||||||
required,
|
required,
|
||||||
tooltips,
|
tooltips,
|
||||||
options,
|
options,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback, useEffect } from 'react'
|
||||||
import { useDataSourceOptions } from '../hooks'
|
import { useDataSourceOptions } from '../hooks'
|
||||||
import OptionCard from './option-card'
|
import OptionCard from './option-card'
|
||||||
import { File, Watercrawl } from '@/app/components/base/icons/src/public/knowledge'
|
import { File, Watercrawl } from '@/app/components/base/icons/src/public/knowledge'
|
||||||
@ -9,9 +9,8 @@ import { DataSourceProvider } from '@/models/common'
|
|||||||
import type { Datasource } from '../types'
|
import type { Datasource } from '../types'
|
||||||
|
|
||||||
type DataSourceOptionsProps = {
|
type DataSourceOptionsProps = {
|
||||||
dataSources: Datasource[]
|
|
||||||
dataSourceNodeId: string
|
dataSourceNodeId: string
|
||||||
onSelect: (option: string) => void
|
onSelect: (option: Datasource) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const DATA_SOURCE_ICONS = {
|
const DATA_SOURCE_ICONS = {
|
||||||
@ -23,15 +22,23 @@ const DATA_SOURCE_ICONS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DataSourceOptions = ({
|
const DataSourceOptions = ({
|
||||||
dataSources,
|
|
||||||
dataSourceNodeId,
|
dataSourceNodeId,
|
||||||
onSelect,
|
onSelect,
|
||||||
}: DataSourceOptionsProps) => {
|
}: DataSourceOptionsProps) => {
|
||||||
const options = useDataSourceOptions(dataSources)
|
const { dataSources, options } = useDataSourceOptions()
|
||||||
|
|
||||||
const handelSelect = useCallback((value: string) => {
|
const handelSelect = useCallback((value: string) => {
|
||||||
onSelect(value)
|
const selectedOption = dataSources.find(option => option.nodeId === value)
|
||||||
}, [onSelect])
|
if (!selectedOption)
|
||||||
|
return
|
||||||
|
onSelect(selectedOption)
|
||||||
|
}, [dataSources, onSelect])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (options.length > 0)
|
||||||
|
handelSelect(options[0].value)
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='grid w-full grid-cols-4 gap-1'>
|
<div className='grid w-full grid-cols-4 gap-1'>
|
||||||
|
|||||||
@ -1,21 +1,24 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { BaseFieldType } from '@/app/components/base/form/form-scenarios/base/types'
|
import { BaseFieldType } from '@/app/components/base/form/form-scenarios/base/types'
|
||||||
import { useStore } from '@/app/components/workflow/store'
|
import { useStore } from '@/app/components/workflow/store'
|
||||||
import { InputVarType } from '@/app/components/workflow/types'
|
|
||||||
import { usePipelineProcessingParams } from '@/service/use-pipeline'
|
import { usePipelineProcessingParams } from '@/service/use-pipeline'
|
||||||
|
import { PipelineInputVarType } from '@/models/pipeline'
|
||||||
|
|
||||||
type PartialInputVarType = InputVarType.textInput | InputVarType.number | InputVarType.select | InputVarType.checkbox
|
type PartialInputVarType = PipelineInputVarType.textInput | PipelineInputVarType.number | PipelineInputVarType.select | PipelineInputVarType.checkbox
|
||||||
|
|
||||||
const VAR_TYPE_MAP: Record<PartialInputVarType, BaseFieldType> = {
|
const VAR_TYPE_MAP: Record<PartialInputVarType, BaseFieldType> = {
|
||||||
[InputVarType.textInput]: BaseFieldType.textInput,
|
[PipelineInputVarType.textInput]: BaseFieldType.textInput,
|
||||||
[InputVarType.number]: BaseFieldType.numberInput,
|
[PipelineInputVarType.number]: BaseFieldType.numberInput,
|
||||||
[InputVarType.select]: BaseFieldType.select,
|
[PipelineInputVarType.select]: BaseFieldType.select,
|
||||||
[InputVarType.checkbox]: BaseFieldType.checkbox,
|
[PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useConfigurations = () => {
|
export const useConfigurations = (datasourceNodeId: string) => {
|
||||||
const pipelineId = useStore(state => state.pipelineId)
|
const pipelineId = useStore(state => state.pipelineId)
|
||||||
const { data: paramsConfig } = usePipelineProcessingParams(pipelineId!)
|
const { data: paramsConfig } = usePipelineProcessingParams({
|
||||||
|
pipeline_id: pipelineId!,
|
||||||
|
node_id: datasourceNodeId,
|
||||||
|
})
|
||||||
|
|
||||||
const initialData = useMemo(() => {
|
const initialData = useMemo(() => {
|
||||||
const variables = paramsConfig?.variables || []
|
const variables = paramsConfig?.variables || []
|
||||||
|
|||||||
@ -6,15 +6,17 @@ import type { FormType } from '@/app/components/base/form'
|
|||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
type DocumentProcessingProps = {
|
type DocumentProcessingProps = {
|
||||||
|
dataSourceNodeId: string
|
||||||
onProcess: (data: Record<string, any>) => void
|
onProcess: (data: Record<string, any>) => void
|
||||||
onBack: () => void
|
onBack: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentProcessing = ({
|
const DocumentProcessing = ({
|
||||||
|
dataSourceNodeId,
|
||||||
onProcess,
|
onProcess,
|
||||||
onBack,
|
onBack,
|
||||||
}: DocumentProcessingProps) => {
|
}: DocumentProcessingProps) => {
|
||||||
const { initialData, configurations } = useConfigurations()
|
const { initialData, configurations } = useConfigurations(dataSourceNodeId)
|
||||||
const schema = generateZodSchema(configurations)
|
const schema = generateZodSchema(configurations)
|
||||||
|
|
||||||
const renderCustomActions = useCallback((form: FormType) => (
|
const renderCustomActions = useCallback((form: FormType) => (
|
||||||
|
|||||||
@ -3,6 +3,10 @@ import type { DataSourceOption, Datasource } from './types'
|
|||||||
import { TestRunStep } from './types'
|
import { TestRunStep } from './types'
|
||||||
import { DataSourceType } from '@/models/datasets'
|
import { DataSourceType } from '@/models/datasets'
|
||||||
import { DataSourceProvider } from '@/models/common'
|
import { DataSourceProvider } from '@/models/common'
|
||||||
|
import { useNodes } from 'reactflow'
|
||||||
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
|
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
|
||||||
|
import { useMemo } from 'react'
|
||||||
|
|
||||||
export const useTestRunSteps = () => {
|
export const useTestRunSteps = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -19,45 +23,78 @@ export const useTestRunSteps = () => {
|
|||||||
return steps
|
return steps
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDataSourceOptions = (dataSources: Datasource[]) => {
|
export const useDataSourceOptions = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const options: DataSourceOption[] = []
|
const nodes = useNodes<DataSourceNodeType>()
|
||||||
dataSources.forEach((source) => {
|
const dataSources: Datasource[] = useMemo(() => {
|
||||||
if (source.type === DataSourceType.FILE) {
|
const dataSourceNodes = nodes.filter(node => node.data.type === BlockEnum.DataSource)
|
||||||
options.push({
|
return dataSourceNodes.map((node) => {
|
||||||
label: t('datasetPipeline.testRun.dataSource.localFiles'),
|
let type: DataSourceType | DataSourceProvider = DataSourceType.FILE
|
||||||
value: source.nodeId,
|
switch (node.data.tool_name) {
|
||||||
type: DataSourceType.FILE,
|
case 'file_upload':
|
||||||
})
|
type = DataSourceType.FILE
|
||||||
}
|
break
|
||||||
if (source.type === DataSourceType.NOTION) {
|
case 'search_notion':
|
||||||
options.push({
|
type = DataSourceType.NOTION
|
||||||
label: 'Notion',
|
break
|
||||||
value: source.nodeId,
|
case 'firecrawl':
|
||||||
type: DataSourceType.NOTION,
|
type = DataSourceProvider.fireCrawl
|
||||||
})
|
break
|
||||||
}
|
case 'jina_reader':
|
||||||
if (source.type === DataSourceProvider.fireCrawl) {
|
type = DataSourceProvider.jinaReader
|
||||||
options.push({
|
break
|
||||||
label: 'Firecrawl',
|
case 'water_crawl':
|
||||||
value: source.nodeId,
|
type = DataSourceProvider.waterCrawl
|
||||||
type: DataSourceProvider.fireCrawl,
|
break
|
||||||
})
|
}
|
||||||
}
|
return {
|
||||||
if (source.type === DataSourceProvider.jinaReader) {
|
nodeId: node.id,
|
||||||
options.push({
|
type,
|
||||||
label: 'Jina Reader',
|
config: {},
|
||||||
value: source.nodeId,
|
}
|
||||||
type: DataSourceProvider.jinaReader,
|
})
|
||||||
})
|
}, [nodes])
|
||||||
}
|
|
||||||
if (source.type === DataSourceProvider.waterCrawl) {
|
const options = useMemo(() => {
|
||||||
options.push({
|
const options: DataSourceOption[] = []
|
||||||
label: 'Water Crawl',
|
dataSources.forEach((source) => {
|
||||||
value: source.nodeId,
|
if (source.type === DataSourceType.FILE) {
|
||||||
type: DataSourceProvider.waterCrawl,
|
options.push({
|
||||||
})
|
label: t('datasetPipeline.testRun.dataSource.localFiles'),
|
||||||
}
|
value: source.nodeId,
|
||||||
})
|
type: DataSourceType.FILE,
|
||||||
return options
|
})
|
||||||
|
}
|
||||||
|
if (source.type === DataSourceType.NOTION) {
|
||||||
|
options.push({
|
||||||
|
label: 'Notion',
|
||||||
|
value: source.nodeId,
|
||||||
|
type: DataSourceType.NOTION,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (source.type === DataSourceProvider.fireCrawl) {
|
||||||
|
options.push({
|
||||||
|
label: 'Firecrawl',
|
||||||
|
value: source.nodeId,
|
||||||
|
type: DataSourceProvider.fireCrawl,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (source.type === DataSourceProvider.jinaReader) {
|
||||||
|
options.push({
|
||||||
|
label: 'Jina Reader',
|
||||||
|
value: source.nodeId,
|
||||||
|
type: DataSourceProvider.jinaReader,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (source.type === DataSourceProvider.waterCrawl) {
|
||||||
|
options.push({
|
||||||
|
label: 'Water Crawl',
|
||||||
|
value: source.nodeId,
|
||||||
|
type: DataSourceProvider.waterCrawl,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return options
|
||||||
|
}, [dataSources, t])
|
||||||
|
return { dataSources, options }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,11 +26,7 @@ const TestRunPanel = () => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const setShowDebugAndPreviewPanel = useWorkflowStoreWithSelector(state => state.setShowDebugAndPreviewPanel)
|
const setShowDebugAndPreviewPanel = useWorkflowStoreWithSelector(state => state.setShowDebugAndPreviewPanel)
|
||||||
const [currentStep, setCurrentStep] = useState(1)
|
const [currentStep, setCurrentStep] = useState(1)
|
||||||
const [datasource, setDatasource] = useState<Datasource>({
|
const [datasource, setDatasource] = useState<Datasource>()
|
||||||
nodeId: '1',
|
|
||||||
type: DataSourceType.FILE,
|
|
||||||
config: {},
|
|
||||||
})
|
|
||||||
const [fileList, setFiles] = useState<FileItem[]>([])
|
const [fileList, setFiles] = useState<FileItem[]>([])
|
||||||
const [notionPages, setNotionPages] = useState<NotionPage[]>([])
|
const [notionPages, setNotionPages] = useState<NotionPage[]>([])
|
||||||
const [websitePages, setWebsitePages] = useState<CrawlResultItem[]>([])
|
const [websitePages, setWebsitePages] = useState<CrawlResultItem[]>([])
|
||||||
@ -41,28 +37,6 @@ const TestRunPanel = () => {
|
|||||||
const enableBilling = useProviderContextSelector(state => state.enableBilling)
|
const enableBilling = useProviderContextSelector(state => state.enableBilling)
|
||||||
|
|
||||||
const steps = useTestRunSteps()
|
const steps = useTestRunSteps()
|
||||||
// TODO: replace with real data sources from API
|
|
||||||
const dataSources = useMemo(() => [{
|
|
||||||
nodeId: '1',
|
|
||||||
type: DataSourceType.FILE,
|
|
||||||
config: {},
|
|
||||||
}, {
|
|
||||||
nodeId: '2',
|
|
||||||
type: DataSourceType.NOTION,
|
|
||||||
config: {},
|
|
||||||
}, {
|
|
||||||
nodeId: '3',
|
|
||||||
type: DataSourceProvider.fireCrawl,
|
|
||||||
config: {},
|
|
||||||
}, {
|
|
||||||
nodeId: '4',
|
|
||||||
type: DataSourceProvider.jinaReader,
|
|
||||||
config: {},
|
|
||||||
}, {
|
|
||||||
nodeId: '5',
|
|
||||||
type: DataSourceProvider.waterCrawl,
|
|
||||||
config: {},
|
|
||||||
}], [])
|
|
||||||
|
|
||||||
const allFileLoaded = (fileList.length > 0 && fileList.every(file => file.file.id))
|
const allFileLoaded = (fileList.length > 0 && fileList.every(file => file.file.id))
|
||||||
const isVectorSpaceFull = plan.usage.vectorSpace >= plan.total.vectorSpace
|
const isVectorSpaceFull = plan.usage.vectorSpace >= plan.total.vectorSpace
|
||||||
@ -77,6 +51,7 @@ const TestRunPanel = () => {
|
|||||||
}, [fileList, isShowVectorSpaceFull])
|
}, [fileList, isShowVectorSpaceFull])
|
||||||
|
|
||||||
const nextBtnDisabled = useMemo(() => {
|
const nextBtnDisabled = useMemo(() => {
|
||||||
|
if (!datasource) return false
|
||||||
if (datasource.type === DataSourceType.FILE)
|
if (datasource.type === DataSourceType.FILE)
|
||||||
return nextDisabled
|
return nextDisabled
|
||||||
if (datasource.type === DataSourceType.NOTION)
|
if (datasource.type === DataSourceType.NOTION)
|
||||||
@ -92,13 +67,6 @@ const TestRunPanel = () => {
|
|||||||
setShowDebugAndPreviewPanel(false)
|
setShowDebugAndPreviewPanel(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDataSourceSelect = useCallback((option: string) => {
|
|
||||||
const dataSource = dataSources.find(dataSource => dataSource.nodeId === option)
|
|
||||||
if (!dataSource)
|
|
||||||
return
|
|
||||||
setDatasource(dataSource)
|
|
||||||
}, [dataSources])
|
|
||||||
|
|
||||||
const updateFile = (fileItem: FileItem, progress: number, list: FileItem[]) => {
|
const updateFile = (fileItem: FileItem, progress: number, list: FileItem[]) => {
|
||||||
const newList = produce(list, (draft) => {
|
const newList = produce(list, (draft) => {
|
||||||
const targetIndex = draft.findIndex(file => file.fileID === fileItem.fileID)
|
const targetIndex = draft.findIndex(file => file.fileID === fileItem.fileID)
|
||||||
@ -129,6 +97,8 @@ const TestRunPanel = () => {
|
|||||||
const { handleRun } = usePipelineRun()
|
const { handleRun } = usePipelineRun()
|
||||||
|
|
||||||
const handleProcess = useCallback((data: Record<string, any>) => {
|
const handleProcess = useCallback((data: Record<string, any>) => {
|
||||||
|
if (!datasource)
|
||||||
|
return
|
||||||
const datasourceInfo: Record<string, any> = {}
|
const datasourceInfo: Record<string, any> = {}
|
||||||
if (datasource.type === DataSourceType.FILE)
|
if (datasource.type === DataSourceType.FILE)
|
||||||
datasourceInfo.fileId = fileList.map(file => file.fileID)
|
datasourceInfo.fileId = fileList.map(file => file.fileID)
|
||||||
@ -176,11 +146,10 @@ const TestRunPanel = () => {
|
|||||||
<>
|
<>
|
||||||
<div className='flex flex-col gap-y-4 px-4 py-2'>
|
<div className='flex flex-col gap-y-4 px-4 py-2'>
|
||||||
<DataSourceOptions
|
<DataSourceOptions
|
||||||
dataSources={dataSources}
|
dataSourceNodeId={datasource?.nodeId || ''}
|
||||||
dataSourceNodeId={datasource.nodeId}
|
onSelect={setDatasource}
|
||||||
onSelect={handleDataSourceSelect}
|
|
||||||
/>
|
/>
|
||||||
{datasource.type === DataSourceType.FILE && (
|
{datasource?.type === DataSourceType.FILE && (
|
||||||
<LocalFile
|
<LocalFile
|
||||||
files={fileList}
|
files={fileList}
|
||||||
updateFile={updateFile}
|
updateFile={updateFile}
|
||||||
@ -188,13 +157,13 @@ const TestRunPanel = () => {
|
|||||||
notSupportBatchUpload={notSupportBatchUpload}
|
notSupportBatchUpload={notSupportBatchUpload}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{datasource.type === DataSourceType.NOTION && (
|
{datasource?.type === DataSourceType.NOTION && (
|
||||||
<Notion
|
<Notion
|
||||||
notionPages={notionPages}
|
notionPages={notionPages}
|
||||||
updateNotionPages={updateNotionPages}
|
updateNotionPages={updateNotionPages}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{datasource.type === DataSourceProvider.fireCrawl && (
|
{datasource?.type === DataSourceProvider.fireCrawl && (
|
||||||
<Firecrawl
|
<Firecrawl
|
||||||
checkedCrawlResult={websitePages}
|
checkedCrawlResult={websitePages}
|
||||||
onCheckedCrawlResultChange={setWebsitePages}
|
onCheckedCrawlResultChange={setWebsitePages}
|
||||||
@ -203,7 +172,7 @@ const TestRunPanel = () => {
|
|||||||
onCrawlOptionsChange={setCrawlOptions}
|
onCrawlOptionsChange={setCrawlOptions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{datasource.type === DataSourceProvider.jinaReader && (
|
{datasource?.type === DataSourceProvider.jinaReader && (
|
||||||
<JinaReader
|
<JinaReader
|
||||||
checkedCrawlResult={websitePages}
|
checkedCrawlResult={websitePages}
|
||||||
onCheckedCrawlResultChange={setWebsitePages}
|
onCheckedCrawlResultChange={setWebsitePages}
|
||||||
@ -212,7 +181,7 @@ const TestRunPanel = () => {
|
|||||||
onCrawlOptionsChange={setCrawlOptions}
|
onCrawlOptionsChange={setCrawlOptions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{datasource.type === DataSourceProvider.waterCrawl && (
|
{datasource?.type === DataSourceProvider.waterCrawl && (
|
||||||
<WaterCrawl
|
<WaterCrawl
|
||||||
checkedCrawlResult={websitePages}
|
checkedCrawlResult={websitePages}
|
||||||
onCheckedCrawlResultChange={setWebsitePages}
|
onCheckedCrawlResultChange={setWebsitePages}
|
||||||
@ -232,6 +201,7 @@ const TestRunPanel = () => {
|
|||||||
{
|
{
|
||||||
currentStep === 2 && (
|
currentStep === 2 && (
|
||||||
<DocumentProcessing
|
<DocumentProcessing
|
||||||
|
dataSourceNodeId={datasource?.nodeId || ''}
|
||||||
onProcess={handleProcess}
|
onProcess={handleProcess}
|
||||||
onBack={handleBackStep}
|
onBack={handleBackStep}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -81,7 +81,7 @@ export const usePipelineInit = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleGetInitialWorkflowData()
|
handleGetInitialWorkflowData()
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
import type { CommonNodeType } from '@/app/components/workflow/types'
|
import type { CommonNodeType } from '@/app/components/workflow/types'
|
||||||
|
import type { RAGPipelineVariables } from '@/models/pipeline'
|
||||||
|
|
||||||
export type DataSourceNodeType = CommonNodeType
|
export type DataSourceNodeType = CommonNodeType & {
|
||||||
|
variables: RAGPipelineVariables
|
||||||
|
}
|
||||||
|
|||||||
@ -113,7 +113,7 @@ export type RAGPipelineVariable = {
|
|||||||
label: string
|
label: string
|
||||||
variable: string
|
variable: string
|
||||||
max_length?: number
|
max_length?: number
|
||||||
default?: string
|
default_value?: string
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
unit?: string
|
unit?: string
|
||||||
required: boolean
|
required: boolean
|
||||||
@ -125,9 +125,40 @@ export type RAGPipelineVariable = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
|
export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
|
||||||
|
export type RAGPipelineVariables = RAGPipelineVariable[]
|
||||||
|
|
||||||
export type PipelineProcessingParamsResponse = {
|
export type PipelineProcessingParamsRequest = {
|
||||||
variables: RAGPipelineVariable[]
|
pipeline_id: string
|
||||||
|
node_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RAGPipelineVariables = RAGPipelineVariable[]
|
export type PipelineProcessingParamsResponse = {
|
||||||
|
variables: RAGPipelineVariables
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PipelineDatasourceNodeRunRequest = {
|
||||||
|
pipeline_id: string
|
||||||
|
node_id: string
|
||||||
|
inputs: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PipelineDatasourceNodeRunResponse = {
|
||||||
|
id: string
|
||||||
|
inputs: Record<string, any>
|
||||||
|
process_data: Record<string, any>
|
||||||
|
outputs: Record<string, any>
|
||||||
|
status: string
|
||||||
|
error?: string
|
||||||
|
elapsed_time: number
|
||||||
|
execution_metadata: {
|
||||||
|
total_tokens: number
|
||||||
|
total_price: number
|
||||||
|
currency?: string
|
||||||
|
}
|
||||||
|
extras: {
|
||||||
|
icon: string | object
|
||||||
|
}
|
||||||
|
created_at: string
|
||||||
|
created_by: string
|
||||||
|
finished_at: string
|
||||||
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import type {
|
|||||||
ImportPipelineDSLRequest,
|
ImportPipelineDSLRequest,
|
||||||
ImportPipelineDSLResponse,
|
ImportPipelineDSLResponse,
|
||||||
PipelineCheckDependenciesResponse,
|
PipelineCheckDependenciesResponse,
|
||||||
|
PipelineDatasourceNodeRunRequest,
|
||||||
|
PipelineProcessingParamsRequest,
|
||||||
PipelineProcessingParamsResponse,
|
PipelineProcessingParamsResponse,
|
||||||
PipelineTemplateByIdResponse,
|
PipelineTemplateByIdResponse,
|
||||||
PipelineTemplateListParams,
|
PipelineTemplateListParams,
|
||||||
@ -95,7 +97,7 @@ export const useImportPipelineDSLConfirm = (
|
|||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: [NAME_SPACE, 'dsl-import-confirm'],
|
mutationKey: [NAME_SPACE, 'dsl-import-confirm'],
|
||||||
mutationFn: (importId: string) => {
|
mutationFn: (importId: string) => {
|
||||||
return post<ImportPipelineDSLConfirmResponse>(`/rag/pipeline/imports/${importId}/confirm`)
|
return post<ImportPipelineDSLConfirmResponse>(`/rag/pipelines/imports/${importId}/confirm`)
|
||||||
},
|
},
|
||||||
...mutationOptions,
|
...mutationOptions,
|
||||||
})
|
})
|
||||||
@ -113,12 +115,29 @@ export const useCheckPipelineDependencies = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useDatasourceNodeRun = () => {
|
||||||
|
return useMutation({
|
||||||
|
mutationKey: [NAME_SPACE, 'datasource-node-run'],
|
||||||
|
mutationFn: (request: PipelineDatasourceNodeRunRequest) => {
|
||||||
|
const { pipeline_id, node_id, ...rest } = request
|
||||||
|
return post(`/rag/pipelines/${pipeline_id}/workflows/published/nodes/${node_id}/run`, {
|
||||||
|
body: rest,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Get the config of shared input fields
|
// Get the config of shared input fields
|
||||||
export const usePipelineProcessingParams = (pipelineId: string) => {
|
export const usePipelineProcessingParams = (params: PipelineProcessingParamsRequest) => {
|
||||||
|
const { pipeline_id, node_id } = params
|
||||||
return useQuery<PipelineProcessingParamsResponse>({
|
return useQuery<PipelineProcessingParamsResponse>({
|
||||||
queryKey: [NAME_SPACE, 'pipeline-processing-params', pipelineId],
|
queryKey: [NAME_SPACE, 'pipeline-processing-params', pipeline_id],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return get<PipelineProcessingParamsResponse>(`/rag/pipeline/${pipelineId}/workflows/processing/parameters`)
|
return get<PipelineProcessingParamsResponse>(`/rag/pipelines/${pipeline_id}/workflows/processing/parameters`, {
|
||||||
|
params: {
|
||||||
|
node_id,
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user