@retrivora-ai/rag-engine 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{ILLMProvider-BfRgI1Xh.d.mts → ILLMProvider-BOJFz3Na.d.mts} +47 -1
  2. package/dist/{ILLMProvider-BfRgI1Xh.d.ts → ILLMProvider-BOJFz3Na.d.ts} +47 -1
  3. package/dist/handlers/index.d.mts +2 -2
  4. package/dist/handlers/index.d.ts +2 -2
  5. package/dist/handlers/index.js +509 -162
  6. package/dist/handlers/index.mjs +5849 -15
  7. package/dist/{index-1Z4GuYBi.d.ts → index-BwpcaziY.d.ts} +4 -2
  8. package/dist/{index-BV0z5mb6.d.mts → index-D3V9Et2M.d.mts} +4 -2
  9. package/dist/index.d.mts +30 -16
  10. package/dist/index.d.ts +30 -16
  11. package/dist/index.js +1999 -1210
  12. package/dist/index.mjs +2041 -1205
  13. package/dist/server.d.mts +21 -25
  14. package/dist/server.d.ts +21 -25
  15. package/dist/server.js +536 -163
  16. package/dist/server.mjs +5923 -67
  17. package/package.json +9 -7
  18. package/src/app/api/upload/route.ts +4 -0
  19. package/src/app/constants.tsx +2 -2
  20. package/src/app/globals.css +35 -11
  21. package/src/app/page.tsx +12 -321
  22. package/src/components/AmbientBackground.tsx +29 -0
  23. package/src/components/ArchitectureCard.tsx +17 -0
  24. package/src/components/ArchitectureCardsSection.tsx +15 -0
  25. package/src/components/ChatWidget.tsx +0 -1
  26. package/src/components/ChatWindow.tsx +32 -0
  27. package/src/components/CodeViewer.tsx +51 -0
  28. package/src/components/ConfigProvider.tsx +1 -0
  29. package/src/components/DocViewer.tsx +37 -0
  30. package/src/components/DocumentUpload.tsx +44 -1
  31. package/src/components/Documentation.tsx +58 -0
  32. package/src/components/DynamicChart.tsx +27 -2
  33. package/src/components/Hero.tsx +59 -0
  34. package/src/components/HourglassLoader.tsx +87 -0
  35. package/src/components/Lifecycle.tsx +37 -0
  36. package/src/components/MarkdownComponents.tsx +143 -0
  37. package/src/components/MessageBubble.tsx +91 -1012
  38. package/src/components/Navbar.tsx +55 -0
  39. package/src/components/ObservabilityPanel.tsx +374 -0
  40. package/src/components/ProductCard.tsx +3 -1
  41. package/src/components/UIDispatcher.tsx +341 -0
  42. package/src/components/VisualizationRenderer.tsx +48 -26
  43. package/src/config/ConfigBuilder.ts +38 -1
  44. package/src/core/LangChainAgent.ts +1 -4
  45. package/src/core/Pipeline.ts +209 -86
  46. package/src/core/QueryProcessor.ts +65 -0
  47. package/src/handlers/index.ts +72 -12
  48. package/src/hooks/useRagChat.ts +19 -9
  49. package/src/index.ts +9 -1
  50. package/src/providers/vectordb/MultiTablePostgresProvider.ts +150 -64
  51. package/src/rag/Reranker.ts +99 -6
  52. package/src/types/chat.ts +2 -0
  53. package/src/types/index.ts +52 -0
  54. package/src/types/props.ts +9 -1
  55. package/src/utils/ProductExtractor.ts +347 -0
  56. package/src/utils/UITransformer.ts +4 -53
  57. package/src/utils/synonyms.ts +78 -0
  58. package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
  59. package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
  60. package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
  61. package/dist/MultiTablePostgresProvider-YY7LPNJK.mjs +0 -8
  62. package/dist/PineconeProvider-QZNRKTN2.mjs +0 -8
  63. package/dist/QdrantProvider-RLJTNGPY.mjs +0 -8
  64. package/dist/RedisProvider-SR65SCKV.mjs +0 -8
  65. package/dist/SimpleGraphProvider-SLOXO4M7.mjs +0 -62
  66. package/dist/UniversalVectorProvider-IN67OS56.mjs +0 -9
  67. package/dist/WeaviateProvider-5FWDFITI.mjs +0 -8
  68. package/dist/chunk-5AJ4XHLW.mjs +0 -201
  69. package/dist/chunk-5YGUXK7Z.mjs +0 -80
  70. package/dist/chunk-BFYLQYQU.mjs +0 -3985
  71. package/dist/chunk-CFVEZTBJ.mjs +0 -102
  72. package/dist/chunk-IMP6FUCY.mjs +0 -30
  73. package/dist/chunk-LR3VMDVK.mjs +0 -157
  74. package/dist/chunk-M6JSPGAR.mjs +0 -117
  75. package/dist/chunk-PSFPZXHX.mjs +0 -245
  76. package/dist/chunk-R3RGUMHE.mjs +0 -218
  77. package/dist/chunk-U55XRW3U.mjs +0 -96
  78. package/dist/chunk-VUQJVIJT.mjs +0 -148
  79. package/dist/chunk-X4TOT24V.mjs +0 -89
  80. package/dist/chunk-YLTMFW4M.mjs +0 -49
