import React from 'react'; import { useState } from "react"; import { useConfig } from "../../hooks/useConfig"; import { useDocument } from "../../hooks/useDocument"; import { useSession } from "../../hooks/useSession"; import DocumentPicker from "../upload/DocumentPicker"; import UploadDocumentsModal from "../upload/UploadDocumentsModal"; import PresetSelector from "./PresetSelector"; import ChunkingStep from "./ChunkingStep"; import { EmbeddingStep, RetrievalStep, LLMStep } from "./Steps"; import { Button, StepIndicator } from "../common/index"; import { useNavigate } from "react-router-dom"; import { saveConfig } from "../../services/api"; const STEP_LABELS = ["Upload", "Chunking", "Embedding", "Retrieval", "LLM & Memory"]; export default function ConfigWizard() { const navigate = useNavigate(); const [showUploadModal, setShowUploadModal] = useState(false); const { config, step, updateChunking, updateEmbedding, updateRetrieval, updateLLM, updateMemory, applyPreset, nextStep, prevStep } = useConfig(); const { document, upload, uploading, uploadProgress, clearDocument, selectDocument } = useDocument(); const { setDocId, setConfigId, setFilename } = useSession(); const canAdvance = step === 0 ? !!document : true; const isLastStep = step === STEP_LABELS.length - 1; const handleSelectExistingDocument = (doc) => { if (!doc) return; selectDocument({ id: doc.id, filename: doc.filename, file_type: doc.file_type || "unknown", file_size: doc.file_size || 0, content: "", }); setDocId(doc.id); setFilename(doc.filename); }; const handleComplete = async () => { if (!document?.id) return; try { const fullConfig = { chunker: config.chunker, embedder: config.embedder, vectorstore: config.vectorstore, retriever: config.retriever, reranker: { enabled: config.retriever.reranker_enabled || false, provider: config.retriever.reranker_provider || "huggingface_api", model: config.retriever.reranker_model || "BAAI/bge-reranker-base", }, llm: { ...config.llm }, memory: config.memory.type === "none" ? {} : config.memory, }; const { data } = await saveConfig({ document_id: document.id, name: "My Config", config_json: fullConfig, }); setDocId(document.id); setConfigId(data.id); setFilename(document.filename); navigate(`/preview?doc=${document.id}&config=${data.id}`); } catch (e) { alert(`Failed: ${e.response?.data?.detail || e.message}`); } }; const stepComponents = [

Upload document(s) through a compact dialog.

{document && (

Selected: {document.filename}

)} setShowUploadModal(false)} onUpload={upload} uploading={uploading} progress={uploadProgress} allowMultiple title="Upload documents for Custom Chat" />
, , , , , ]; return (

Configure RAG Pipeline

Set each stage — or pick a preset to start fast.

{step > 0 && }
{stepComponents[step]}
Step {step + 1} / {STEP_LABELS.length} {isLastStep ? : }
); }