@retrivora-ai/rag-engine 1.9.6 → 1.9.8
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 +130 -113
- package/dist/{ILLMProvider-DNhyOYoK.d.mts → ILLMProvider-B8ROITYK.d.mts} +59 -8
- package/dist/{ILLMProvider-DNhyOYoK.d.ts → ILLMProvider-B8ROITYK.d.ts} +59 -8
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +2376 -489
- package/dist/handlers/index.mjs +2372 -489
- package/dist/{index-CjQdL0cX.d.ts → index-B8PbEFSY.d.mts} +17 -3
- package/dist/{index-CHL1jdYm.d.mts → index-BCPKUAVL.d.ts} +33 -41
- package/dist/{index-Hgbwl9X4.d.ts → index-CrxCy36A.d.mts} +33 -41
- package/dist/{index-C9v7-tWd.d.mts → index-DNvoi-sV.d.ts} +17 -3
- package/dist/index.css +695 -203
- package/dist/index.d.mts +37 -7
- package/dist/index.d.ts +37 -7
- package/dist/index.js +1197 -286
- package/dist/index.mjs +1221 -297
- package/dist/server.d.mts +62 -6
- package/dist/server.d.ts +62 -6
- package/dist/server.js +2526 -574
- package/dist/server.mjs +2517 -573
- package/package.json +12 -10
- package/src/app/constants.tsx +207 -212
- package/src/app/layout.tsx +4 -28
- package/src/app/types.ts +17 -17
- package/src/components/AmbientBackground.tsx +10 -10
- package/src/components/ArchitectureCard.tsx +43 -7
- package/src/components/ArchitectureCardsSection.tsx +37 -4
- package/src/components/ChatWidget.tsx +4 -1
- package/src/components/ChatWindow.tsx +9 -2
- package/src/components/CodeViewer.tsx +19 -14
- package/src/components/DocViewer.tsx +75 -15
- package/src/components/Documentation.tsx +111 -28
- package/src/components/Hero.tsx +103 -20
- package/src/components/Lifecycle.tsx +65 -25
- package/src/components/MarkdownComponents.tsx +44 -1
- package/src/components/MessageBubble.tsx +162 -50
- package/src/components/constants.tsx +279 -0
- package/src/config/RagConfig.ts +56 -10
- package/src/config/constants.ts +5 -0
- package/src/config/serverConfig.ts +15 -0
- package/src/core/ConfigResolver.ts +30 -25
- package/src/core/DatabaseStorage.ts +469 -0
- package/src/core/LicenseVerifier.ts +154 -0
- package/src/core/MultiAgentCoordinator.ts +239 -0
- package/src/core/Pipeline.ts +148 -16
- package/src/core/ProviderRegistry.ts +5 -5
- package/src/core/Retrivora.ts +52 -6
- package/src/core/VectorPlugin.ts +74 -11
- package/src/core/mcp.ts +261 -0
- package/src/exceptions/index.ts +52 -0
- package/src/handlers/index.ts +504 -47
- package/src/hooks/useRagChat.ts +100 -43
- package/src/hooks/useStoredMessages.ts +15 -4
- package/src/index.ts +7 -0
- package/src/llm/LLMFactory.ts +15 -6
- package/src/llm/providers/GroqProvider.ts +176 -0
- package/src/llm/providers/QwenProvider.ts +191 -0
- package/src/server.ts +23 -13
- package/src/types/chat.ts +16 -0
- package/src/types/props.ts +50 -1
- package/.env.example +0 -80
- package/LICENSE.txt +0 -21
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qwen LLM Provider (via Alibaba DashScope / ModelStudio compatible mode)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import OpenAI from 'openai';
|
|
6
|
+
import { ILLMProvider, EmbedOptions } from '../ILLMProvider';
|
|
7
|
+
import { ChatMessage, ChatOptions } from '../../types';
|
|
8
|
+
import { LLMConfig, EmbeddingConfig } from '../../config/RagConfig';
|
|
9
|
+
import { IProviderValidator, IProviderHealthChecker, HealthCheckResult } from '../../core/ProviderInterfaces';
|
|
10
|
+
import { ValidationError } from '../../core/ConfigValidator';
|
|
11
|
+
import { buildSystemContent } from '../utils';
|
|
12
|
+
|
|
13
|
+
export class QwenProvider implements ILLMProvider {
|
|
14
|
+
private readonly client: OpenAI;
|
|
15
|
+
private readonly llmConfig: LLMConfig;
|
|
16
|
+
private readonly embeddingConfig?: EmbeddingConfig;
|
|
17
|
+
|
|
18
|
+
constructor(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig) {
|
|
19
|
+
const apiKey = llmConfig.apiKey || process.env.DASHSCOPE_API_KEY || process.env.QWEN_API_KEY;
|
|
20
|
+
if (!apiKey) throw new Error('[QwenProvider] llmConfig.apiKey, DASHSCOPE_API_KEY, or QWEN_API_KEY environment variable is required');
|
|
21
|
+
|
|
22
|
+
this.client = new OpenAI({
|
|
23
|
+
apiKey,
|
|
24
|
+
baseURL: llmConfig.baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
25
|
+
});
|
|
26
|
+
this.llmConfig = llmConfig;
|
|
27
|
+
this.embeddingConfig = embeddingConfig;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getValidator(): IProviderValidator {
|
|
31
|
+
return {
|
|
32
|
+
validate(config: Record<string, unknown>): ValidationError[] {
|
|
33
|
+
const errors: ValidationError[] = [];
|
|
34
|
+
const isEmbedding = config.provider === 'qwen' && 'dimensions' in config;
|
|
35
|
+
const prefix = isEmbedding ? 'embedding' : 'llm';
|
|
36
|
+
|
|
37
|
+
if (!config.apiKey && !process.env.DASHSCOPE_API_KEY && !process.env.QWEN_API_KEY) {
|
|
38
|
+
errors.push({
|
|
39
|
+
field: `${prefix}.apiKey`,
|
|
40
|
+
message: 'Qwen API key is required',
|
|
41
|
+
suggestion: 'Set DASHSCOPE_API_KEY or QWEN_API_KEY environment variable',
|
|
42
|
+
severity: 'error',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!config.model) {
|
|
46
|
+
errors.push({
|
|
47
|
+
field: `${prefix}.model`,
|
|
48
|
+
message: 'Qwen model name is required',
|
|
49
|
+
suggestion: isEmbedding ? 'e.g., "text-embedding-v3"' : 'e.g., "qwen-plus" or "qwen-max"',
|
|
50
|
+
severity: 'error',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return errors;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static getHealthChecker(): IProviderHealthChecker {
|
|
59
|
+
return {
|
|
60
|
+
async check(config: Record<string, unknown>): Promise<HealthCheckResult> {
|
|
61
|
+
const timestamp = Date.now();
|
|
62
|
+
const apiKey = (config.apiKey as string) || process.env.DASHSCOPE_API_KEY || process.env.QWEN_API_KEY || '';
|
|
63
|
+
const modelName = config.model as string;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const OpenAI = await import('openai');
|
|
67
|
+
const client = new OpenAI.default({
|
|
68
|
+
apiKey,
|
|
69
|
+
baseURL: (config.baseUrl as string) || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
70
|
+
});
|
|
71
|
+
const models = await client.models.list();
|
|
72
|
+
const hasModel = models.data.some((m) => m.id === modelName);
|
|
73
|
+
return {
|
|
74
|
+
healthy: true,
|
|
75
|
+
provider: 'qwen',
|
|
76
|
+
capabilities: { model: modelName, available: hasModel, totalModels: models.data.length },
|
|
77
|
+
timestamp,
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return {
|
|
81
|
+
healthy: false,
|
|
82
|
+
provider: 'qwen',
|
|
83
|
+
error: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
|
+
timestamp,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string> {
|
|
92
|
+
const basePrompt =
|
|
93
|
+
options?.systemPrompt ??
|
|
94
|
+
this.llmConfig.systemPrompt ??
|
|
95
|
+
'You are a helpful assistant. Answer questions based on the provided context.';
|
|
96
|
+
|
|
97
|
+
const systemMessage: OpenAI.Chat.ChatCompletionSystemMessageParam = {
|
|
98
|
+
role: 'system',
|
|
99
|
+
content: buildSystemContent(basePrompt, context),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const formattedMessages: OpenAI.Chat.ChatCompletionMessageParam[] = [
|
|
103
|
+
systemMessage,
|
|
104
|
+
...messages.map((m) => ({
|
|
105
|
+
role: m.role as 'user' | 'assistant',
|
|
106
|
+
content: m.content,
|
|
107
|
+
})),
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const completion = await this.client.chat.completions.create({
|
|
111
|
+
model: this.llmConfig.model,
|
|
112
|
+
messages: formattedMessages,
|
|
113
|
+
max_tokens: options?.maxTokens ?? this.llmConfig.maxTokens ?? 1024,
|
|
114
|
+
temperature: options?.temperature ?? this.llmConfig.temperature ?? 0.7,
|
|
115
|
+
stop: options?.stop,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return completion.choices[0]?.message?.content ?? '';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async *chatStream(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string> {
|
|
122
|
+
const basePrompt =
|
|
123
|
+
options?.systemPrompt ??
|
|
124
|
+
this.llmConfig.systemPrompt ??
|
|
125
|
+
'You are a helpful assistant. Answer questions based on the provided context.';
|
|
126
|
+
|
|
127
|
+
const systemMessage: OpenAI.Chat.ChatCompletionSystemMessageParam = {
|
|
128
|
+
role: 'system',
|
|
129
|
+
content: buildSystemContent(basePrompt, context),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const formattedMessages: OpenAI.Chat.ChatCompletionMessageParam[] = [
|
|
133
|
+
systemMessage,
|
|
134
|
+
...messages.map((m) => ({
|
|
135
|
+
role: m.role as 'user' | 'assistant',
|
|
136
|
+
content: m.content,
|
|
137
|
+
})),
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const stream = await this.client.chat.completions.create({
|
|
141
|
+
model: this.llmConfig.model,
|
|
142
|
+
messages: formattedMessages,
|
|
143
|
+
max_tokens: options?.maxTokens ?? this.llmConfig.maxTokens ?? 1024,
|
|
144
|
+
temperature: options?.temperature ?? this.llmConfig.temperature ?? 0.7,
|
|
145
|
+
stop: options?.stop,
|
|
146
|
+
stream: true,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (!stream) {
|
|
150
|
+
throw new Error('[QwenProvider] completions.create stream is undefined');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for await (const chunk of stream) {
|
|
154
|
+
const content = chunk.choices[0]?.delta?.content || '';
|
|
155
|
+
if (content) yield content;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async embed(text: string, options?: EmbedOptions): Promise<number[]> {
|
|
160
|
+
const results = await this.batchEmbed([text], options);
|
|
161
|
+
return results[0];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]> {
|
|
165
|
+
const model =
|
|
166
|
+
options?.model ??
|
|
167
|
+
this.embeddingConfig?.model ??
|
|
168
|
+
'text-embedding-v1';
|
|
169
|
+
|
|
170
|
+
const apiKey = this.embeddingConfig?.apiKey ?? this.llmConfig.apiKey;
|
|
171
|
+
const client = apiKey !== this.llmConfig.apiKey
|
|
172
|
+
? new OpenAI({
|
|
173
|
+
apiKey,
|
|
174
|
+
baseURL: this.embeddingConfig?.baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
175
|
+
})
|
|
176
|
+
: this.client;
|
|
177
|
+
|
|
178
|
+
const response = await client.embeddings.create({ model, input: texts });
|
|
179
|
+
return response.data.map((d) => d.embedding);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async ping(): Promise<boolean> {
|
|
183
|
+
try {
|
|
184
|
+
await this.client.models.list();
|
|
185
|
+
return true;
|
|
186
|
+
} catch (err) {
|
|
187
|
+
console.error('[QwenProvider] Ping failed:', err);
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -25,30 +25,20 @@ export type { ILLMProvider, EmbedOptions } from './llm/ILLMProvider';
|
|
|
25
25
|
export type { Chunk, ChunkOptions } from './rag/DocumentChunker';
|
|
26
26
|
export type { HealthCheckResult, IProviderValidator, IProviderHealthChecker } from './core/ProviderInterfaces';
|
|
27
27
|
export type { ValidationError } from './core/ConfigValidator';
|
|
28
|
+
export type { LicensePayload } from './core/LicenseVerifier';
|
|
28
29
|
export type { BatchOptions, BatchResult } from './core/BatchProcessor';
|
|
29
30
|
|
|
30
31
|
// ── Core Orchestration ─────────────────────────────────────────
|
|
31
|
-
export { VectorPlugin } from './core/VectorPlugin';
|
|
32
32
|
export { Retrivora } from './core/Retrivora';
|
|
33
|
+
export { VectorPlugin } from './core/VectorPlugin';
|
|
33
34
|
export { Pipeline } from './core/Pipeline';
|
|
34
35
|
export { ConfigResolver } from './core/ConfigResolver';
|
|
35
36
|
export { ProviderRegistry } from './core/ProviderRegistry';
|
|
36
37
|
export { ConfigValidator } from './core/ConfigValidator';
|
|
38
|
+
export { LicenseVerifier } from './core/LicenseVerifier';
|
|
37
39
|
export { ProviderHealthCheck } from './core/ProviderHealthCheck';
|
|
38
40
|
export { BatchProcessor } from './core/BatchProcessor';
|
|
39
41
|
|
|
40
|
-
// ── Exceptions ────────────────────────────────────────────────
|
|
41
|
-
export {
|
|
42
|
-
RetrivoraError,
|
|
43
|
-
ProviderNotFoundException,
|
|
44
|
-
EmbeddingFailedException,
|
|
45
|
-
RetrievalException,
|
|
46
|
-
RateLimitException,
|
|
47
|
-
ConfigurationException,
|
|
48
|
-
AuthenticationException,
|
|
49
|
-
} from './exceptions';
|
|
50
|
-
export type { RetrivoraErrorCode } from './exceptions';
|
|
51
|
-
|
|
52
42
|
// ── Configuration Helpers ──────────────────────────────────────
|
|
53
43
|
export { getRagConfig } from './config/serverConfig';
|
|
54
44
|
export { ConfigBuilder, PRESETS, createFromPreset } from './config/ConfigBuilder';
|
|
@@ -77,6 +67,8 @@ export { LLMFactory } from './llm/LLMFactory';
|
|
|
77
67
|
export { OpenAIProvider } from './llm/providers/OpenAIProvider';
|
|
78
68
|
export { AnthropicProvider } from './llm/providers/AnthropicProvider';
|
|
79
69
|
export { OllamaProvider } from './llm/providers/OllamaProvider';
|
|
70
|
+
export { GroqProvider } from './llm/providers/GroqProvider';
|
|
71
|
+
export { QwenProvider } from './llm/providers/QwenProvider';
|
|
80
72
|
export { UniversalLLMAdapter } from './llm/providers/UniversalLLMAdapter';
|
|
81
73
|
|
|
82
74
|
// ── Next.js Route Handler Factories ───────────────────────────
|
|
@@ -86,8 +78,26 @@ export {
|
|
|
86
78
|
createIngestHandler,
|
|
87
79
|
createHealthHandler,
|
|
88
80
|
createUploadHandler,
|
|
81
|
+
createHistoryHandler,
|
|
82
|
+
createFeedbackHandler,
|
|
83
|
+
createSessionsHandler,
|
|
84
|
+
createRagHandler,
|
|
89
85
|
sseFrame,
|
|
90
86
|
sseTextFrame,
|
|
91
87
|
sseMetaFrame,
|
|
92
88
|
sseErrorFrame,
|
|
93
89
|
} from './handlers';
|
|
90
|
+
|
|
91
|
+
// ── Exceptions ────────────────────────────────────────────────
|
|
92
|
+
export type { RetrivoraErrorCode } from './exceptions';
|
|
93
|
+
export {
|
|
94
|
+
RetrivoraError,
|
|
95
|
+
ProviderNotFoundException,
|
|
96
|
+
EmbeddingFailedException,
|
|
97
|
+
RetrievalException,
|
|
98
|
+
RateLimitException,
|
|
99
|
+
ConfigurationException,
|
|
100
|
+
AuthenticationException,
|
|
101
|
+
wrapError,
|
|
102
|
+
} from './exceptions';
|
|
103
|
+
|
package/src/types/chat.ts
CHANGED
|
@@ -41,6 +41,12 @@ export interface ChatOptions {
|
|
|
41
41
|
export interface UseRagChatOptions {
|
|
42
42
|
/** Override the chat API endpoint (default: /api/chat) */
|
|
43
43
|
apiUrl?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Base URL for the Retrivora SDK catch-all route used for history, feedback,
|
|
46
|
+
* and sessions endpoints. Defaults to '/api/retrivora'.
|
|
47
|
+
* e.g. if your catch-all is at /api/retrivora/[[...retrivora]], set this to '/api/retrivora'.
|
|
48
|
+
*/
|
|
49
|
+
retrivoraApiBase?: string;
|
|
44
50
|
/** Override project namespace */
|
|
45
51
|
namespace?: string;
|
|
46
52
|
/** Persist chat history to localStorage (default: true) */
|
|
@@ -49,6 +55,10 @@ export interface UseRagChatOptions {
|
|
|
49
55
|
onReply?: (message: RagMessage) => void;
|
|
50
56
|
/** Called on error */
|
|
51
57
|
onError?: (error: string) => void;
|
|
58
|
+
/** Optional custom headers to send with the chat request */
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
/** Session ID for history and feedback tracking (default: 'default') */
|
|
61
|
+
sessionId?: string;
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
export interface UseRagChatReturn {
|
|
@@ -68,4 +78,10 @@ export interface UseRagChatReturn {
|
|
|
68
78
|
setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
|
|
69
79
|
/** Abort the current active stream request */
|
|
70
80
|
stop: () => void;
|
|
81
|
+
/** Load message history from database storage */
|
|
82
|
+
loadHistory: (sessionId: string) => Promise<void>;
|
|
83
|
+
/** Clear conversation history from database and locally */
|
|
84
|
+
clearHistory: (sessionId: string) => Promise<void>;
|
|
85
|
+
/** Submit rating and optional comment for a specific assistant message */
|
|
86
|
+
submitFeedback: (messageId: string, rating: 'thumbs_up' | 'thumbs_down', comment?: string) => Promise<void>;
|
|
71
87
|
}
|
package/src/types/props.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties, MouseEvent } from 'react';
|
|
1
|
+
import { ReactNode, CSSProperties, MouseEvent, ElementType } from 'react';
|
|
2
2
|
import { Product, VectorMatch } from './index';
|
|
3
3
|
import { RagMessage } from './chat';
|
|
4
4
|
import { UIConfig } from '../config/RagConfig';
|
|
5
5
|
|
|
6
|
+
export interface ArchitectureCardProps {
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
badge: string;
|
|
11
|
+
badgeColor: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Snippet {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description: string;
|
|
18
|
+
code: string;
|
|
19
|
+
language: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PipelineStep {
|
|
23
|
+
step: string;
|
|
24
|
+
Icon: ElementType;
|
|
25
|
+
title: string;
|
|
26
|
+
desc: string;
|
|
27
|
+
colors: { from: string; to: string };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ProviderPill {
|
|
31
|
+
Icon: ElementType;
|
|
32
|
+
label: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
6
35
|
export type ChatViewportSize = 'compact' | 'medium' | 'large';
|
|
7
36
|
|
|
8
37
|
export interface ChatWindowProps {
|
|
@@ -26,6 +55,15 @@ export interface ChatWindowProps {
|
|
|
26
55
|
isMaximized?: boolean;
|
|
27
56
|
/** Called when the user clicks 'Add to Cart' on a product */
|
|
28
57
|
onAddToCart?: (product: Product) => void;
|
|
58
|
+
/** Optional custom API URL to send chat messages to */
|
|
59
|
+
apiUrl?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Base URL for Retrivora SDK history/feedback/sessions endpoints.
|
|
62
|
+
* Defaults to '/api/retrivora'. Set this to match your catch-all route location.
|
|
63
|
+
*/
|
|
64
|
+
retrivoraApiBase?: string;
|
|
65
|
+
/** Optional custom headers to send with the chat request */
|
|
66
|
+
headers?: Record<string, string>;
|
|
29
67
|
}
|
|
30
68
|
|
|
31
69
|
export interface ChatWidgetProps {
|
|
@@ -33,6 +71,15 @@ export interface ChatWidgetProps {
|
|
|
33
71
|
position?: 'bottom-right' | 'bottom-left';
|
|
34
72
|
/** Called when the user clicks 'Add to Cart' on a product */
|
|
35
73
|
onAddToCart?: (product: Product) => void;
|
|
74
|
+
/** Optional custom API URL to send chat messages to */
|
|
75
|
+
apiUrl?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Base URL for Retrivora SDK history/feedback/sessions endpoints.
|
|
78
|
+
* Defaults to '/api/retrivora'.
|
|
79
|
+
*/
|
|
80
|
+
retrivoraApiBase?: string;
|
|
81
|
+
/** Optional custom headers to send with the chat request */
|
|
82
|
+
headers?: Record<string, string>;
|
|
36
83
|
}
|
|
37
84
|
|
|
38
85
|
export interface MessageBubbleProps {
|
|
@@ -43,6 +90,8 @@ export interface MessageBubbleProps {
|
|
|
43
90
|
accentColor: string;
|
|
44
91
|
onAddToCart?: (product: Product) => void;
|
|
45
92
|
viewportSize?: ChatViewportSize;
|
|
93
|
+
/** Called when the user clicks thumbs up or thumbs down on an assistant message */
|
|
94
|
+
onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
|
|
46
95
|
}
|
|
47
96
|
|
|
48
97
|
export interface ProductCardProps {
|
package/.env.example
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# ─── Project ─────────────────────────────────────────────────
|
|
2
|
-
RAG_PROJECT_ID=my-project
|
|
3
|
-
|
|
4
|
-
# ─── Vector Database ──────────────────────────────────────────
|
|
5
|
-
# Choose: pinecone | pgvector | rest | universal_rest
|
|
6
|
-
VECTOR_DB_PROVIDER=pinecone
|
|
7
|
-
VECTOR_DB_INDEX=rag-index
|
|
8
|
-
|
|
9
|
-
# Pinecone (if provider=pinecone)
|
|
10
|
-
PINECONE_API_KEY=your-pinecone-api-key
|
|
11
|
-
PINECONE_ENVIRONMENT=us-east-1
|
|
12
|
-
|
|
13
|
-
# pgVector (if provider=pgvector)
|
|
14
|
-
PGVECTOR_CONNECTION_STRING=postgresql://user:password@localhost:5432/StagVectorDB
|
|
15
|
-
|
|
16
|
-
# Generic REST (if provider=rest)
|
|
17
|
-
VECTOR_DB_REST_URL=http://localhost:8080
|
|
18
|
-
VECTOR_DB_REST_API_KEY=your-rest-api-key
|
|
19
|
-
# VECTOR_DB_QUERY_PATH=/query
|
|
20
|
-
# VECTOR_DB_UPSERT_PATH=/upsert
|
|
21
|
-
|
|
22
|
-
# ─── LLM ──────────────────────────────────────────────────────
|
|
23
|
-
# Choose: openai | anthropic | ollama | gemini | universal_rest
|
|
24
|
-
LLM_PROVIDER=openai
|
|
25
|
-
LLM_MODEL=gpt-4o
|
|
26
|
-
LLM_MAX_TOKENS=1024
|
|
27
|
-
LLM_TEMPERATURE=0.7
|
|
28
|
-
LLM_SYSTEM_PROMPT=You are a helpful assistant. Use the provided context to answer questions accurately.
|
|
29
|
-
|
|
30
|
-
# OpenAI (if provider=openai)
|
|
31
|
-
OPENAI_API_KEY=sk-...
|
|
32
|
-
|
|
33
|
-
# Anthropic (if provider=anthropic)
|
|
34
|
-
ANTHROPIC_API_KEY=sk-ant-...
|
|
35
|
-
|
|
36
|
-
# Gemini (if provider=gemini)
|
|
37
|
-
GEMINI_API_KEY=AIza...
|
|
38
|
-
|
|
39
|
-
# Ollama (if provider=ollama)
|
|
40
|
-
LLM_BASE_URL=http://localhost:11434
|
|
41
|
-
|
|
42
|
-
# ── Master Universal Provider (LiteLLM, Qdrant, etc.) ─────────
|
|
43
|
-
# Use 'universal_rest' for ANY model or DB via pre-set profiles.
|
|
44
|
-
LLM_PROVIDER=universal_rest
|
|
45
|
-
LLM_MODEL=gpt-4o
|
|
46
|
-
# Profile: litellm | ollama-standard | openai-compatible
|
|
47
|
-
LLM_UNIVERSAL_PROFILE=litellm
|
|
48
|
-
LLM_BASE_URL=https://proxy.example.com/api
|
|
49
|
-
LLM_API_KEY=your-key
|
|
50
|
-
|
|
51
|
-
VECTOR_DB_PROVIDER=universal_rest
|
|
52
|
-
# Profile: qdrant | chromadb
|
|
53
|
-
VECTOR_UNIVERSAL_PROFILE=qdrant
|
|
54
|
-
VECTOR_BASE_URL=http://localhost:6333
|
|
55
|
-
VECTOR_DB_INDEX=my-index
|
|
56
|
-
|
|
57
|
-
# ─── Embedding ────────────────────────────────────────────────
|
|
58
|
-
# Choose: openai | ollama | gemini | custom
|
|
59
|
-
EMBEDDING_PROVIDER=openai
|
|
60
|
-
EMBEDDING_MODEL=text-embedding-3-small
|
|
61
|
-
EMBEDDING_DIMENSIONS=1536
|
|
62
|
-
# EMBEDDING_BASE_URL=http://localhost:11434 # for ollama
|
|
63
|
-
# EMBEDDING_API_KEY=your-embedding-key # for custom embedding endpoints
|
|
64
|
-
|
|
65
|
-
# ─── RAG Pipeline Tuning ──────────────────────────────────────
|
|
66
|
-
RAG_TOP_K=5
|
|
67
|
-
RAG_SCORE_THRESHOLD=0.0
|
|
68
|
-
RAG_CHUNK_SIZE=1000
|
|
69
|
-
RAG_CHUNK_OVERLAP=200
|
|
70
|
-
|
|
71
|
-
# ─── UI Branding (NEXT_PUBLIC_ = safe to expose to browser) ───
|
|
72
|
-
NEXT_PUBLIC_PROJECT_ID=my-project
|
|
73
|
-
NEXT_PUBLIC_UI_TITLE=AI Assistant
|
|
74
|
-
NEXT_PUBLIC_UI_SUBTITLE=Powered by RAG
|
|
75
|
-
NEXT_PUBLIC_PRIMARY_COLOR=#6366f1
|
|
76
|
-
NEXT_PUBLIC_ACCENT_COLOR=#8b5cf6
|
|
77
|
-
NEXT_PUBLIC_PLACEHOLDER=Ask me anything…
|
|
78
|
-
NEXT_PUBLIC_SHOW_SOURCES=true
|
|
79
|
-
NEXT_PUBLIC_WELCOME_MESSAGE=Hello! I'm your AI assistant. Ask me anything about your documents.
|
|
80
|
-
# NEXT_PUBLIC_LOGO_URL=https://your-domain.com/logo.png
|
package/LICENSE.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) [2026] [Abhinav Alkuchi]
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|