@@ -13,7 +13,9 @@ import {
13
13
  Minimize2,
14
14
  Mic,
15
15
  MicOff,
16
+ Paperclip,
16
17
  } from 'lucide-react';
18
+ import { DocumentUpload } from './DocumentUpload';
17
19
  import { MessageBubble } from './MessageBubble';
18
20
  import { useConfig } from './ConfigProvider';
19
21
  import { useRagChat } from '../hooks/useRagChat';
@@ -77,6 +79,7 @@ export function ChatWindow({
77
79
  const [isSuggesting, setIsSuggesting] = useState(false);
78
80
 
79
81
  const [isListening, setIsListening] = useState(false);
82
+ const [isUploadModalOpen, setIsUploadModalOpen] = useState(false);
80
83
  const recognitionRef = useRef<ISpeechRecognition | null>(null);
81
84
 
82
85
  // Initialize SpeechRecognition
@@ -396,6 +399,24 @@ export function ChatWindow({
396
399
  <div ref={bottomRef} />
397
400
  </div>
398
401
 
402
+ {/* Upload Modal Overlay */}
403
+ {isUploadModalOpen && (
404
+ <div className="absolute inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/50 backdrop-blur-sm rounded-inherit">
405
+ <div className="relative w-full max-w-md bg-white dark:bg-[#0f0f1a] rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200">
406
+ <button
407
+ onClick={() => setIsUploadModalOpen(false)}
408
+ className="absolute top-4 right-4 p-1.5 rounded-lg text-slate-400 hover:text-slate-600 hover:bg-slate-100 dark:hover:text-white/80 dark:hover:bg-white/10 transition-colors z-10"
409
+ >
410
+ <X className="w-5 h-5" />
411
+ </button>
412
+ <DocumentUpload
413
+ namespace={projectId}
414
+ onUploadComplete={() => setIsUploadModalOpen(false)}
415
+ />
416
+ </div>
417
+ </div>
418
+ )}
419
+
399
420
  {/* ── Input ── */}
400
421
  <div className={`px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? 'bg-transparent' : 'bg-white dark:bg-[#0f0f1a]'}`}>
401
422
 
@@ -460,6 +481,17 @@ export function ChatWindow({
460
481
  </button>
461
482
  )}
462
483
 
484
+ {ui.allowUpload !== false && (
485
+ <button
486
+ type="button"
487
+ onClick={() => setIsUploadModalOpen(true)}
488
+ className="flex-shrink-0 w-9 h-9 rounded-xl flex items-center justify-center transition-all hover:scale-105 active:scale-95 text-slate-400 dark:text-white/40 hover:bg-slate-200 dark:hover:bg-white/10"
489
+ title="Upload Document"
490
+ >
491
+ <Paperclip className="w-4 h-4" />
492
+ </button>
493
+ )}
494
+
463
495
  <button
464
496
  onClick={sendMessage}
465
497
  disabled={!input.trim() || isLoading}
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Check, Copy } from 'lucide-react';
5
+ import { Snippet } from '@/app/types';
6
+
7
+ export function CodeViewer({ snippet }: { snippet: Snippet }) {
8
+ const [copied, setCopied] = React.useState(false);
9
+
10
+ const handleCopy = () => {
11
+ navigator.clipboard.writeText(snippet.code);
12
+ setCopied(true);
13
+ setTimeout(() => setCopied(false), 2000);
14
+ };
15
+
16
+ return (
17
+ <div className="flex flex-col h-full rounded-2xl border border-slate-200 dark:border-white/10 bg-slate-50 dark:bg-slate-900/50 shadow-lg overflow-hidden min-h-[440px]">
18
+ <div className="flex items-center justify-between px-5 py-3 border-b border-slate-200 dark:border-white/10 bg-white dark:bg-slate-900">
19
+ <div className="flex items-center gap-3">
20
+ <div className="flex gap-1.5">
21
+ <div className="w-2.5 h-2.5 rounded-full bg-red-500" />
22
+ <div className="w-2.5 h-2.5 rounded-full bg-yellow-500" />
23
+ <div className="w-2.5 h-2.5 rounded-full bg-green-500" />
24
+ </div>
25
+ <span className="text-[10px] font-mono text-slate-400 dark:text-white/30 uppercase tracking-widest ml-2">{snippet.language}</span>
26
+ </div>
27
+ <button
28
+ onClick={handleCopy}
29
+ className="flex items-center gap-2 text-[10px] font-bold text-slate-500 dark:text-white/40 hover:text-indigo-600 dark:hover:text-indigo-400 transition-all active:scale-95"
30
+ >
31
+ {copied ? (
32
+ <>
33
+ <Check size={14} className="text-emerald-500" />
34
+ <span className="text-emerald-500">Copied!</span>
35
+ </>
36
+ ) : (
37
+ <>
38
+ <Copy size={14} />
39
+ <span>Copy Code</span>
40
+ </>
41
+ )}
42
+ </button>
43
+ </div>
44
+ <div className="p-8 font-mono text-[12px] leading-relaxed overflow-auto custom-scrollbar flex-grow bg-[#0f172a] text-indigo-50">
45
+ <pre className="whitespace-pre">
46
+ <code>{snippet.code}</code>
47
+ </pre>
48
+ </div>
49
+ </div>
50
+ );
51
+ }
@@ -22,6 +22,7 @@ export function ConfigProvider({
22
22
  const merged: ClientConfig = {
23
23
  projectId: config?.projectId || DEFAULT_CONFIG.projectId,
24
24
  ui: mergeDefined(DEFAULT_CONFIG.ui, config?.ui) as Required<UIConfig>,
25
+ embedding: config?.embedding,
25
26
  };
26
27
 
27
28
  return <ConfigContext.Provider value={merged}>{children}</ConfigContext.Provider>;
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Snippet } from '@/app/types';
5
+ import { SNIPPETS } from '@/app/constants';
6
+ import { CodeViewer } from './CodeViewer';
7
+
8
+ export function DocViewer({ activeSnippet, setActiveSnippet }: { activeSnippet: Snippet, setActiveSnippet: (s: Snippet) => void }) {
9
+ return (
10
+ <>
11
+ <div className="mb-6 flex flex-wrap gap-2 border-b border-slate-100 dark:border-white/5 pb-6">
12
+ {SNIPPETS.map((snippet) => (
13
+ <button
14
+ key={snippet.id}
15
+ onClick={() => setActiveSnippet(snippet)}
16
+ className={`px-5 py-2 rounded-xl text-[10px] font-bold uppercase tracking-wider transition-all border ${activeSnippet.id === snippet.id
17
+ ? 'bg-indigo-600 text-white border-indigo-600 shadow-lg shadow-indigo-200 dark:shadow-indigo-500/20 scale-105'
18
+ : 'bg-white dark:bg-white/5 border-slate-200 dark:border-white/10 text-slate-500 dark:text-white/40 hover:text-indigo-600 dark:hover:text-indigo-400 hover:border-indigo-300 dark:hover:border-white/20'
19
+ }`}
20
+ >
21
+ {snippet.title}
22
+ </button>
23
+ ))}
24
+ </div>
25
+
26
+ <div className="flex-grow flex flex-col gap-6 animate-in fade-in slide-in-from-bottom-2 duration-500">
27
+ <div className="max-w-2xl">
28
+ <h3 className="text-xl font-bold text-slate-900 dark:text-white mb-2">{activeSnippet.title}</h3>
29
+ <p className="text-sm text-slate-500 dark:text-white/40 leading-relaxed font-medium italic">
30
+ {activeSnippet.description}
31
+ </p>
32
+ </div>
33
+ <CodeViewer snippet={activeSnippet} />
34
+ </div>
35
+ </>
36
+ );
37
+ }
@@ -13,11 +13,33 @@ interface FileState {
13
13
  }
14
14
 
15
15
  export function DocumentUpload({ namespace, onUploadComplete, className = '' }: DocumentUploadProps) {
16
- const { ui } = useConfig();
16
+ const { ui, embedding } = useConfig();
17
17
  const [fileStates, setFileStates] = useState<FileState[]>([]);
18
18
  const [isDragging, setIsDragging] = useState(false);
19
19
  const fileInputRef = useRef<HTMLInputElement>(null);
20
20
 
21
+ const MULTI_DIMENSION_MODELS: Record<string, number[]> = {
22
+ 'text-embedding-3-small': [512, 1536],
23
+ 'text-embedding-3-large': [256, 1024, 3072],
24
+ 'nomic-embed-text': [64, 128, 256, 512, 768]
25
+ };
26
+
27
+ const COMMON_DIMENSIONS = [64, 128, 256, 384, 512, 768, 1024, 1536, 3072];
28
+ const currentModel = embedding?.model || 'unknown';
29
+ const defaultDimension = embedding?.dimensions || 1536;
30
+
31
+ // Provide specific dimensions for known models, otherwise provide common ones
32
+ let availableDimensions = Object.entries(MULTI_DIMENSION_MODELS).find(([k]) => currentModel.includes(k))?.[1];
33
+ if (!availableDimensions) {
34
+ availableDimensions = COMMON_DIMENSIONS.includes(defaultDimension)
35
+ ? COMMON_DIMENSIONS
36
+ : [...COMMON_DIMENSIONS, defaultDimension].sort((a, b) => a - b);
37
+ }
38
+
39
+ const isChangeable = true; // Always allow the user to select the dimension
40
+
41
+ const [dimension, setDimension] = useState(defaultDimension);
42
+
21
43
  const addFiles = (files: File[]) => {
22
44
  const newStates = files.map(file => ({ file, status: 'idle' as const }));
23
45
  setFileStates(prev => [...prev, ...newStates]);
@@ -60,6 +82,7 @@ export function DocumentUpload({ namespace, onUploadComplete, className = '' }:
60
82
  const formData = new FormData();
61
83
  idleFiles.forEach(s => formData.append('files', s.file));
62
84
  if (namespace) formData.append('namespace', namespace);
85
+ formData.append('dimension', dimension.toString());
63
86
 
64
87
  try {
65
88
  const response = await fetch('/api/upload', {
@@ -125,6 +148,26 @@ export function DocumentUpload({ namespace, onUploadComplete, className = '' }:
125
148
  className="hidden"
126
149
  accept=".pdf,.docx,.txt,.md,.json,.csv"
127
150
  />
151
+
152
+ <div className="mt-6 flex flex-col items-center gap-2 text-sm">
153
+ <label className="text-slate-600 dark:text-white/60 font-medium">Embedding Dimension</label>
154
+ {isChangeable ? (
155
+ <select
156
+ value={dimension}
157
+ onChange={(e) => setDimension(Number(e.target.value))}
158
+ disabled={isUploading}
159
+ className="px-3 py-1.5 rounded-lg bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-800 dark:text-white/90 outline-none focus:border-emerald-500 transition-colors"
160
+ >
161
+ {availableDimensions.map(dim => (
162
+ <option key={dim} value={dim} className="bg-white dark:bg-slate-900">{dim}</option>
163
+ ))}
164
+ </select>
165
+ ) : (
166
+ <div className="px-3 py-1.5 rounded-lg bg-slate-100 dark:bg-white/10 border border-slate-200 dark:border-white/10 text-slate-500 dark:text-white/50 cursor-not-allowed text-xs">
167
+ {dimension} (Fixed for {currentModel})
168
+ </div>
169
+ )}
170
+ </div>
128
171
  </div>
129
172
 
130
173
  {fileStates.length > 0 && (
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { FileText, Zap, Package, ExternalLink } from 'lucide-react';
5
+ import { DocViewer } from '@/components/DocViewer';
6
+ import { LANDING_PAGE_CONTENT, QUICK_START_STEPS, API_ENDPOINTS, SNIPPETS } from '@/app/constants';
7
+ import { Snippet } from '@/app/types';
8
+
9
+ export function Documentation() {
10
+ const [activeSnippet, setActiveSnippet] = React.useState<Snippet>(SNIPPETS[0]);
11
+
12
+ return (
13
+ <div className="mt-32 max-w-6xl mx-auto mb-24 relative">
14
+ <div className="text-center mb-16">
15
+ <h2 className="text-3xl font-bold text-slate-900 dark:text-white mb-4">{LANDING_PAGE_CONTENT.guide.title}</h2>
16
+ <p className="text-slate-600 dark:text-white/40 max-w-2xl mx-auto">{LANDING_PAGE_CONTENT.guide.subtitle}</p>
17
+ </div>
18
+ <div className="relative z-10 w-full grid gap-16 lg:grid-cols-[280px_1fr] items-start">
19
+ <aside className="flex flex-col gap-10">
20
+ <section>
21
+ <h2 className="mb-6 text-[10px] font-black text-slate-400 dark:text-white/30 uppercase tracking-[0.3em] flex items-center gap-3">
22
+ <FileText size={14} className="text-indigo-500" /> Quick Start
23
+ </h2>
24
+ <ol className="space-y-6">
25
+ {QUICK_START_STEPS.map((step, i) => (
26
+ <li key={i} className="group flex items-start gap-4">
27
+ <span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-white dark:bg-white/5 text-slate-600 dark:text-white/40 font-mono text-[10px] border border-slate-200 dark:border-white/10 shadow-sm">{i + 1}</span>
28
+ <span className="text-xs text-slate-500 dark:text-white/50 font-medium leading-relaxed pt-1">{step}</span>
29
+ </li>
30
+ ))}
31
+ </ol>
32
+ </section>
33
+ <section className="rounded-2xl border border-slate-200 dark:border-white/10 bg-white dark:bg-white/3 p-6 shadow-sm">
34
+ <h2 className="mb-6 text-[10px] font-black text-slate-400 dark:text-white/30 uppercase tracking-[0.3em] flex items-center gap-3">
35
+ <Zap size={14} className="text-indigo-500" /> API Endpoints
36
+ </h2>
37
+ <div className="grid gap-2.5">
38
+ {API_ENDPOINTS.map((slug) => (
39
+ <div key={slug} className="group flex items-center justify-between p-2 rounded-lg bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/5 hover:border-indigo-200 dark:hover:border-indigo-500/30">
40
+ <span className="text-[10px] font-mono text-slate-500 dark:text-white/30 group-hover:text-indigo-600">/api/{slug}</span>
41
+ <span className="text-[8px] font-bold text-indigo-600 dark:text-indigo-400 bg-indigo-50 dark:bg-indigo-500/10 px-1.5 py-0.5 rounded border border-indigo-100 dark:border-indigo-500/20">POST</span>
42
+ </div>
43
+ ))}
44
+ </div>
45
+ </section>
46
+ </aside>
47
+ <section className="flex flex-col h-full min-h-[560px]">
48
+ <DocViewer activeSnippet={activeSnippet} setActiveSnippet={setActiveSnippet} />
49
+ </section>
50
+ </div>
51
+ <div className="mt-16 text-center">
52
+ <a href="https://www.npmjs.com/package/@retrivora-ai/rag-engine" className="inline-flex items-center gap-3 px-8 py-4 rounded-2xl bg-slate-900 dark:bg-white text-white dark:text-slate-900 font-bold shadow-xl shadow-indigo-500/20">
53
+ <Package className="w-5 h-5" /> Get Started on NPM <ExternalLink className="w-4 h-4" />
54
+ </a>
55
+ </div>
56
+ </div>
57
+ );
58
+ }
@@ -20,18 +20,22 @@ interface DynamicChartProps {
20
20
  primaryColor?: string;
21
21
  accentColor?: string;
22
22
  viewportSize?: ChatViewportSize;
23
+ /** When true, renders a shimmer skeleton instead of the chart. */
24
+ isStreaming?: boolean;
23
25
  }
24
26
 
25
- const DEFAULT_COLORS = ['#6366f1', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899'];
27
+ /** Shared palette imported by VisualizationRenderer to avoid duplication. */
28
+ export const CHART_COLORS = ['#6366f1', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899'];
26
29
 
27
30
  export function DynamicChart({
28
31
  config,
29
32
  primaryColor = '#6366f1',
30
33
  accentColor = '#8b5cf6',
31
34
  viewportSize = 'large',
35
+ isStreaming = false,
32
36
  }: DynamicChartProps) {
33
37
  const { type, data } = config;
34
- const colors = config.colors || [primaryColor, accentColor, ...DEFAULT_COLORS];
38
+ const colors = config.colors || [primaryColor, accentColor, ...CHART_COLORS];
35
39
  const containerRef = React.useRef<HTMLDivElement>(null);
36
40
  const [containerWidth, setContainerWidth] = React.useState(0);
37
41
 
@@ -111,6 +115,27 @@ export function DynamicChart({
111
115
  });
112
116
  }, [data]);
113
117
 
118
+ if (isStreaming) {
119
+ const bars = type === 'pie' ? 6 : 5;
120
+ return (
121
+ <div className="w-full mt-4 mb-2 animate-pulse">
122
+ {type === 'pie' ? (
123
+ <div className="mx-auto w-40 h-40 rounded-full bg-slate-100 dark:bg-white/10" />
124
+ ) : (
125
+ <div className="flex items-end gap-2 h-32 px-2">
126
+ {Array.from({ length: bars }).map((_, i) => (
127
+ <div
128
+ key={i}
129
+ className="flex-1 rounded-t-md bg-slate-100 dark:bg-white/10"
130
+ style={{ height: `${40 + (i % 3) * 25}%` }}
131
+ />
132
+ ))}
133
+ </div>
134
+ )}
135
+ </div>
136
+ );
137
+ }
138
+
114
139
  if (!data || data.length === 0) {
115
140
  return <div className="p-4 text-sm text-slate-500">No data available for chart.</div>;
116
141
  }
@@ -0,0 +1,59 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { useConfig } from '@/components/ConfigProvider';
5
+ import { ChatWindow } from '@/components/ChatWindow';
6
+ import { LANDING_PAGE_CONTENT, VECTOR_DATABASES, AI_MODELS } from '@/app/constants';
7
+
8
+ export function Hero() {
9
+ const { ui } = useConfig();
10
+
11
+ return (
12
+ <div className="grid lg:grid-cols-2 gap-12 items-start">
13
+ <div className="flex flex-col gap-6 pt-4">
14
+ <div
15
+ className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-medium border w-fit"
16
+ style={{ borderColor: `${ui.primaryColor}40`, color: ui.primaryColor, background: `${ui.primaryColor}10` }}
17
+ >
18
+ <span className="w-1.5 h-1.5 rounded-full animate-pulse" style={{ background: ui.primaryColor }} />
19
+ {LANDING_PAGE_CONTENT.hero.badge}
20
+ </div>
21
+ <h1 className="text-5xl md:text-7xl font-black text-slate-900 dark:text-white mb-6 tracking-tight">
22
+ {LANDING_PAGE_CONTENT.hero.title.split('for')[0]} <br />
23
+ <span className="text-transparent bg-clip-text" style={{ backgroundImage: `linear-gradient(to right, ${ui.primaryColor}, ${ui.accentColor})` }}>
24
+ for {LANDING_PAGE_CONTENT.hero.title.split('for')[1]}
25
+ </span>
26
+ </h1>
27
+ <p className="text-lg md:text-xl text-slate-600 dark:text-white/40 max-w-2xl leading-relaxed">
28
+ {LANDING_PAGE_CONTENT.hero.subtitle}
29
+ </p>
30
+ <div className="flex flex-col gap-4 mt-4">
31
+ <div className="flex flex-col gap-2">
32
+ <span className="text-[10px] font-black text-slate-400 dark:text-white/30 uppercase tracking-[0.2em] ml-1">Vector Ecosystem</span>
33
+ <div className="flex flex-wrap gap-2">
34
+ {VECTOR_DATABASES.map(({ Icon, label }) => (
35
+ <span key={label} className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/60 text-[11px] font-semibold hover:bg-slate-50 dark:hover:bg-white/8 transition-all shadow-sm group">
36
+ <Icon className="w-3 h-3 transition-transform group-hover:scale-110" style={{ color: ui.primaryColor }} /> {label}
37
+ </span>
38
+ ))}
39
+ </div>
40
+ </div>
41
+
42
+ <div className="flex flex-col gap-2">
43
+ <span className="text-[10px] font-black text-slate-400 dark:text-white/30 uppercase tracking-[0.2em] ml-1">AI Model Garden</span>
44
+ <div className="flex flex-wrap gap-2">
45
+ {AI_MODELS.map(({ Icon, label }) => (
46
+ <span key={label} className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/60 text-[11px] font-semibold hover:bg-slate-50 dark:hover:bg-white/8 transition-all shadow-sm group">
47
+ <Icon className="w-3 h-3 transition-transform group-hover:scale-110" style={{ color: ui.accentColor }} /> {label}
48
+ </span>
49
+ ))}
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <div className="lg:sticky lg:top-6 h-[calc(100vh-3rem)] min-h-[500px] max-h-[800px]">
55
+ <ChatWindow className="w-full h-full" />
56
+ </div>
57
+ </div>
58
+ );
59
+ }
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+
3
+ interface HourglassLoaderProps {
4
+ size?: number;
5
+ primaryColor?: string;
6
+ accentColor?: string;
7
+ glow?: boolean;
8
+ }
9
+
10
+ const HourglassLoader: React.FC<HourglassLoaderProps> = ({
11
+ size = 16,
12
+ primaryColor = '#10b981',
13
+ glow = false,
14
+ }) => {
15
+ return (
16
+ <svg
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ viewBox="0 0 100 100"
19
+ preserveAspectRatio="xMidYMid"
20
+ style={{
21
+ width: size,
22
+ height: size,
23
+ background: 'transparent',
24
+ filter: glow ? `drop-shadow(0 0 4px ${primaryColor})` : 'none',
25
+ }}
26
+ >
27
+ <g>
28
+ {/* Rotation Animation */}
29
+ <animateTransform
30
+ attributeName="transform"
31
+ type="rotate"
32
+ calcMode="spline"
33
+ values="0 50 50; 0 50 50; 180 50 50"
34
+ keyTimes="0; 0.8; 1"
35
+ keySplines="0 0 1 1; 0.4 0 0.2 1"
36
+ dur="2s"
37
+ repeatCount="indefinite"
38
+ />
39
+
40
+ {/* Glass Outline */}
41
+ <path
42
+ d="M 25 15 L 75 15 L 75 20 L 55 50 L 75 80 L 75 85 L 25 85 L 25 80 L 45 50 L 25 20 Z"
43
+ fill="none"
44
+ stroke={primaryColor}
45
+ strokeWidth="5"
46
+ strokeLinejoin="round"
47
+ strokeLinecap="round"
48
+ />
49
+
50
+ {/* Top Sand */}
51
+ <path fill={primaryColor}>
52
+ <animate
53
+ attributeName="d"
54
+ values="M 30 20 L 70 20 L 50 50 L 50 50 Z; M 50 50 L 50 50 L 50 50 L 50 50 Z; M 50 50 L 50 50 L 50 50 L 50 50 Z"
55
+ keyTimes="0; 0.8; 1"
56
+ dur="2s"
57
+ repeatCount="indefinite"
58
+ />
59
+ </path>
60
+
61
+ {/* Bottom Sand */}
62
+ <path fill={primaryColor}>
63
+ <animate
64
+ attributeName="d"
65
+ values="M 30 80 L 70 80 L 70 80 L 30 80 Z; M 30 80 L 70 80 L 50 50 L 50 50 Z; M 30 80 L 70 80 L 50 50 L 50 50 Z"
66
+ keyTimes="0; 0.8; 1"
67
+ dur="2s"
68
+ repeatCount="indefinite"
69
+ />
70
+ </path>
71
+
72
+ {/* Falling Sand Stream */}
73
+ <line x1="50" y1="50" x2="50" y2="80" stroke={primaryColor} strokeWidth="3">
74
+ <animate
75
+ attributeName="opacity"
76
+ values="0; 1; 1; 0; 0"
77
+ keyTimes="0; 0.1; 0.7; 0.8; 1"
78
+ dur="2s"
79
+ repeatCount="indefinite"
80
+ />
81
+ </line>
82
+ </g>
83
+ </svg>
84
+ );
85
+ };
86
+
87
+ export default HourglassLoader;
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { LANDING_PAGE_CONTENT, PIPELINE_STEPS } from '@/app/constants';
5
+
6
+ export function Lifecycle() {
7
+ return (
8
+ <div className="mt-24 mb-12">
9
+ <h2 className="text-2xl font-bold text-slate-900 dark:text-white text-center mb-2">{LANDING_PAGE_CONTENT.lifecycle.title}</h2>
10
+ <div className="relative max-w-5xl mx-auto py-12">
11
+ <div className="absolute left-1/2 top-0 bottom-0 w-0.5 bg-slate-200 dark:bg-white/10 -translate-x-1/2 hidden md:block" />
12
+ <div className="space-y-12 md:space-y-0">
13
+ {PIPELINE_STEPS.map(({ step, Icon, title, desc, colors }, index) => {
14
+ const isLeft = index % 2 === 0;
15
+ return (
16
+ <div key={step} className={`relative flex flex-col md:flex-row items-center gap-8 ${isLeft ? 'md:flex-row' : 'md:flex-row-reverse'}`}>
17
+ <div className={`w-full md:w-1/2 relative flex ${isLeft ? 'justify-end' : 'justify-start'}`}>
18
+ <div className="relative p-6 rounded-2xl border border-slate-200 dark:border-white/10 bg-white dark:bg-white/3 max-w-md text-left overflow-hidden group">
19
+ <div className="absolute -right-2 -bottom-4 text-7xl font-bold opacity-[0.1] italic" style={{ color: colors.from }}>{step}</div>
20
+ <h3 className="font-semibold text-slate-900 dark:text-white mb-2 text-lg flex items-center gap-2">
21
+ <Icon className="w-5 h-5" style={{ color: colors.from }} /> {title}
22
+ </h3>
23
+ <p className="text-slate-600 dark:text-white/40 text-sm leading-relaxed">{desc}</p>
24
+ </div>
25
+ </div>
26
+ <div className="relative z-10 w-12 h-12 rounded-2xl flex items-center justify-center shadow-xl border-4 border-slate-50 dark:border-[#080811]" style={{ background: `linear-gradient(135deg, ${colors.from}, ${colors.to})` }}>
27
+ <Icon className="w-6 h-6 text-white" />
28
+ </div>
29
+ <div className="hidden md:block md:w-1/2" />
30
+ </div>
31
+ );
32
+ })}
33
+ </div>
34
+ </div>
35
+ </div>
36
+ );
37
+ }
@@ -0,0 +1,143 @@
1
+ import React from 'react';
2
+ import { Components } from 'react-markdown';
3
+ import { UIDispatcher } from './UIDispatcher';
4
+ import { Product } from '../types';
5
+ import { ChatViewportSize } from '../types/props';
6
+
7
+ interface MarkdownComponentsProps {
8
+ primaryColor: string;
9
+ accentColor: string;
10
+ isStreaming: boolean;
11
+ onAddToCart?: (product: Product) => void;
12
+ viewportSize: ChatViewportSize;
13
+ }
14
+
15
+ export function createMarkdownComponents({
16
+ primaryColor,
17
+ accentColor,
18
+ isStreaming,
19
+ onAddToCart,
20
+ viewportSize,
21
+ }: MarkdownComponentsProps): Components {
22
+ return {
23
+ p: ({ ...props }: React.HTMLAttributes<HTMLParagraphElement>) => (
24
+ <p className="whitespace-pre-line" {...props} />
25
+ ),
26
+ table: ({ ...props }: React.HTMLAttributes<HTMLTableElement>) => {
27
+ // Fix: intercept table rendering during streaming instead of using sentinel
28
+ if (isStreaming) {
29
+ return (
30
+ <div className="my-5 p-6 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex items-center justify-center gap-3 select-none">
31
+ <div className="w-4 h-4 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" />
32
+ <p className="text-xs text-slate-500 font-medium italic animate-pulse">
33
+ Generating data table...
34
+ </p>
35
+ </div>
36
+ );
37
+ }
38
+
39
+ return (
40
+ <div className="not-prose overflow-hidden my-5 rounded-xl border border-slate-200 dark:border-white/10 shadow-sm bg-white dark:bg-slate-900/50">
41
+ <div className="overflow-x-auto">
42
+ <table
43
+ className="!table w-full text-left border-collapse min-w-[400px] text-sm"
44
+ {...props}
45
+ />
46
+ </div>
47
+ </div>
48
+ );
49
+ },
50
+ thead: ({ ...props }: React.HTMLAttributes<HTMLTableSectionElement>) => (
51
+ <thead
52
+ className="!table-header-group bg-slate-50 dark:bg-white/5 border-b border-slate-200 dark:border-white/10"
53
+ {...props}
54
+ />
55
+ ),
56
+ tbody: ({ ...props }: React.HTMLAttributes<HTMLTableSectionElement>) => (
57
+ <tbody className="!table-row-group divide-y divide-slate-100 dark:divide-white/5" {...props} />
58
+ ),
59
+ tr: ({ ...props }: React.HTMLAttributes<HTMLTableRowElement>) => (
60
+ <tr
61
+ className="!table-row hover:bg-slate-50/70 dark:hover:bg-white/5 transition-colors"
62
+ {...props}
63
+ />
64
+ ),
65
+ th: ({ children, ...props }: React.ThHTMLAttributes<HTMLTableCellElement>) => (
66
+ <th
67
+ className="!table-cell px-4 py-3 font-bold text-slate-700 dark:text-white/90 whitespace-nowrap text-[11px] uppercase tracking-wider text-left"
68
+ {...props}
69
+ >
70
+ {normaliseChild(children)}
71
+ </th>
72
+ ),
73
+ td: ({ children, ...props }: React.TdHTMLAttributes<HTMLTableCellElement>) => (
74
+ <td
75
+ className="!table-cell px-4 py-3 text-slate-600 dark:text-white/70 whitespace-nowrap text-sm"
76
+ {...props}
77
+ >
78
+ {normaliseChild(children)}
79
+ </td>
80
+ ),
81
+ code({
82
+ inline,
83
+ className,
84
+ children,
85
+ ...props
86
+ }: React.HTMLAttributes<HTMLElement> & { inline?: boolean }) {
87
+ const lang = /language-(\w+)/.exec(className ?? '')?.[1];
88
+
89
+ if (!inline && (lang === 'ui' || lang === 'chart' || lang === 'json')) {
90
+ const content = String(children ?? '').trim();
91
+ // Since we extract pure components, UIDispatcher handles these formats
92
+ return (
93
+ <UIDispatcher
94
+ rawContent={content}
95
+ primaryColor={primaryColor}
96
+ accentColor={accentColor}
97
+ isStreaming={isStreaming}
98
+ onAddToCart={onAddToCart}
99
+ viewportSize={viewportSize}
100
+ />
101
+ );
102
+ }
103
+
104
+ if (!inline) {
105
+ const content = String(children ?? '').trim();
106
+ // Fallback catch for json payload without lang block
107
+ if (content.startsWith('{') && content.endsWith('}')) {
108
+ return (
109
+ <UIDispatcher
110
+ rawContent={content}
111
+ primaryColor={primaryColor}
112
+ accentColor={accentColor}
113
+ isStreaming={isStreaming}
114
+ onAddToCart={onAddToCart}
115
+ viewportSize={viewportSize}
116
+ />
117
+ );
118
+ }
119
+ }
120
+
121
+ return (
122
+ <code className={className} {...props}>
123
+ {typeof children === 'string' || typeof children === 'number'
124
+ ? children
125
+ : JSON.stringify(children)}
126
+ </code>
127
+ );
128
+ },
129
+ };
130
+ }
131
+
132
+ /** Safely render table cell children that might be plain objects. */
133
+ function normaliseChild(children: unknown): React.ReactNode {
134
+ if (
135
+ typeof children === 'object' &&
136
+ children !== null &&
137
+ !Array.isArray(children) &&
138
+ !React.isValidElement(children)
139
+ ) {
140
+ return JSON.stringify(children);
141
+ }
142
+ return children as React.ReactNode;
143
+ }