@retrivora-ai/rag-engine 1.9.7 → 1.9.9
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.
- package/README.md +136 -136
- package/dist/{ILLMProvider-Bhk6zJOK.d.mts → ILLMProvider-DMxLyTdq.d.mts} +59 -4
- package/dist/{ILLMProvider-Bhk6zJOK.d.ts → ILLMProvider-DMxLyTdq.d.ts} +59 -4
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +2327 -474
- package/dist/handlers/index.mjs +2329 -473
- package/dist/{index-B9J_XEh0.d.ts → index-CfkqZd2Y.d.ts} +12 -2
- package/dist/{index-C3SVtPYg.d.mts → index-DXd29KMq.d.mts} +27 -52
- package/dist/{index-Bu7T6xgr.d.ts → index-D_bOdJML.d.ts} +27 -52
- package/dist/{index-BJ4cd-t5.d.mts → index-xygonxpW.d.mts} +12 -2
- package/dist/index.css +783 -550
- package/dist/index.d.mts +35 -7
- package/dist/index.d.ts +35 -7
- package/dist/index.js +419 -282
- package/dist/index.mjs +426 -292
- package/dist/server.d.mts +65 -6
- package/dist/server.d.ts +65 -6
- package/dist/server.js +2185 -317
- package/dist/server.mjs +2185 -317
- package/package.json +13 -8
- package/src/app/constants.tsx +37 -7
- package/src/app/page.tsx +2 -0
- package/src/components/ChatWidget.tsx +2 -1
- package/src/components/ChatWindow.tsx +4 -1
- package/src/components/CodeViewer.tsx +19 -14
- package/src/components/MarkdownComponents.tsx +44 -1
- package/src/components/MessageBubble.tsx +162 -50
- package/src/components/constants.tsx +228 -0
- package/src/config/RagConfig.ts +48 -2
- package/src/config/constants.ts +4 -0
- package/src/config/serverConfig.ts +15 -0
- package/src/core/ConfigResolver.ts +38 -6
- package/src/core/DatabaseStorage.ts +469 -0
- package/src/core/LicenseVerifier.ts +260 -0
- package/src/core/MultiAgentCoordinator.ts +239 -0
- package/src/core/Pipeline.ts +151 -18
- package/src/core/Retrivora.ts +7 -0
- package/src/core/VectorPlugin.ts +12 -3
- package/src/core/mcp.ts +261 -0
- package/src/handlers/index.ts +449 -63
- package/src/hooks/useRagChat.ts +96 -42
- package/src/hooks/useStoredMessages.ts +15 -4
- package/src/index.ts +3 -0
- package/src/llm/LLMFactory.ts +9 -1
- package/src/llm/providers/GroqProvider.ts +176 -0
- package/src/llm/providers/QwenProvider.ts +191 -0
- package/src/server.ts +7 -0
- package/src/types/chat.ts +14 -0
- package/src/types/props.ts +12 -0
- package/.env.example +0 -80
- package/LICENSE.txt +0 -21
- package/src/components/AmbientBackground.tsx +0 -29
- package/src/components/ArchitectureCard.tsx +0 -17
- package/src/components/ArchitectureCardsSection.tsx +0 -15
- package/src/components/DocViewer.tsx +0 -103
- package/src/components/Documentation.tsx +0 -121
- package/src/components/Hero.tsx +0 -59
- package/src/components/Lifecycle.tsx +0 -37
- package/src/components/Navbar.tsx +0 -55
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.9",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"rag",
|
|
9
9
|
"retrieval-augmented-generation",
|
|
@@ -72,16 +72,21 @@
|
|
|
72
72
|
"README.md"
|
|
73
73
|
],
|
|
74
74
|
"scripts": {
|
|
75
|
-
"dev": "next
|
|
76
|
-
"build": "
|
|
75
|
+
"dev": "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --watch --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style",
|
|
76
|
+
"build": "npm run build:pkg",
|
|
77
77
|
"build:pkg": "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --no-splitting --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.css && rm src/index.css",
|
|
78
|
-
"start": "next start",
|
|
79
78
|
"lint": "eslint",
|
|
80
|
-
"
|
|
79
|
+
"clean": "rm -rf dist"
|
|
81
80
|
},
|
|
82
81
|
"peerDependencies": {
|
|
83
82
|
"react": ">=18.0.0",
|
|
84
|
-
"react-dom": ">=18.0.0"
|
|
83
|
+
"react-dom": ">=18.0.0",
|
|
84
|
+
"next": ">=15.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"next": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
85
90
|
},
|
|
86
91
|
"dependencies": {
|
|
87
92
|
"@anthropic-ai/sdk": "^0.95.1",
|
|
@@ -91,7 +96,6 @@
|
|
|
91
96
|
"@types/papaparse": "^5.5.2",
|
|
92
97
|
"axios": "^1.15.0",
|
|
93
98
|
"lucide-react": "^1.8.0",
|
|
94
|
-
"next": "^16.2.6",
|
|
95
99
|
"next-themes": "^0.4.6",
|
|
96
100
|
"openai": "^6.34.0",
|
|
97
101
|
"papaparse": "^5.5.3",
|
|
@@ -122,6 +126,7 @@
|
|
|
122
126
|
"dotenv": "^17.4.2",
|
|
123
127
|
"eslint": "^9",
|
|
124
128
|
"eslint-config-next": "16.2.4",
|
|
129
|
+
"next": "16.2.10",
|
|
125
130
|
"tailwindcss": "^4",
|
|
126
131
|
"tsup": "^8.5.1",
|
|
127
132
|
"typescript": "^5"
|
package/src/app/constants.tsx
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
FileText,
|
|
18
18
|
Puzzle,
|
|
19
19
|
MessageSquare,
|
|
20
|
+
Cpu,
|
|
21
|
+
Cloud,
|
|
20
22
|
} from 'lucide-react';
|
|
21
23
|
import { ArchitectureCardProps, Snippet, PipelineStep, ProviderPill } from './types';
|
|
22
24
|
|
|
@@ -51,6 +53,8 @@ export const AI_MODELS: ProviderPill[] = [
|
|
|
51
53
|
{ Icon: Sparkles, label: 'OpenAI' },
|
|
52
54
|
{ Icon: Bot, label: 'Anthropic' },
|
|
53
55
|
{ Icon: Brain, label: 'Gemini' },
|
|
56
|
+
{ Icon: Cpu, label: 'Groq' },
|
|
57
|
+
{ Icon: Cloud, label: 'Qwen' },
|
|
54
58
|
{ Icon: Code, label: 'Copilot' },
|
|
55
59
|
{ Icon: Terminal, label: 'LiteLLM' },
|
|
56
60
|
];
|
|
@@ -130,23 +134,49 @@ const { reply, sources } = await pipeline.ask('How does Retrivora work?');`,
|
|
|
130
134
|
id: 'handlers',
|
|
131
135
|
title: 'Route Handlers',
|
|
132
136
|
language: 'typescript',
|
|
133
|
-
description: '
|
|
134
|
-
code: `//
|
|
135
|
-
|
|
137
|
+
description: 'Mount pre-built API endpoints. Configuration is automatically read from environment variables, or can be passed explicitly.',
|
|
138
|
+
code: `// ─── OPTION A: ZERO CONFIG (Reads from environment variables) ───
|
|
139
|
+
// src/app/api/chat/route.ts
|
|
140
|
+
import { createStreamHandler } from '@retrivora-ai/rag-engine/handlers';
|
|
141
|
+
export const POST = createStreamHandler();
|
|
142
|
+
|
|
143
|
+
// ─── OPTION B: EXPLICIT CONFIGURATION ───
|
|
144
|
+
// src/app/api/chat/route.ts
|
|
145
|
+
import { createStreamHandler } from '@retrivora-ai/rag-engine/handlers';
|
|
136
146
|
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
export const POST = createStreamHandler({
|
|
148
|
+
vectorDb: {
|
|
149
|
+
provider: 'pinecone',
|
|
150
|
+
apiKey: process.env.CUSTOM_PINECONE_KEY,
|
|
151
|
+
indexName: 'docs-index',
|
|
152
|
+
},
|
|
153
|
+
llm: {
|
|
154
|
+
provider: 'openai',
|
|
155
|
+
apiKey: process.env.CUSTOM_OPENAI_KEY,
|
|
156
|
+
model: 'gpt-4o',
|
|
157
|
+
}
|
|
158
|
+
});`,
|
|
139
159
|
},
|
|
140
160
|
{
|
|
141
161
|
id: 'ui',
|
|
142
162
|
title: 'React Components',
|
|
143
163
|
language: 'typescript',
|
|
144
|
-
description: '
|
|
164
|
+
description: 'Configure and embed themeable UI widgets using the ConfigProvider context.',
|
|
145
165
|
code: `import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';
|
|
146
166
|
|
|
147
167
|
export default function Layout({ children }) {
|
|
148
168
|
return (
|
|
149
|
-
<ConfigProvider config={{
|
|
169
|
+
<ConfigProvider config={{
|
|
170
|
+
projectId: 'my-project-id',
|
|
171
|
+
ui: {
|
|
172
|
+
title: 'Retrivora Assistant',
|
|
173
|
+
welcomeMessage: 'Hi! Ask me anything about our software.',
|
|
174
|
+
primaryColor: '#4f46e5', // Custom primary brand color
|
|
175
|
+
accentColor: '#8b5cf6', // Custom accent gradient color
|
|
176
|
+
borderRadius: 'lg', // 'none' | 'sm' | 'md' | 'lg' | 'xl'
|
|
177
|
+
allowUpload: true, // Toggle custom file uploading
|
|
178
|
+
}
|
|
179
|
+
}}>
|
|
150
180
|
{children}
|
|
151
181
|
<ChatWidget position="bottom-right" />
|
|
152
182
|
</ConfigProvider>
|
package/src/app/page.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { Navbar } from '@/components/Navbar';
|
|
|
6
6
|
import { Hero } from '@/components/Hero';
|
|
7
7
|
import { Lifecycle } from '@/components/Lifecycle';
|
|
8
8
|
import { ArchitectureCardsSection } from '@/components/ArchitectureCardsSection';
|
|
9
|
+
import { RagPatternsSection } from '@/components/RagPatternsSection';
|
|
9
10
|
import { Documentation } from '@/components/Documentation';
|
|
10
11
|
import { ChatWidget } from '@/components/ChatWidget';
|
|
11
12
|
|
|
@@ -17,6 +18,7 @@ export default function HomePage() {
|
|
|
17
18
|
<div className="relative z-10 container mx-auto px-6 py-12">
|
|
18
19
|
<Hero />
|
|
19
20
|
<Lifecycle />
|
|
21
|
+
<RagPatternsSection />
|
|
20
22
|
<ArchitectureCardsSection />
|
|
21
23
|
<Documentation />
|
|
22
24
|
</div>
|
|
@@ -46,7 +46,7 @@ const GEMINI_STYLES = `
|
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
|
|
49
|
-
export function ChatWidget({ position = 'bottom-right', onAddToCart, apiUrl, headers }: ChatWidgetProps) {
|
|
49
|
+
export function ChatWidget({ position = 'bottom-right', onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWidgetProps) {
|
|
50
50
|
const { ui } = useConfig();
|
|
51
51
|
const [isOpen, setIsOpen] = useState(false);
|
|
52
52
|
const [hasUnread, setHasUnread] = useState(false);
|
|
@@ -147,6 +147,7 @@ export function ChatWidget({ position = 'bottom-right', onAddToCart, apiUrl, hea
|
|
|
147
147
|
isMaximized={isMaximized}
|
|
148
148
|
onAddToCart={onAddToCart}
|
|
149
149
|
apiUrl={apiUrl}
|
|
150
|
+
retrivoraApiBase={retrivoraApiBase}
|
|
150
151
|
headers={headers}
|
|
151
152
|
/>
|
|
152
153
|
{/* Pointer (Tail) */}
|
|
@@ -64,6 +64,7 @@ export function ChatWindow({
|
|
|
64
64
|
isMaximized = false,
|
|
65
65
|
onAddToCart,
|
|
66
66
|
apiUrl,
|
|
67
|
+
retrivoraApiBase,
|
|
67
68
|
headers
|
|
68
69
|
}: ChatWindowProps) {
|
|
69
70
|
const { ui, projectId } = useConfig();
|
|
@@ -73,9 +74,10 @@ export function ChatWindow({
|
|
|
73
74
|
const windowRef = useRef<HTMLDivElement>(null);
|
|
74
75
|
const bottomRef = useRef<HTMLDivElement>(null);
|
|
75
76
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
76
|
-
const { messages, send, clear, isLoading, error, stop } = useRagChat(projectId, {
|
|
77
|
+
const { messages, send, clear, isLoading, error, stop, submitFeedback } = useRagChat(projectId, {
|
|
77
78
|
namespace: projectId,
|
|
78
79
|
apiUrl,
|
|
80
|
+
retrivoraApiBase,
|
|
79
81
|
headers,
|
|
80
82
|
});
|
|
81
83
|
|
|
@@ -376,6 +378,7 @@ export function ChatWindow({
|
|
|
376
378
|
accentColor={ui.accentColor}
|
|
377
379
|
onAddToCart={onAddToCart}
|
|
378
380
|
viewportSize={viewportSize}
|
|
381
|
+
onFeedback={submitFeedback}
|
|
379
382
|
/>
|
|
380
383
|
))
|
|
381
384
|
)}
|
|
@@ -14,35 +14,40 @@ export function CodeViewer({ snippet }: { snippet: Snippet }) {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<div className="flex flex-col
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
<div className="flex flex-col rounded-2xl border border-white/8 overflow-hidden min-h-[300px] shadow-xl">
|
|
18
|
+
{/* VS Code-style chrome header */}
|
|
19
|
+
<div className="flex items-center justify-between px-5 py-3 border-b border-white/5 bg-[#0d0d1a]">
|
|
20
|
+
<div className="flex items-center gap-4">
|
|
20
21
|
<div className="flex gap-1.5">
|
|
21
|
-
<div className="w-2.5 h-2.5 rounded-full bg-
|
|
22
|
-
<div className="w-2.5 h-2.5 rounded-full bg-
|
|
23
|
-
<div className="w-2.5 h-2.5 rounded-full bg-
|
|
22
|
+
<div className="w-2.5 h-2.5 rounded-full bg-rose-500/80" />
|
|
23
|
+
<div className="w-2.5 h-2.5 rounded-full bg-amber-500/80" />
|
|
24
|
+
<div className="w-2.5 h-2.5 rounded-full bg-emerald-500/80" />
|
|
24
25
|
</div>
|
|
25
|
-
<span className="text-[10px] font-mono text-
|
|
26
|
+
<span className="text-[10px] font-mono text-white/25 uppercase tracking-widest">
|
|
27
|
+
{snippet.language}
|
|
28
|
+
</span>
|
|
26
29
|
</div>
|
|
27
30
|
<button
|
|
28
31
|
onClick={handleCopy}
|
|
29
|
-
className="flex items-center gap-2 text-[10px] font-bold text-
|
|
32
|
+
className="flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[10px] font-bold text-white/35 hover:text-white/80 hover:bg-white/5 transition-all active:scale-95"
|
|
30
33
|
>
|
|
31
34
|
{copied ? (
|
|
32
35
|
<>
|
|
33
|
-
<Check size={
|
|
34
|
-
<span className="text-emerald-
|
|
36
|
+
<Check size={12} className="text-emerald-400" />
|
|
37
|
+
<span className="text-emerald-400">Copied!</span>
|
|
35
38
|
</>
|
|
36
39
|
) : (
|
|
37
40
|
<>
|
|
38
|
-
<Copy size={
|
|
39
|
-
|
|
41
|
+
<Copy size={12} />
|
|
42
|
+
Copy Code
|
|
40
43
|
</>
|
|
41
44
|
)}
|
|
42
45
|
</button>
|
|
43
46
|
</div>
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
|
|
48
|
+
{/* Code body */}
|
|
49
|
+
<div className="p-6 font-mono text-[12px] leading-relaxed overflow-auto flex-grow bg-[#080818]">
|
|
50
|
+
<pre className="whitespace-pre text-indigo-200/85">
|
|
46
51
|
<code>{snippet.code}</code>
|
|
47
52
|
</pre>
|
|
48
53
|
</div>
|
|
@@ -116,10 +116,11 @@ export function createMarkdownComponents({
|
|
|
116
116
|
/>
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
|
+
return <CodeBlock language={lang}>{content}</CodeBlock>;
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
return (
|
|
122
|
-
<code className=
|
|
123
|
+
<code className="px-1.5 py-0.5 rounded bg-slate-100 dark:bg-white/10 text-rose-600 dark:text-rose-400 font-mono text-[11px]" {...props}>
|
|
123
124
|
{typeof children === 'string' || typeof children === 'number'
|
|
124
125
|
? children
|
|
125
126
|
: JSON.stringify(children)}
|
|
@@ -129,6 +130,48 @@ export function createMarkdownComponents({
|
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
function CodeBlock({ children, language }: { children: string; language?: string }) {
|
|
134
|
+
const [copied, setCopied] = React.useState(false);
|
|
135
|
+
|
|
136
|
+
const handleCopy = async () => {
|
|
137
|
+
try {
|
|
138
|
+
await navigator.clipboard.writeText(children);
|
|
139
|
+
setCopied(true);
|
|
140
|
+
setTimeout(() => setCopied(false), 2000);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.warn('Failed to copy code', e);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<div className="not-prose my-4 rounded-xl border border-slate-200 dark:border-white/10 overflow-hidden bg-slate-900 text-slate-100 shadow-lg select-text">
|
|
148
|
+
<div className="flex items-center justify-between px-4 py-2 bg-slate-950 border-b border-slate-800 text-xs font-semibold text-slate-400 select-none">
|
|
149
|
+
<span className="font-mono lowercase">{language || 'code'}</span>
|
|
150
|
+
<button
|
|
151
|
+
onClick={handleCopy}
|
|
152
|
+
className="flex items-center gap-1.5 px-2 py-1 rounded hover:bg-slate-800 hover:text-slate-250 transition-colors cursor-pointer text-slate-400 border border-transparent hover:border-slate-800"
|
|
153
|
+
type="button"
|
|
154
|
+
>
|
|
155
|
+
{copied ? (
|
|
156
|
+
<>
|
|
157
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" className="text-emerald-500"><polyline points="20 6 9 17 4 12"/></svg>
|
|
158
|
+
<span className="text-emerald-500">Copied!</span>
|
|
159
|
+
</>
|
|
160
|
+
) : (
|
|
161
|
+
<>
|
|
162
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
|
163
|
+
<span>Copy</span>
|
|
164
|
+
</>
|
|
165
|
+
)}
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
<div className="p-4 overflow-x-auto font-mono text-[11px] leading-relaxed text-slate-200 bg-slate-900/90 whitespace-pre">
|
|
169
|
+
<code>{children}</code>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
132
175
|
/** Safely render table cell children that might be plain objects. */
|
|
133
176
|
function normaliseChild(children: unknown): React.ReactNode {
|
|
134
177
|
if (
|