import React, { useState, useEffect } from "react"; import { UploadCloud, FileText, Database, Search, CheckCircle2, ArrowRight, Loader2, Lock, Cpu, File, Terminal, } from "lucide-react"; import { useLanguage } from "../App"; import { TerminalBlock } from "../components/TerminalBlock"; export const Playground: React.FC = () => { const { language } = useLanguage(); const [step, setStep] = useState<"upload" | "processing" | "ready">("upload"); const [processingStage, setProcessingStage] = useState(0); // 0: Parsing, 1: Chunking, 2: Embedding, 3: Indexing const [query, setQuery] = useState(""); const [showResult, setShowResult] = useState(false); const content = { en: { title: "Enterprise Knowledge Engine", subtitle: "Experience our secure RAG pipeline architecture. Turn unstructured documents into queryable intelligence.", upload_title: "Data Ingestion", upload_desc: "Drag and drop your internal PDFs, DOCX, or Wiki dumps here. We simulate the ingestion process secure enterprises use.", drop_label: "Drop corporate assets here", processing_title: "Processing Pipeline", stages: [ "Optical Character Recognition (OCR)", "Semantic Chunking", "Vector Embedding (text-embedding-3-large)", "Pinecone Indexing", ], query_placeholder: "Ask a question about the uploaded documents...", query_btn: "Retrieve Insight", result_title: "Synthesized Answer", source_title: "Source Attribution", value_prop: "Why this matters: Most enterprise knowledge is trapped in PDFs. We build pipelines that unlock this data while respecting RBAC (Role-Based Access Control).", }, th: { title: "เครื่องยนต์ความรู้องค์กร", subtitle: "สัมผัสสถาปัตยกรรม RAG ที่ปลอดภัยของเรา เปลี่ยนเอกสารที่ไม่มีโครงสร้างให้เป็นข้อมูลอัจฉริยะที่ค้นหาได้", upload_title: "การนำเข้าข้อมูล", upload_desc: "ลากและวาง PDF, DOCX หรือ Wiki ภายในองค์กรที่นี่ เราจำลองกระบวนการนำเข้าข้อมูลที่องค์กรระดับสูงใช้", drop_label: "วางไฟล์ข้อมูลองค์กรที่นี่", processing_title: "ท่อประมวลผลข้อมูล", stages: [ "การแปลงภาพเป็นข้อความ (OCR)", "การแบ่งส่วนความหมาย (Semantic Chunking)", "การสร้าง Vector (text-embedding-3-large)", "การจัดทำดัชนี Pinecone", ], query_placeholder: "ถามคำถามเกี่ยวกับเอกสารที่อัปโหลด...", query_btn: "ค้นหาข้อมูลเชิงลึก", result_title: "คำตอบที่สังเคราะห์แล้ว", source_title: "การอ้างอิงแหล่งที่มา", value_prop: "ทำไมสิ่งนี้ถึงสำคัญ: ความรู้องค์กรส่วนใหญ่ติดอยู่ใน PDF เราสร้างระบบที่ปลดล็อกข้อมูลนี้โดยยังคงรักษาความปลอดภัยตามสิทธิ์การเข้าถึง (RBAC)", }, }; const t = content[language]; const handleSimulateUpload = () => { setStep("processing"); setProcessingStage(0); // Simulate pipeline stages const interval = setInterval(() => { setProcessingStage((prev) => { if (prev >= 3) { clearInterval(interval); setTimeout(() => setStep("ready"), 800); return 3; } return prev + 1; }); }, 1500); }; const handleSearch = (e: React.FormEvent) => { e.preventDefault(); if (!query) return; setShowResult(true); }; return (

{t.title}

{t.subtitle}

{/* Left: Demo Interface */}
{/* Step 1: Upload */}

{t.upload_title}

{step === "upload" && ( <>

{t.upload_desc}

policy_v2.pdf technical_specs.docx
)}
{/* Step 2: Processing Pipeline */} {(step === "processing" || step === "ready") && (

{t.processing_title}

{t.stages.map((stage, index) => (
index ? "bg-green-500 border-green-500" : processingStage === index ? "bg-white border-accent animate-pulse" : "bg-white border-gray-200" }`} >
= index ? "opacity-100" : "opacity-30"}`} >

{stage}

{processingStage === index && (

Processing...

)}
))}
)} {/* Step 3: Query Interface */} {step === "ready" && (
Secure Context
setQuery(e.target.value)} className="w-full bg-gray-50 border border-gray-200 p-4 pr-12 rounded-sm text-ink focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink font-serif placeholder:text-gray-400" placeholder={t.query_placeholder} />
{showResult && (

{t.result_title}

Based on the{" "} technical_specs.docx , the maximum concurrent connection limit for the websocket gateway is{" "} 10,000 users per shard. To increase this, you must scale the Redis cluster horizontally.

{t.source_title}

"...gateway.max_connections = 10000 # Hard limit per shard. See Redis scaling section..."
Score: 0.89
)}
)}
{/* Right: Architecture Context */}
pipeline_logs.txt
$ init_ingestion_job --secure
{step === "processing" && ( <>
[INFO] File uploaded: technical_specs.docx (2.4MB)
[INFO] Parsing PDF structure...
{processingStage >= 1 && (
[PROC] Chunking strategy: RecursiveCharacter (512tk)
)} {processingStage >= 2 && (
[EMBD] Batch embedding 142 chunks...
)} {processingStage >= 3 && (
[INDX] Upserting to namespace 'corp-knowledge'...
)} )} {step === "ready" && ( <>
[DONE] Indexing complete. Latency: 4.2s
----------------------------------------
$ waiting_for_query...
{showResult && ( <>
$ query_received
[RETR] Semantic search k=3
[GEN] LLM Context window filled (1200 tokens)
)} )}

Business Value

{t.value_prop}

); };