@retrivora-ai/rag-engine 2.4.3 → 2.4.6

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 (142) hide show
  1. package/README.md +22 -0
  2. package/dist/{BatchProcessor-zbQMaZHm.d.mts → BatchProcessor-BGslIR5l.d.mts} +65 -4
  3. package/dist/{BatchProcessor-D42E706a.d.ts → BatchProcessor-C3gY6kZ0.d.ts} +65 -4
  4. package/dist/handlers/index.js +668 -837
  5. package/dist/handlers/index.mjs +678 -837
  6. package/dist/index.css +5 -0
  7. package/dist/index.d.mts +4 -28
  8. package/dist/index.d.ts +4 -28
  9. package/dist/index.js +91 -43
  10. package/dist/index.min.css +1 -1
  11. package/dist/index.mjs +91 -43
  12. package/dist/server.d.mts +21 -7
  13. package/dist/server.d.ts +21 -7
  14. package/dist/server.js +731 -875
  15. package/dist/server.mjs +741 -875
  16. package/package.json +11 -4
  17. package/src/LicensedRetrivora.ts +0 -278
  18. package/src/app/api/chat/route.ts +0 -4
  19. package/src/app/api/health/route.ts +0 -5
  20. package/src/app/api/ingest/route.ts +0 -27
  21. package/src/app/api/suggestions/route.ts +0 -5
  22. package/src/app/api/upload/route.ts +0 -5
  23. package/src/app/constants.tsx +0 -270
  24. package/src/app/favicon.ico +0 -0
  25. package/src/app/globals.css +0 -449
  26. package/src/app/layout.tsx +0 -22
  27. package/src/app/page.tsx +0 -64
  28. package/src/app/types.ts +0 -30
  29. package/src/browser.tsx +0 -127
  30. package/src/components/ChatWidget.tsx +0 -393
  31. package/src/components/ChatWindow.tsx +0 -952
  32. package/src/components/CodeViewer.tsx +0 -56
  33. package/src/components/ConfigProvider.tsx +0 -141
  34. package/src/components/DocumentUpload.tsx +0 -354
  35. package/src/components/DynamicChart.tsx +0 -297
  36. package/src/components/HourglassLoader.tsx +0 -87
  37. package/src/components/MarkdownComponents.tsx +0 -186
  38. package/src/components/MessageBubble.tsx +0 -498
  39. package/src/components/ObservabilityPanel.tsx +0 -374
  40. package/src/components/ProductCard.tsx +0 -107
  41. package/src/components/ProductCarousel.tsx +0 -97
  42. package/src/components/SourceCard.tsx +0 -61
  43. package/src/components/ThemeProvider.tsx +0 -8
  44. package/src/components/ThemeToggle.tsx +0 -29
  45. package/src/components/ThinkingBlock.tsx +0 -75
  46. package/src/components/UIDispatcher.tsx +0 -342
  47. package/src/components/VisualizationRenderer.tsx +0 -621
  48. package/src/components/constants.tsx +0 -503
  49. package/src/config/ConfigBuilder.ts +0 -285
  50. package/src/config/EmbeddingStrategy.ts +0 -148
  51. package/src/config/LicenseConfigResolver.ts +0 -298
  52. package/src/config/RagConfig.ts +0 -328
  53. package/src/config/UniversalProfiles.ts +0 -82
  54. package/src/config/constants.ts +0 -64
  55. package/src/config/serverConfig.ts +0 -378
  56. package/src/config/uiConstants.ts +0 -47
  57. package/src/core/BatchProcessor.ts +0 -385
  58. package/src/core/CircuitBreaker.ts +0 -118
  59. package/src/core/ConfigFetcher.ts +0 -220
  60. package/src/core/ConfigResolver.ts +0 -165
  61. package/src/core/ConfigValidator.ts +0 -197
  62. package/src/core/DatabaseStorage.ts +0 -526
  63. package/src/core/FreeTierLimitsGuard.ts +0 -281
  64. package/src/core/LLMRouter.ts +0 -79
  65. package/src/core/LangChainAgent.ts +0 -132
  66. package/src/core/LicenseValidator.ts +0 -284
  67. package/src/core/LicenseVerifier.ts +0 -261
  68. package/src/core/MultiAgentCoordinator.ts +0 -239
  69. package/src/core/Pipeline.ts +0 -1279
  70. package/src/core/PluginManager.ts +0 -277
  71. package/src/core/ProjectSettings.ts +0 -247
  72. package/src/core/ProviderHealthCheck.ts +0 -133
  73. package/src/core/ProviderInterfaces.ts +0 -37
  74. package/src/core/ProviderRegistry.ts +0 -156
  75. package/src/core/QueryProcessor.ts +0 -399
  76. package/src/core/Retrivora.ts +0 -98
  77. package/src/core/VectorPlugin.ts +0 -193
  78. package/src/core/mcp.ts +0 -261
  79. package/src/exceptions/index.ts +0 -131
  80. package/src/handlers/index.ts +0 -1625
  81. package/src/hooks/useHydrated.ts +0 -13
  82. package/src/hooks/useProjectSettings.ts +0 -105
  83. package/src/hooks/useRagChat.ts +0 -436
  84. package/src/hooks/useStoredMessages.ts +0 -64
  85. package/src/index.css +0 -4269
  86. package/src/index.ts +0 -137
  87. package/src/lib/plugin.ts +0 -24
  88. package/src/llm/ILLMProvider.ts +0 -60
  89. package/src/llm/LLMFactory.ts +0 -141
  90. package/src/llm/providers/AnthropicProvider.ts +0 -215
  91. package/src/llm/providers/GeminiProvider.ts +0 -311
  92. package/src/llm/providers/GroqProvider.ts +0 -184
  93. package/src/llm/providers/OllamaProvider.ts +0 -232
  94. package/src/llm/providers/OpenAIProvider.ts +0 -188
  95. package/src/llm/providers/QwenProvider.ts +0 -199
  96. package/src/llm/providers/UniversalLLMAdapter.ts +0 -422
  97. package/src/llm/utils.ts +0 -46
  98. package/src/providers/graphdb/BaseGraphProvider.ts +0 -43
  99. package/src/providers/graphdb/SimpleGraphProvider.ts +0 -66
  100. package/src/providers/vectordb/BaseVectorProvider.ts +0 -98
  101. package/src/providers/vectordb/ChromaDBProvider.ts +0 -130
  102. package/src/providers/vectordb/MilvusProvider.ts +0 -134
  103. package/src/providers/vectordb/MongoDBProvider.ts +0 -250
  104. package/src/providers/vectordb/MultiTablePostgresProvider.ts +0 -461
  105. package/src/providers/vectordb/PineconeProvider.ts +0 -295
  106. package/src/providers/vectordb/PostgreSQLProvider.ts +0 -227
  107. package/src/providers/vectordb/QdrantProvider.ts +0 -294
  108. package/src/providers/vectordb/RedisProvider.ts +0 -105
  109. package/src/providers/vectordb/UniversalVectorProvider.ts +0 -221
  110. package/src/providers/vectordb/WeaviateProvider.ts +0 -172
  111. package/src/rag/DocumentChunker.ts +0 -144
  112. package/src/rag/EntityExtractor.ts +0 -90
  113. package/src/rag/LlamaIndexIngestor.ts +0 -60
  114. package/src/rag/Reranker.ts +0 -106
  115. package/src/rendering/IntentClassifier.ts +0 -167
  116. package/src/rendering/RendererRegistry.ts +0 -164
  117. package/src/rendering/RuleEngine.ts +0 -67
  118. package/src/rendering/VisualizationDecisionEngine.ts +0 -164
  119. package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +0 -237
  120. package/src/rendering/index.ts +0 -12
  121. package/src/rendering/rules/Rule1SpecificInfoRule.ts +0 -28
  122. package/src/rendering/rules/Rule2ComparisonRule.ts +0 -24
  123. package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +0 -28
  124. package/src/rendering/rules/Rule4AnalyticalRule.ts +0 -38
  125. package/src/rendering/rules/Rule5MixedResponseRule.ts +0 -29
  126. package/src/rendering/rules/Rule6SmallResultSetRule.ts +0 -24
  127. package/src/rendering/rules/Rule7LargeTableRule.ts +0 -35
  128. package/src/rendering/types.ts +0 -96
  129. package/src/server.ts +0 -156
  130. package/src/tailwind.css +0 -194
  131. package/src/telemetry/TelemetryService.ts +0 -330
  132. package/src/types/chat.ts +0 -89
  133. package/src/types/index.ts +0 -278
  134. package/src/types/pdf-parse.d.ts +0 -13
  135. package/src/types/props.ts +0 -169
  136. package/src/utils/DocumentParser.ts +0 -111
  137. package/src/utils/ProductExtractor.ts +0 -350
  138. package/src/utils/SchemaMapper.ts +0 -176
  139. package/src/utils/UITransformer.ts +0 -1812
  140. package/src/utils/synonyms.ts +0 -80
  141. package/src/utils/templateUtils.ts +0 -78
  142. package/src/version.ts +0 -6
