@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/utils/synonyms.ts
DELETED
|
@@ -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
|
-
}
|