diff --git a/web/app/components/base/form/form-scenarios/base/types.ts b/web/app/components/base/form/form-scenarios/base/types.ts index 32b05aa8f9..9cdb60ae14 100644 --- a/web/app/components/base/form/form-scenarios/base/types.ts +++ b/web/app/components/base/form/form-scenarios/base/types.ts @@ -20,6 +20,7 @@ export type ShowCondition = { export type NumberConfiguration = { max?: number min?: number + unit?: string } export type SelectConfiguration = { diff --git a/web/app/components/rag-pipeline/components/input-field/editor/form/hooks.ts b/web/app/components/rag-pipeline/components/input-field/editor/form/hooks.ts index 3a43c2e030..86e9265677 100644 --- a/web/app/components/rag-pipeline/components/input-field/editor/form/hooks.ts +++ b/web/app/components/rag-pipeline/components/input-field/editor/form/hooks.ts @@ -320,7 +320,7 @@ export const useHiddenConfigurations = (props: { }, { type: InputFieldType.textInput, label: t('appDebug.variableConfig.tooltips'), - variable: 'hint', + variable: 'tooltips', required: false, showConditions: [], showOptional: true, diff --git a/web/app/components/rag-pipeline/components/panel/test-run/data-source/website/base/options/hooks.ts b/web/app/components/rag-pipeline/components/panel/test-run/data-source/website/base/options/hooks.ts index dc3a9292a2..312aef526d 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/data-source/website/base/options/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/data-source/website/base/options/hooks.ts @@ -11,7 +11,7 @@ export const useInitialData = (variables: RAGPipelineVariables) => { if (item.type === PipelineInputVarType.number) initialData[item.variable] = item.default_value || 0 if ([PipelineInputVarType.singleFile, PipelineInputVarType.multiFiles].includes(item.type)) - initialData[item.variable] = item.default_value || [] + initialData[item.variable] = [] if (item.type === PipelineInputVarType.checkbox) initialData[item.variable] = item.default_value || true }) diff --git a/web/app/components/rag-pipeline/components/panel/test-run/document-processing/hooks.ts b/web/app/components/rag-pipeline/components/panel/test-run/document-processing/hooks.ts index 921a7d57b2..2fcde8321c 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/document-processing/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/document-processing/hooks.ts @@ -1,18 +1,19 @@ import { useMemo } from 'react' +import type { BaseConfiguration } 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 { useDraftPipelineProcessingParams } from '@/service/use-pipeline' import { PipelineInputVarType } from '@/models/pipeline' -type PartialInputVarType = PipelineInputVarType.textInput | PipelineInputVarType.number | PipelineInputVarType.select | PipelineInputVarType.checkbox - -const VAR_TYPE_MAP: Record = { +const VAR_TYPE_MAP: Record = { [PipelineInputVarType.textInput]: BaseFieldType.textInput, - [PipelineInputVarType.number]: BaseFieldType.numberInput, + [PipelineInputVarType.paragraph]: BaseFieldType.textInput, [PipelineInputVarType.select]: BaseFieldType.select, + [PipelineInputVarType.singleFile]: BaseFieldType.file, + [PipelineInputVarType.multiFiles]: BaseFieldType.fileList, + [PipelineInputVarType.number]: BaseFieldType.numberInput, [PipelineInputVarType.checkbox]: BaseFieldType.checkbox, } - export const useConfigurations = (datasourceNodeId: string) => { const pipelineId = useStore(state => state.pipelineId) const { data: paramsConfig } = useDraftPipelineProcessingParams({ @@ -23,23 +24,23 @@ export const useConfigurations = (datasourceNodeId: string) => { const initialData = useMemo(() => { const variables = paramsConfig?.variables || [] return variables.reduce((acc, item) => { - const type = VAR_TYPE_MAP[item.type as PartialInputVarType] - if (type === BaseFieldType.textInput) - acc[item.variable] = '' + const type = VAR_TYPE_MAP[item.type] + if ([BaseFieldType.textInput, BaseFieldType.paragraph, BaseFieldType.select].includes(type)) + acc[item.variable] = item.default_value ?? '' if (type === BaseFieldType.numberInput) - acc[item.variable] = 0 - if (type === BaseFieldType.select) - acc[item.variable] = item.options?.[0] || '' + acc[item.variable] = item.default_value ?? 0 if (type === BaseFieldType.checkbox) acc[item.variable] = true + if ([BaseFieldType.file, BaseFieldType.fileList].includes(type)) + acc[item.variable] = [] return acc }, {} as Record) }, [paramsConfig]) const configurations = useMemo(() => { const variables = paramsConfig?.variables || [] - const configs = variables.map(item => ({ - type: VAR_TYPE_MAP[item.type as PartialInputVarType], + const configs: BaseConfiguration[] = variables.map(item => ({ + type: VAR_TYPE_MAP[item.type], variable: item.variable, label: item.label, required: item.required, @@ -50,6 +51,12 @@ export const useConfigurations = (datasourceNodeId: string) => { })), showConditions: [], default: item.default_value, + placeholder: item.placeholder, + tooltip: item.tooltips, + unit: item.unit, + allowedFileTypes: item.allowed_file_types, + allowedFileExtensions: item.allowed_file_extensions, + allowedFileUploadMethods: item.allowed_file_upload_methods, })) return configs }, [paramsConfig]) diff --git a/web/app/components/rag-pipeline/components/panel/test-run/document-processing/options.tsx b/web/app/components/rag-pipeline/components/panel/test-run/document-processing/options.tsx index f61020a067..b14d44c723 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/document-processing/options.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/document-processing/options.tsx @@ -28,7 +28,7 @@ const Options = ({ if (!result.success) { const issues = result.error.issues const firstIssue = issues[0] - const errorMessage = `"${firstIssue.path.join('.')}" ${firstIssue.message}` + const errorMessage = `Path: ${firstIssue.path.join('.')} Error: ${firstIssue.message}` Toast.notify({ type: 'error', message: errorMessage, diff --git a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts index 26805b34de..00d3d220e9 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts @@ -30,6 +30,7 @@ export const useDatasourceOptions = () => { const datasourceNodes = nodes.filter(node => node.data.type === BlockEnum.DataSource) return datasourceNodes.map((node) => { let type: DataSourceType | DataSourceProvider = DataSourceType.FILE + // todo: distinguish datasource type via provider_type field switch (node.data.tool_name) { case 'file_upload': type = DataSourceType.FILE diff --git a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx index 4604d8d404..0f8cc46ab6 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx @@ -119,6 +119,7 @@ const TestRunPanel = () => { } handleRun({ inputs: data, + start_node_id: datasource.nodeId, datasource_type, datasource_info: datasourceInfo, }) diff --git a/web/models/pipeline.ts b/web/models/pipeline.ts index efd6129488..ee431f742d 100644 --- a/web/models/pipeline.ts +++ b/web/models/pipeline.ts @@ -98,12 +98,12 @@ export type PipelineCheckDependenciesResponse = { } export enum PipelineInputVarType { - textInput = 'textInput', + textInput = 'text-input', paragraph = 'paragraph', select = 'select', - number = 'numberInput', + number = 'number-input', singleFile = 'file', - multiFiles = 'fileList', + multiFiles = 'file-list', checkbox = 'checkbox', } diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index 46520b996a..4f5b4383e4 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -143,6 +143,7 @@ export const useDraftPipelineProcessingParams = (params: PipelineProcessingParam }, }) }, + staleTime: 0, }) }