@@ -1,80 +0,0 @@
1
- /**
2
- * Shared synonym map used by UITransformer and MessageBubble to resolve
3
- * schema-agnostic field names from vector metadata.
4
- */
5
- export const FIELD_SYNONYMS: Record<string, string[]> = {
6
- name: ['product', 'item', 'title', 'label', 'heading', 'subject', 'product name', 'item name'],
7
- price: ['cost', 'amount', 'msrp', 'price', 'rate', 'value', 'price_usd', 'variant price'],
8
- brand: ['manufacturer', 'vendor', 'make', 'company', 'brand_name', 'supplier'],
9
- image: ['imageUrl', 'thumbnail', 'img', 'url', 'photo', 'picture', 'media', 'image_url',
10
- 'main_image', 'product_image', 'thumb', 'image src', 'variant image'],
11
- stock: ['inventory', 'quantity', 'count', 'availability', 'stock_level', 'inStock',
12
- 'is_available', 'in stock', 'status', 'variant inventory qty'],
13
- category: ['product_category', 'product category', 'category_name', 'category name',
14
- 'department', 'collection', 'type'],
15
- description: ['summary', 'content', 'body', 'text', 'info', 'details', 'body (html)', 'seo description'],
16
- link: ['url', 'href', 'product_url', 'page_url', 'link'],
17
- };
18
-
19
- /**
20
- * Dynamically registers new synonyms into the global FIELD_SYNONYMS dictionary.
21
- * You can call this during your app initialization to support custom schema fields.
22
- */
23
- export function addSynonyms(customSynonyms: Record<string, string[]>) {
24
- for (const [key, aliases] of Object.entries(customSynonyms)) {
25
- if (!FIELD_SYNONYMS[key]) {
26
- FIELD_SYNONYMS[key] = [];
27
- }
28
- const existing = new Set(FIELD_SYNONYMS[key].map(s => s.toLowerCase()));
29
-
30
- for (const alias of aliases) {
31
- if (!existing.has(alias.toLowerCase())) {
32
- FIELD_SYNONYMS[key].push(alias);
33
- existing.add(alias.toLowerCase());
34
- }
35
- }
36
- }
37
- }
38
-
39
- /**
40
- * Robustly extract a value from metadata by checking exact, case-insensitive,
41
- * and synonym-based key matches.
42
- */
43
- export function resolveMetadataValue(
44
- meta: Record<string, unknown>,
45
- uiKey: string,
46
- ): unknown {
47
- const synonyms = FIELD_SYNONYMS[uiKey] ?? [];
48
-
49
- const keys = Object.keys(meta);
50
- const systemKeys = ['namespace', 'filename', 'filesize', 'filetype', 'docid', 'uploadedat', 'dimension', 'chunkindex'];
51
-
52
- // 1. Exact case-insensitive match for primary key
53
- let match = keys.find((k) => k.toLowerCase() === uiKey.toLowerCase());
54
- if (match !== undefined) return meta[match];
55
-
56
- // 2. Exact case-insensitive match for synonyms
57
- match = keys.find((k) => synonyms.map(s => s.toLowerCase()).includes(k.toLowerCase()));
58
- if (match !== undefined) return meta[match];
59
-
60
- const isBlacklisted = (kl: string) => {
61
- return systemKeys.includes(kl) || kl.startsWith('option1') || kl.startsWith('option2') || kl.startsWith('option3');
62
- };
63
-
64
- // 3. Partial match (substring) strictly for primary key
65
- match = keys.find((k) => {
66
- const kl = k.toLowerCase();
67
- if (isBlacklisted(kl)) return false;
68
- return kl.includes(uiKey.toLowerCase());
69
- });
70
- if (match !== undefined) return meta[match];
71
-
72
- // 4. Partial match (substring) for synonyms
73
- match = keys.find((k) => {
74
- const kl = k.toLowerCase();
75
- if (isBlacklisted(kl)) return false;
76
- return synonyms.some((sk) => kl.includes(sk.toLowerCase()) || sk.toLowerCase().includes(kl));
77
- });
78
-
79
- return match !== undefined ? meta[match] : undefined;
80
- }
@@ -1,78 +0,0 @@
1
- /**
2
- * Utility functions for Universal Configuration Adapters.
3
- * Handles JSON path extraction and payload templating.
4
- */
5
-
6
- /**
7
- * Resolves a dot-notation or bracket-notation path on an object.
8
- * Example: resolvePath({ a: { b: [10, 20] } }, 'a.b[1]') => 20
9
- */
10
- function isRecord(value: unknown): value is Record<string, unknown> {
11
- return typeof value === 'object' && value !== null;
12
- }
13
-
14
- export function resolvePath(obj: unknown, path: string): unknown {
15
- if (!path || !obj) return undefined;
16
- return path
17
- .replace(/\[(\w+)\]/g, '.$1') // convert indexes to properties
18
- .replace(/^\./, '') // strip a leading dot
19
- .split('.')
20
- .reduce<unknown>((current, segment) => {
21
- if (!isRecord(current) && !Array.isArray(current)) {
22
- return undefined;
23
- }
24
-
25
- return current[segment as keyof typeof current];
26
- }, obj);
27
- }
28
-
29
- /**
30
- * Replaces mustache-style variables in a JSON template string.
31
- * It handles both quoted "{{key}}" and unquoted {{key}} replacements.
32
- *
33
- * Note: To avoid JSON syntax errors, variables should be used as standalone
34
- * values in the template, e.g., { "query": {{vector}} } or { "text": "{{content}}" }.
35
- * Inline string concatenation like { "text": "Context: {{content}}" } is not supported
36
- * for complex objects or escaped strings.
37
- */
38
- export function buildPayload(template: string, vars: Record<string, unknown>): unknown {
39
- let raw = template;
40
- for (const [key, val] of Object.entries(vars)) {
41
- // stringify handles quoting and escaping for us
42
- const stringifiedVal = val === undefined ? 'null' : JSON.stringify(val);
43
-
44
- // Replace exact quoted occurrences first: "{{key}}" -> "escaped string" or [array]
45
- raw = raw.replace(new RegExp(`"\\{\\{${key}\\}\\}"`, 'g'), stringifiedVal);
46
-
47
- // Replace unquoted occurrences: {{key}} -> "escaped string" or [array]
48
- raw = raw.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), stringifiedVal);
49
- }
50
-
51
- try {
52
- return JSON.parse(raw) as unknown;
53
- } catch (err) {
54
- throw new Error(`Failed to parse payload template: ${(err as Error).message}\nRaw payload: ${raw}`);
55
- }
56
- }
57
-
58
- /**
59
- * Merges two objects, ignoring undefined, null, or empty string values in the override.
60
- */
61
- export function mergeDefined<T extends object>(
62
- base: T | undefined | null,
63
- override?: Partial<T>
64
- ): T {
65
- const merged = { ...(base || {}) } as T;
66
-
67
- if (!override) {
68
- return merged;
69
- }
70
-
71
- for (const [key, value] of Object.entries(override)) {
72
- if (value !== undefined && value !== null && value !== '') {
73
- (merged as Record<string, unknown>)[key] = value;
74
- }
75
- }
76
-
77
- return merged;
78
- }
package/src/version.ts DELETED
@@ -1,6 +0,0 @@
1
- import pkg from '../package.json';
2
-
3
- /**
4
- * Dynamically resolved SDK Version from package.json
5
- */
6
- export const SDK_VERSION: string = pkg.version || '2.1.3';