@retrivora-ai/rag-engine 2.4.3 → 2.4.5
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/dist/{BatchProcessor-zbQMaZHm.d.mts → BatchProcessor-Csy_K1qQ.d.mts} +2 -0
- package/dist/{BatchProcessor-D42E706a.d.ts → BatchProcessor-Dg18zZGk.d.ts} +2 -0
- package/dist/handlers/index.js +27 -4
- package/dist/handlers/index.mjs +27 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -10
- package/dist/index.mjs +12 -10
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +28 -4
- package/dist/server.mjs +28 -4
- package/package.json +1 -3
- package/src/LicensedRetrivora.ts +0 -278
- package/src/app/api/chat/route.ts +0 -4
- package/src/app/api/health/route.ts +0 -5
- package/src/app/api/ingest/route.ts +0 -27
- package/src/app/api/suggestions/route.ts +0 -5
- package/src/app/api/upload/route.ts +0 -5
- package/src/app/constants.tsx +0 -270
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +0 -449
- package/src/app/layout.tsx +0 -22
- package/src/app/page.tsx +0 -64
- package/src/app/types.ts +0 -30
- package/src/browser.tsx +0 -127
- package/src/components/ChatWidget.tsx +0 -393
- package/src/components/ChatWindow.tsx +0 -952
- package/src/components/CodeViewer.tsx +0 -56
- package/src/components/ConfigProvider.tsx +0 -141
- package/src/components/DocumentUpload.tsx +0 -354
- package/src/components/DynamicChart.tsx +0 -297
- package/src/components/HourglassLoader.tsx +0 -87
- package/src/components/MarkdownComponents.tsx +0 -186
- package/src/components/MessageBubble.tsx +0 -498
- package/src/components/ObservabilityPanel.tsx +0 -374
- package/src/components/ProductCard.tsx +0 -107
- package/src/components/ProductCarousel.tsx +0 -97
- package/src/components/SourceCard.tsx +0 -61
- package/src/components/ThemeProvider.tsx +0 -8
- package/src/components/ThemeToggle.tsx +0 -29
- package/src/components/ThinkingBlock.tsx +0 -75
- package/src/components/UIDispatcher.tsx +0 -342
- package/src/components/VisualizationRenderer.tsx +0 -621
- package/src/components/constants.tsx +0 -503
- package/src/config/ConfigBuilder.ts +0 -285
- package/src/config/EmbeddingStrategy.ts +0 -148
- package/src/config/LicenseConfigResolver.ts +0 -298
- package/src/config/RagConfig.ts +0 -328
- package/src/config/UniversalProfiles.ts +0 -82
- package/src/config/constants.ts +0 -64
- package/src/config/serverConfig.ts +0 -378
- package/src/config/uiConstants.ts +0 -47
- package/src/core/BatchProcessor.ts +0 -385
- package/src/core/CircuitBreaker.ts +0 -118
- package/src/core/ConfigFetcher.ts +0 -220
- package/src/core/ConfigResolver.ts +0 -165
- package/src/core/ConfigValidator.ts +0 -197
- package/src/core/DatabaseStorage.ts +0 -526
- package/src/core/FreeTierLimitsGuard.ts +0 -281
- package/src/core/LLMRouter.ts +0 -79
- package/src/core/LangChainAgent.ts +0 -132
- package/src/core/LicenseValidator.ts +0 -284
- package/src/core/LicenseVerifier.ts +0 -261
- package/src/core/MultiAgentCoordinator.ts +0 -239
- package/src/core/Pipeline.ts +0 -1279
- package/src/core/PluginManager.ts +0 -277
- package/src/core/ProjectSettings.ts +0 -247
- package/src/core/ProviderHealthCheck.ts +0 -133
- package/src/core/ProviderInterfaces.ts +0 -37
- package/src/core/ProviderRegistry.ts +0 -156
- package/src/core/QueryProcessor.ts +0 -399
- package/src/core/Retrivora.ts +0 -98
- package/src/core/VectorPlugin.ts +0 -193
- package/src/core/mcp.ts +0 -261
- package/src/exceptions/index.ts +0 -131
- package/src/handlers/index.ts +0 -1625
- package/src/hooks/useHydrated.ts +0 -13
- package/src/hooks/useProjectSettings.ts +0 -105
- package/src/hooks/useRagChat.ts +0 -436
- package/src/hooks/useStoredMessages.ts +0 -64
- package/src/index.css +0 -4269
- package/src/index.ts +0 -137
- package/src/lib/plugin.ts +0 -24
- package/src/llm/ILLMProvider.ts +0 -60
- package/src/llm/LLMFactory.ts +0 -141
- package/src/llm/providers/AnthropicProvider.ts +0 -215
- package/src/llm/providers/GeminiProvider.ts +0 -311
- package/src/llm/providers/GroqProvider.ts +0 -184
- package/src/llm/providers/OllamaProvider.ts +0 -232
- package/src/llm/providers/OpenAIProvider.ts +0 -188
- package/src/llm/providers/QwenProvider.ts +0 -199
- package/src/llm/providers/UniversalLLMAdapter.ts +0 -422
- package/src/llm/utils.ts +0 -46
- package/src/providers/graphdb/BaseGraphProvider.ts +0 -43
- package/src/providers/graphdb/SimpleGraphProvider.ts +0 -66
- package/src/providers/vectordb/BaseVectorProvider.ts +0 -98
- package/src/providers/vectordb/ChromaDBProvider.ts +0 -130
- package/src/providers/vectordb/MilvusProvider.ts +0 -134
- package/src/providers/vectordb/MongoDBProvider.ts +0 -250
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +0 -461
- package/src/providers/vectordb/PineconeProvider.ts +0 -295
- package/src/providers/vectordb/PostgreSQLProvider.ts +0 -227
- package/src/providers/vectordb/QdrantProvider.ts +0 -294
- package/src/providers/vectordb/RedisProvider.ts +0 -105
- package/src/providers/vectordb/UniversalVectorProvider.ts +0 -221
- package/src/providers/vectordb/WeaviateProvider.ts +0 -172
- package/src/rag/DocumentChunker.ts +0 -144
- package/src/rag/EntityExtractor.ts +0 -90
- package/src/rag/LlamaIndexIngestor.ts +0 -60
- package/src/rag/Reranker.ts +0 -106
- package/src/rendering/IntentClassifier.ts +0 -167
- package/src/rendering/RendererRegistry.ts +0 -164
- package/src/rendering/RuleEngine.ts +0 -67
- package/src/rendering/VisualizationDecisionEngine.ts +0 -164
- package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +0 -237
- package/src/rendering/index.ts +0 -12
- package/src/rendering/rules/Rule1SpecificInfoRule.ts +0 -28
- package/src/rendering/rules/Rule2ComparisonRule.ts +0 -24
- package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +0 -28
- package/src/rendering/rules/Rule4AnalyticalRule.ts +0 -38
- package/src/rendering/rules/Rule5MixedResponseRule.ts +0 -29
- package/src/rendering/rules/Rule6SmallResultSetRule.ts +0 -24
- package/src/rendering/rules/Rule7LargeTableRule.ts +0 -35
- package/src/rendering/types.ts +0 -96
- package/src/server.ts +0 -156
- package/src/tailwind.css +0 -194
- package/src/telemetry/TelemetryService.ts +0 -330
- package/src/types/chat.ts +0 -89
- package/src/types/index.ts +0 -278
- package/src/types/pdf-parse.d.ts +0 -13
- package/src/types/props.ts +0 -169
- package/src/utils/DocumentParser.ts +0 -111
- package/src/utils/ProductExtractor.ts +0 -350
- package/src/utils/SchemaMapper.ts +0 -176
- package/src/utils/UITransformer.ts +0 -1812
- package/src/utils/synonyms.ts +0 -80
- package/src/utils/templateUtils.ts +0 -78
- package/src/version.ts +0 -6
package/src/types/chat.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { VectorMatch } from './index';
|
|
2
|
-
|
|
3
|
-
export type MessageRole = 'user' | 'assistant' | 'system';
|
|
4
|
-
|
|
5
|
-
export interface ChatMessage {
|
|
6
|
-
role: MessageRole;
|
|
7
|
-
content: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface RagMessage extends ChatMessage {
|
|
11
|
-
id: string;
|
|
12
|
-
sources?: VectorMatch[];
|
|
13
|
-
uiTransformation?: unknown;
|
|
14
|
-
/** Full observability trace emitted by the backend. Only present on assistant messages. */
|
|
15
|
-
trace?: import('./index').ObservabilityTrace;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
/**
|
|
18
|
-
* Chain-of-thought reasoning from the LLM.
|
|
19
|
-
* Populated by native Anthropic extended thinking or simulated <think> tag stripping.
|
|
20
|
-
*/
|
|
21
|
-
thinking?: string;
|
|
22
|
-
/** Wall-clock ms the model spent in the thinking phase. */
|
|
23
|
-
thinkingMs?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface ChatOptions {
|
|
27
|
-
/** Override max tokens for this specific call */
|
|
28
|
-
maxTokens?: number;
|
|
29
|
-
/** Override temperature for this specific call */
|
|
30
|
-
temperature?: number;
|
|
31
|
-
/** Stop sequences */
|
|
32
|
-
stop?: string[];
|
|
33
|
-
/**
|
|
34
|
-
* Per-call system prompt override. When provided, providers should use this
|
|
35
|
-
* instead of (or in addition to) their configured llmConfig.systemPrompt.
|
|
36
|
-
* Useful for one-off analytical calls (e.g. UITransformer.analyzeAndDecide).
|
|
37
|
-
*/
|
|
38
|
-
systemPrompt?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface UseRagChatOptions {
|
|
42
|
-
/** Override the chat API endpoint (default: /api/chat) */
|
|
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;
|
|
50
|
-
/** Override project namespace */
|
|
51
|
-
namespace?: string;
|
|
52
|
-
/** Persist chat history to localStorage (default: true) */
|
|
53
|
-
persist?: boolean;
|
|
54
|
-
/** Called after each successful assistant reply */
|
|
55
|
-
onReply?: (message: RagMessage) => void;
|
|
56
|
-
/** Called on error */
|
|
57
|
-
onError?: (error: string) => void;
|
|
58
|
-
/** Optional custom headers to send with the chat request */
|
|
59
|
-
headers?: Record<string, string>;
|
|
60
|
-
/** Optional Retrivora license key override */
|
|
61
|
-
licenseKey?: string;
|
|
62
|
-
/** Session ID for history and feedback tracking (default: 'default') */
|
|
63
|
-
sessionId?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface UseRagChatReturn {
|
|
67
|
-
/** All messages in the current conversation */
|
|
68
|
-
messages: RagMessage[];
|
|
69
|
-
/** Whether a response is in flight */
|
|
70
|
-
isLoading: boolean;
|
|
71
|
-
/** Current error message, or null */
|
|
72
|
-
error: string | null;
|
|
73
|
-
/** Send a user message */
|
|
74
|
-
send: (text: string) => Promise<void>;
|
|
75
|
-
/** Clear the conversation (and localStorage if persist=true) */
|
|
76
|
-
clear: () => void;
|
|
77
|
-
/** Retry the last failed send */
|
|
78
|
-
retry: () => Promise<void>;
|
|
79
|
-
/** Programmatically set the conversation (e.g. to restore from a DB) */
|
|
80
|
-
setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
|
|
81
|
-
/** Abort the current active stream request */
|
|
82
|
-
stop: () => void;
|
|
83
|
-
/** Load message history from database storage */
|
|
84
|
-
loadHistory: (sessionId: string) => Promise<void>;
|
|
85
|
-
/** Clear conversation history from database and locally */
|
|
86
|
-
clearHistory: (sessionId: string) => Promise<void>;
|
|
87
|
-
/** Submit rating and optional comment for a specific assistant message */
|
|
88
|
-
submitFeedback: (messageId: string, rating: 'thumbs_up' | 'thumbs_down', comment?: string) => Promise<void>;
|
|
89
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
// ─── Observability ────────────────────────────────────────────────────────────
|
|
2
|
-
|
|
3
|
-
/** Per-stage latency breakdown for a single RAG request. */
|
|
4
|
-
export interface LatencyBreakdown {
|
|
5
|
-
embedMs: number;
|
|
6
|
-
retrieveMs: number;
|
|
7
|
-
rerankMs?: number;
|
|
8
|
-
generateMs: number;
|
|
9
|
-
totalMs: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Token usage reported by the LLM (or estimated when the provider doesn't expose it). */
|
|
13
|
-
export interface TokenUsage {
|
|
14
|
-
promptTokens: number;
|
|
15
|
-
completionTokens: number;
|
|
16
|
-
totalTokens: number;
|
|
17
|
-
/** Rough cost in USD — estimated from token counts and model pricing. */
|
|
18
|
-
estimatedCostUsd?: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** A single retrieved chunk annotated with its retrieval context. */
|
|
22
|
-
export interface RetrievedChunk {
|
|
23
|
-
id: string | number;
|
|
24
|
-
score: number;
|
|
25
|
-
content: string;
|
|
26
|
-
metadata: Record<string, unknown>;
|
|
27
|
-
namespace: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Full observability trace for one RAG request.
|
|
32
|
-
* Emitted by the backend as an SSE frame and stored on each RagMessage.
|
|
33
|
-
*/
|
|
34
|
-
export interface ObservabilityTrace {
|
|
35
|
-
requestId: string;
|
|
36
|
-
query: string;
|
|
37
|
-
rewrittenQuery?: string;
|
|
38
|
-
systemPrompt: string;
|
|
39
|
-
userPrompt: string;
|
|
40
|
-
chunks: RetrievedChunk[];
|
|
41
|
-
latency: LatencyBreakdown;
|
|
42
|
-
tokens?: TokenUsage;
|
|
43
|
-
model?: string;
|
|
44
|
-
provider?: string;
|
|
45
|
-
/** 0 = fully grounded, 1 = likely hallucinated. */
|
|
46
|
-
hallucinationScore?: number;
|
|
47
|
-
hallucinationReason?: string;
|
|
48
|
-
timestamp: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ─── Vector / RAG ─────────────────────────────────────────────────────────────
|
|
52
|
-
|
|
53
|
-
export interface VectorMatch {
|
|
54
|
-
id: string | number;
|
|
55
|
-
score: number;
|
|
56
|
-
content: string;
|
|
57
|
-
metadata?: Record<string, unknown>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface UpsertDocument {
|
|
61
|
-
id: string | number;
|
|
62
|
-
vector: number[];
|
|
63
|
-
content: string;
|
|
64
|
-
metadata?: Record<string, unknown>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface IngestDocument {
|
|
68
|
-
docId: string | number;
|
|
69
|
-
content: string;
|
|
70
|
-
metadata?: Record<string, unknown>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface ChatResponse {
|
|
74
|
-
reply: string;
|
|
75
|
-
sources: VectorMatch[];
|
|
76
|
-
graphData?: GraphSearchResult;
|
|
77
|
-
ui_transformation?: unknown;
|
|
78
|
-
/** Observability trace — populated by the instrumented Pipeline. */
|
|
79
|
-
trace?: ObservabilityTrace;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface GraphNode {
|
|
83
|
-
id: string;
|
|
84
|
-
label: string;
|
|
85
|
-
properties?: Record<string, unknown>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface Edge {
|
|
89
|
-
source: string;
|
|
90
|
-
target: string;
|
|
91
|
-
type: string;
|
|
92
|
-
properties?: Record<string, unknown>;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface GraphSearchResult {
|
|
96
|
-
nodes: GraphNode[];
|
|
97
|
-
edges: Edge[];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface RetrievalResult {
|
|
101
|
-
sources: VectorMatch[];
|
|
102
|
-
graphData?: GraphSearchResult;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface IRetriever {
|
|
106
|
-
retrieve(query: string, options?: Record<string, unknown>): Promise<RetrievalResult>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface SuggestionsResponse {
|
|
110
|
-
suggestions: string[];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface Product {
|
|
114
|
-
id: string | number;
|
|
115
|
-
name: string;
|
|
116
|
-
brand?: string;
|
|
117
|
-
price?: string | number;
|
|
118
|
-
image?: string;
|
|
119
|
-
link?: string;
|
|
120
|
-
description?: string;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Supported UI visualization types
|
|
125
|
-
*/
|
|
126
|
-
export type VisualizationType =
|
|
127
|
-
| 'pie_chart'
|
|
128
|
-
| 'bar_chart'
|
|
129
|
-
| 'line_chart'
|
|
130
|
-
| 'histogram'
|
|
131
|
-
| 'horizontal_bar'
|
|
132
|
-
| 'scatter_plot'
|
|
133
|
-
| 'radar_chart'
|
|
134
|
-
| 'metric_card'
|
|
135
|
-
| 'geo_map'
|
|
136
|
-
| 'table'
|
|
137
|
-
| 'product_carousel'
|
|
138
|
-
| 'carousel'
|
|
139
|
-
| 'text';
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Base structure for all UI transformation responses
|
|
143
|
-
*/
|
|
144
|
-
export interface UITransformationResponse {
|
|
145
|
-
type: VisualizationType;
|
|
146
|
-
title: string;
|
|
147
|
-
description?: string;
|
|
148
|
-
data: unknown;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Pie chart data structure
|
|
153
|
-
*/
|
|
154
|
-
export interface PieChartData {
|
|
155
|
-
label: string;
|
|
156
|
-
value: number;
|
|
157
|
-
inStockCount?: number;
|
|
158
|
-
outOfStockCount?: number;
|
|
159
|
-
[key: string]: unknown;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Bar chart data structure
|
|
164
|
-
*/
|
|
165
|
-
export interface BarChartData {
|
|
166
|
-
category: string;
|
|
167
|
-
value: number;
|
|
168
|
-
inStockCount?: number;
|
|
169
|
-
outOfStockCount?: number;
|
|
170
|
-
[key: string]: unknown;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Line chart data point
|
|
175
|
-
*/
|
|
176
|
-
export interface LineChartDataPoint {
|
|
177
|
-
timestamp: string | number;
|
|
178
|
-
value: number;
|
|
179
|
-
label?: string;
|
|
180
|
-
[key: string]: unknown;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Scatter plot data point
|
|
185
|
-
*/
|
|
186
|
-
export interface ScatterPlotDataPoint {
|
|
187
|
-
x: number;
|
|
188
|
-
y: number;
|
|
189
|
-
label?: string;
|
|
190
|
-
[key: string]: unknown;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* KPI / metric card representation
|
|
195
|
-
*/
|
|
196
|
-
export interface MetricCardData {
|
|
197
|
-
label: string;
|
|
198
|
-
value: number;
|
|
199
|
-
operation?: 'sum' | 'average' | 'count' | 'min' | 'max' | 'median';
|
|
200
|
-
unit?: string;
|
|
201
|
-
details?: Record<string, string | number | boolean>;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Table representation
|
|
206
|
-
*/
|
|
207
|
-
export interface TableData {
|
|
208
|
-
columns: string[];
|
|
209
|
-
rows: (string | number | boolean)[][];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Product carousel item
|
|
215
|
-
*/
|
|
216
|
-
export interface CarouselProduct {
|
|
217
|
-
id: string | number;
|
|
218
|
-
name: string;
|
|
219
|
-
price?: number | string;
|
|
220
|
-
image?: string;
|
|
221
|
-
inStock?: boolean;
|
|
222
|
-
brand?: string;
|
|
223
|
-
description?: string;
|
|
224
|
-
[key: string]: unknown;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
export * from './props';
|
|
230
|
-
export * from './chat';
|
|
231
|
-
|
|
232
|
-
// ─── Global Retrivora Metadata Schema ───────────────────────────────────────
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Standardized Retrivora Metadata Schema for document vectors and storage.
|
|
236
|
-
* Guarantees uniform metadata structure across vector DB backends (Pinecone, MongoDB, etc.).
|
|
237
|
-
*/
|
|
238
|
-
export interface RetrivoraChunkMetadata {
|
|
239
|
-
/** Document unique identifier */
|
|
240
|
-
docId: string;
|
|
241
|
-
/** Original file name (e.g. report.pdf, data.json, sheets.xlsx) */
|
|
242
|
-
fileName: string;
|
|
243
|
-
/** File format type identifier */
|
|
244
|
-
fileType: 'txt' | 'json' | 'pdf' | 'excel' | 'word' | 'md' | 'csv' | string;
|
|
245
|
-
/** MIME type string */
|
|
246
|
-
mimeType: string;
|
|
247
|
-
/** 0-indexed position of chunk within the parent document */
|
|
248
|
-
chunkIndex: number;
|
|
249
|
-
/** Total count of chunks in the document */
|
|
250
|
-
totalChunks: number;
|
|
251
|
-
/** Extracted text content of the chunk */
|
|
252
|
-
content: string;
|
|
253
|
-
/** Character length of the chunk content */
|
|
254
|
-
characterCount: number;
|
|
255
|
-
/** Workspace or Project ID */
|
|
256
|
-
workspaceId: string;
|
|
257
|
-
/** Isolated vector database namespace (e.g. Pinecone namespace) */
|
|
258
|
-
pineconeNamespace: string;
|
|
259
|
-
/** Retrivora Tier level */
|
|
260
|
-
tier: 'free' | 'enterprise';
|
|
261
|
-
/** ISO 8601 timestamp when the document was processed */
|
|
262
|
-
ingestedAt: string;
|
|
263
|
-
/** Additional custom metadata Key-Value pairs */
|
|
264
|
-
customMetadata?: Record<string, unknown>;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export interface RetrivoraIngestedDocument {
|
|
268
|
-
docId: string;
|
|
269
|
-
fileName: string;
|
|
270
|
-
fileType: string;
|
|
271
|
-
mimeType: string;
|
|
272
|
-
fileSizeBytes?: number;
|
|
273
|
-
totalChunks: number;
|
|
274
|
-
workspaceId: string;
|
|
275
|
-
pineconeNamespace: string;
|
|
276
|
-
ingestedAt: string;
|
|
277
|
-
chunks: RetrivoraChunkMetadata[];
|
|
278
|
-
}
|
package/src/types/pdf-parse.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare module 'pdf-parse/lib/pdf-parse.js' {
|
|
2
|
-
interface PDFData {
|
|
3
|
-
text: string;
|
|
4
|
-
numpages: number;
|
|
5
|
-
numrender: number;
|
|
6
|
-
info: Record<string, unknown>;
|
|
7
|
-
metadata: Record<string, unknown>;
|
|
8
|
-
version: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function PDFParse(dataBuffer: Buffer, options?: Record<string, unknown>): Promise<PDFData>;
|
|
12
|
-
export default PDFParse;
|
|
13
|
-
}
|
package/src/types/props.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties, MouseEvent, ElementType } from 'react';
|
|
2
|
-
import { Product, VectorMatch } from './index';
|
|
3
|
-
import { RagMessage } from './chat';
|
|
4
|
-
import { UIConfig } from '../config/RagConfig';
|
|
5
|
-
import { ProjectChatSettings, WidgetPosition } from '../core/ProjectSettings';
|
|
6
|
-
|
|
7
|
-
export interface ArchitectureCardProps {
|
|
8
|
-
icon: ReactNode;
|
|
9
|
-
title: string;
|
|
10
|
-
description: string;
|
|
11
|
-
badge: string;
|
|
12
|
-
badgeColor: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface Snippet {
|
|
16
|
-
id: string;
|
|
17
|
-
title: string;
|
|
18
|
-
description: string;
|
|
19
|
-
code: string;
|
|
20
|
-
language: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface PipelineStep {
|
|
24
|
-
step: string;
|
|
25
|
-
Icon: ElementType;
|
|
26
|
-
title: string;
|
|
27
|
-
desc: string;
|
|
28
|
-
colors: { from: string; to: string };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface ProviderPill {
|
|
32
|
-
Icon: ElementType;
|
|
33
|
-
label: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type ChatViewportSize = 'compact' | 'medium' | 'large';
|
|
37
|
-
|
|
38
|
-
export interface ChatWindowProps {
|
|
39
|
-
/** Additional className for the wrapper div */
|
|
40
|
-
className?: string;
|
|
41
|
-
/** Inline styles for the wrapper div */
|
|
42
|
-
style?: CSSProperties;
|
|
43
|
-
/** Called when the close button is clicked (for widget mode) */
|
|
44
|
-
onClose?: () => void;
|
|
45
|
-
/** Whether to show a close (X) button in the header */
|
|
46
|
-
showClose?: boolean;
|
|
47
|
-
/** Called when the user starts dragging the resize handle */
|
|
48
|
-
onResizeStart?: (e: MouseEvent) => void;
|
|
49
|
-
/** Called when the user clicks the reset size button */
|
|
50
|
-
onResetResize?: () => void;
|
|
51
|
-
/** Whether the window has been resized from its default */
|
|
52
|
-
isResized?: boolean;
|
|
53
|
-
/** Called when the user clicks the maximize/minimize button */
|
|
54
|
-
onMaximize?: () => void;
|
|
55
|
-
/** Whether the window is currently maximized */
|
|
56
|
-
isMaximized?: boolean;
|
|
57
|
-
/** Called when the user clicks 'Add to Cart' on a product */
|
|
58
|
-
onAddToCart?: (product: Product) => void;
|
|
59
|
-
/** Optional custom API URL to send chat messages to */
|
|
60
|
-
apiUrl?: string;
|
|
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 Retrivora license key override */
|
|
66
|
-
licenseKey?: string;
|
|
67
|
-
/** Optional custom headers to send with the chat request */
|
|
68
|
-
headers?: Record<string, string>;
|
|
69
|
-
/** Optional session ID to load conversation history from the server */
|
|
70
|
-
sessionId?: string;
|
|
71
|
-
/** Whether to show the ChatGPT-style sidebar history management and new chat controls */
|
|
72
|
-
showHistory?: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface ChatWidgetProps {
|
|
76
|
-
/** Position of the floating button. Defaults to bottom-right. */
|
|
77
|
-
position?: WidgetPosition;
|
|
78
|
-
/** Called when the user clicks 'Add to Cart' on a product */
|
|
79
|
-
onAddToCart?: (product: Product) => void;
|
|
80
|
-
/** Optional custom API URL to send chat messages to */
|
|
81
|
-
apiUrl?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Base URL for Retrivora SDK history/feedback/sessions endpoints.
|
|
84
|
-
* Defaults to '/api/retrivora'.
|
|
85
|
-
*/
|
|
86
|
-
retrivoraApiBase?: string;
|
|
87
|
-
/** Optional Retrivora license key override */
|
|
88
|
-
licenseKey?: string;
|
|
89
|
-
/** Optional custom headers to send with the chat request */
|
|
90
|
-
headers?: Record<string, string>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface MessageBubbleProps {
|
|
94
|
-
message: RagMessage;
|
|
95
|
-
sources?: VectorMatch[];
|
|
96
|
-
isStreaming?: boolean;
|
|
97
|
-
primaryColor: string;
|
|
98
|
-
accentColor: string;
|
|
99
|
-
onAddToCart?: (product: Product) => void;
|
|
100
|
-
viewportSize?: ChatViewportSize;
|
|
101
|
-
/** Called when the user clicks thumbs up or thumbs down on an assistant message */
|
|
102
|
-
onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface ProductCardProps {
|
|
106
|
-
product: Product;
|
|
107
|
-
primaryColor?: string;
|
|
108
|
-
onAddToCart?: (product: Product) => void;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface ProductCarouselProps {
|
|
112
|
-
products: Product[];
|
|
113
|
-
primaryColor?: string;
|
|
114
|
-
onAddToCart?: (product: Product) => void;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface DocumentUploadProps {
|
|
118
|
-
/** Optional namespace for the upload */
|
|
119
|
-
namespace?: string;
|
|
120
|
-
/** Custom upload API endpoint URL (defaults to /api/retrivora/upload or /api/upload) */
|
|
121
|
-
uploadUrl?: string;
|
|
122
|
-
/** Base URL for Retrivora SDK endpoints (defaults to /api/retrivora) */
|
|
123
|
-
retrivoraApiBase?: string;
|
|
124
|
-
/** Callback when upload completes */
|
|
125
|
-
onUploadComplete?: (results: unknown) => void;
|
|
126
|
-
/** Additional className */
|
|
127
|
-
className?: string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface SourceCardProps {
|
|
131
|
-
source: VectorMatch;
|
|
132
|
-
index: number;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface ClientConfig {
|
|
136
|
-
projectId: string;
|
|
137
|
-
ui: Required<UIConfig>;
|
|
138
|
-
embedding?: {
|
|
139
|
-
model?: string;
|
|
140
|
-
dimensions?: number;
|
|
141
|
-
};
|
|
142
|
-
licenseKey?: string;
|
|
143
|
-
headers?: Record<string, string>;
|
|
144
|
-
retrivoraApiBase?: string;
|
|
145
|
-
projectSettings?: ProjectChatSettings;
|
|
146
|
-
autoLoadProjectSettings?: boolean;
|
|
147
|
-
isProjectSettingsLoading?: boolean;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export interface ConfigProviderProps {
|
|
151
|
-
config?: {
|
|
152
|
-
projectId?: string;
|
|
153
|
-
ui?: Partial<UIConfig>;
|
|
154
|
-
embedding?: { model?: string; dimensions?: number };
|
|
155
|
-
licenseKey?: string;
|
|
156
|
-
headers?: Record<string, string>;
|
|
157
|
-
retrivoraApiBase?: string;
|
|
158
|
-
projectSettings?: Partial<ProjectChatSettings>;
|
|
159
|
-
autoLoadProjectSettings?: boolean;
|
|
160
|
-
// Root-level flat mappings for developer convenience
|
|
161
|
-
primaryColor?: string;
|
|
162
|
-
secondaryColor?: string;
|
|
163
|
-
accentColor?: string;
|
|
164
|
-
theme?: 'light' | 'dark' | 'system';
|
|
165
|
-
borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
166
|
-
visualStyle?: 'solid' | 'glass';
|
|
167
|
-
};
|
|
168
|
-
children: ReactNode;
|
|
169
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DocumentParser — handles text extraction from various file formats.
|
|
3
|
-
* Supported: .txt, .md, .json, .csv, .pdf, .docx, .doc, .xlsx, .xls
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class DocumentParser {
|
|
7
|
-
/**
|
|
8
|
-
* Extract text from a File or Buffer based on its type.
|
|
9
|
-
*/
|
|
10
|
-
static async parse(file: File | Buffer, fileName: string, mimeType: string): Promise<string> {
|
|
11
|
-
const extension = fileName.split('.').pop()?.toLowerCase() || '';
|
|
12
|
-
|
|
13
|
-
// 1. Basic text & Markdown formats
|
|
14
|
-
if (extension === 'txt' || extension === 'md' || mimeType === 'text/plain' || mimeType === 'text/markdown') {
|
|
15
|
-
return this.readAsText(file);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 2. JSON files
|
|
19
|
-
if (extension === 'json' || mimeType === 'application/json') {
|
|
20
|
-
const text = await this.readAsText(file);
|
|
21
|
-
try {
|
|
22
|
-
const obj = JSON.parse(text);
|
|
23
|
-
return JSON.stringify(obj, null, 2);
|
|
24
|
-
} catch {
|
|
25
|
-
return text;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 3. CSV files
|
|
30
|
-
if (extension === 'csv' || mimeType === 'text/csv') {
|
|
31
|
-
return this.readAsText(file);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 4. Excel spreadsheets (.xlsx, .xls)
|
|
35
|
-
if (
|
|
36
|
-
extension === 'xlsx' ||
|
|
37
|
-
extension === 'xls' ||
|
|
38
|
-
mimeType.includes('spreadsheet') ||
|
|
39
|
-
mimeType.includes('excel')
|
|
40
|
-
) {
|
|
41
|
-
try {
|
|
42
|
-
// Dynamic import with ts-ignore to allow optional resolution
|
|
43
|
-
const xlsx = await import('xlsx');
|
|
44
|
-
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await (file as File).arrayBuffer());
|
|
45
|
-
const workbook = xlsx.read(buffer, { type: 'buffer' });
|
|
46
|
-
const sheetsText: string[] = [];
|
|
47
|
-
|
|
48
|
-
for (const sheetName of workbook.SheetNames) {
|
|
49
|
-
const sheet = workbook.Sheets[sheetName];
|
|
50
|
-
const csv = xlsx.utils.sheet_to_csv(sheet);
|
|
51
|
-
if (csv && csv.trim()) {
|
|
52
|
-
sheetsText.push(`--- Sheet: ${sheetName} ---\n${csv.trim()}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return sheetsText.join('\n\n') || `[Empty Excel Workbook: ${fileName}]`;
|
|
56
|
-
} catch {
|
|
57
|
-
// Fall back to reading text lines if xlsx module is not present
|
|
58
|
-
try {
|
|
59
|
-
return await this.readAsText(file);
|
|
60
|
-
} catch {
|
|
61
|
-
return `[Excel File Content: ${fileName}]`;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 5. PDF Documents (Requires pdf-parse)
|
|
67
|
-
if (extension === 'pdf' || mimeType === 'application/pdf') {
|
|
68
|
-
try {
|
|
69
|
-
const pdf = await import('pdf-parse');
|
|
70
|
-
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await (file as File).arrayBuffer());
|
|
71
|
-
const data = await pdf.default(buffer);
|
|
72
|
-
return data.text;
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.warn('[DocumentParser] PDF parsing failed. Make sure "pdf-parse" is installed.', err);
|
|
75
|
-
return `[PDF Parsing Error for ${fileName}]`;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 6. Word Documents (.docx, .doc) (Requires mammoth)
|
|
80
|
-
if (
|
|
81
|
-
extension === 'docx' ||
|
|
82
|
-
extension === 'doc' ||
|
|
83
|
-
mimeType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
|
84
|
-
mimeType === 'application/msword'
|
|
85
|
-
) {
|
|
86
|
-
try {
|
|
87
|
-
const mammoth = await import('mammoth');
|
|
88
|
-
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await (file as File).arrayBuffer());
|
|
89
|
-
const result = await mammoth.extractRawText({ buffer });
|
|
90
|
-
return result.value;
|
|
91
|
-
} catch (err) {
|
|
92
|
-
console.warn('[DocumentParser] Word parsing failed. Make sure "mammoth" is installed.', err);
|
|
93
|
-
return `[Word Parsing Error for ${fileName}]`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Fallback: try reading as plain UTF-8 text
|
|
98
|
-
try {
|
|
99
|
-
return await this.readAsText(file);
|
|
100
|
-
} catch {
|
|
101
|
-
throw new Error(`[DocumentParser] Unsupported file format: ${fileName} (${mimeType})`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private static async readAsText(file: File | Buffer): Promise<string> {
|
|
106
|
-
if (Buffer.isBuffer(file)) {
|
|
107
|
-
return file.toString('utf-8');
|
|
108
|
-
}
|
|
109
|
-
return await (file as File).text();
|
|
110
|
-
}
|
|
111
|
-
}
|