diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts index 49f9dc359b..c8315f565c 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts +++ b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts @@ -51,7 +51,6 @@ export const useDatasourceOptions = (pipelineNodes: Node[]) return { nodeId: node.id, type: node.data.provider_type as DatasourceType, - variables: node.data.variables || [], description: node.data.desc || '', docTitle: '', // todo: Add docTitle and docLink if needed, or remove these properties if not used docLink: '', diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx index 8de9a436db..3eb2f0445d 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx @@ -274,7 +274,7 @@ const CreateFormPipeline = () => { {datasource?.type === DatasourceType.websiteCrawl && ( { +type DatasourceProps = { + onSelect: (dataSource: Datasource) => void + datasourceNodeId: string +} + +const DataSource = ({ + onSelect: setDatasource, + datasourceNodeId, +}: DatasourceProps) => { const { t } = useTranslation() return ( @@ -9,6 +20,13 @@ const DataSource = () => {
{t('datasetPipeline.inputFieldPanel.preview.stepOneTitle')}
+
+ +
+
) } diff --git a/web/app/components/rag-pipeline/components/input-field/preview/form.tsx b/web/app/components/rag-pipeline/components/input-field/preview/form.tsx new file mode 100644 index 0000000000..0e67b084df --- /dev/null +++ b/web/app/components/rag-pipeline/components/input-field/preview/form.tsx @@ -0,0 +1,41 @@ +import { useAppForm } from '@/app/components/base/form' +import BaseField from '@/app/components/base/form/form-scenarios/base/field' +import type { RAGPipelineVariables } from '@/models/pipeline' +import { useConfigurations, useInitialData } from '../../panel/test-run/data-source/website-crawl/base/options/hooks' + +type FormProps = { + variables: RAGPipelineVariables +} + +const Form = ({ + variables, +}: FormProps) => { + const initialData = useInitialData(variables) + const configurations = useConfigurations(variables) + + const form = useAppForm({ + defaultValues: initialData, + }) + + return ( + { + e.preventDefault() + e.stopPropagation() + }} + > +
+ {configurations.map((config, index) => { + const FieldComponent = BaseField({ + initialData, + config, + }) + return + })} +
+
+ ) +} + +export default Form diff --git a/web/app/components/rag-pipeline/components/input-field/preview/index.tsx b/web/app/components/rag-pipeline/components/input-field/preview/index.tsx index 534a219bb5..692306a642 100644 --- a/web/app/components/rag-pipeline/components/input-field/preview/index.tsx +++ b/web/app/components/rag-pipeline/components/input-field/preview/index.tsx @@ -1,7 +1,12 @@ +import { useState } from 'react' import { RiCloseLine } from '@remixicon/react' import DialogWrapper from './dialog-wrapper' import { useTranslation } from 'react-i18next' import Badge from '@/app/components/base/badge' +import DataSource from './data-source' +import Divider from '@/app/components/base/divider' +import ProcessDocuments from './process-documents' +import type { Datasource } from '../../panel/test-run/types' type PreviewPanelProps = { show: boolean @@ -13,6 +18,7 @@ const PreviewPanel = ({ onClose, }: PreviewPanelProps) => { const { t } = useTranslation() + const [datasource, setDatasource] = useState() return ( + +
+ +
+
) } diff --git a/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx b/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx new file mode 100644 index 0000000000..2d93f66b75 --- /dev/null +++ b/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' +import { useStore } from '@/app/components/workflow/store' +import { useDraftPipelineProcessingParams } from '@/service/use-pipeline' +import Form from './form' + +type ProcessDocumentsProps = { + dataSourceNodeId: string +} + +const ProcessDocuments = ({ + dataSourceNodeId, +}: ProcessDocumentsProps) => { + const { t } = useTranslation() + const pipelineId = useStore(state => state.pipelineId) + const { data: paramsConfig } = useDraftPipelineProcessingParams({ + pipeline_id: pipelineId!, + node_id: dataSourceNodeId, + }) + + return ( +
+
+ {t('datasetPipeline.inputFieldPanel.preview.stepTwoTitle')} +
+
+
+ ) +} + +export default React.memo(ProcessDocuments) 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 661a021a6a..3fbb1a07aa 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 @@ -49,7 +49,6 @@ export const useDatasourceOptions = () => { return { nodeId: node.id, type: node.data.provider_type as DatasourceType, - variables: node.data.variables || [], description: '', // todo: Add description docTitle: '', // todo: Add docTitle and docLink docLink: '', 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 5c718bb3da..84b48c3653 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 @@ -139,7 +139,7 @@ const TestRunPanel = () => { {datasource?.type === DatasourceType.websiteCrawl && (