@retrivora-ai/rag-engine 1.7.5 → 1.7.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.
@@ -2362,11 +2362,14 @@ Classify the query into ONE of the following intents:
2362
2362
 
2363
2363
  ## 5. DATA RULES
2364
2364
 
2365
- - NEVER hallucinate fields
2365
+ - NEVER hallucinate fields or data
2366
2366
  - ONLY use retrieved vector DB data
2367
2367
  - NO placeholders ("...", "N/A")
2368
2368
  - If image/link missing \u2192 REMOVE FIELD
2369
2369
  - Aggregate BEFORE rendering chart
2370
+ - IF NO DATA IS FOUND in the retrieved context:
2371
+ \u2192 DO NOT output a \`\`\`ui\`\`\` block
2372
+ \u2192 Instead, state clearly that no relevant products or data were found.
2370
2373
 
2371
2374
  ---
2372
2375
 
@@ -3926,11 +3926,14 @@ Classify the query into ONE of the following intents:
3926
3926
 
3927
3927
  ## 5. DATA RULES
3928
3928
 
3929
- - NEVER hallucinate fields
3929
+ - NEVER hallucinate fields or data
3930
3930
  - ONLY use retrieved vector DB data
3931
3931
  - NO placeholders ("...", "N/A")
3932
3932
  - If image/link missing \u2192 REMOVE FIELD
3933
3933
  - Aggregate BEFORE rendering chart
3934
+ - IF NO DATA IS FOUND in the retrieved context:
3935
+ \u2192 DO NOT output a \`\`\`ui\`\`\` block
3936
+ \u2192 Instead, state clearly that no relevant products or data were found.
3934
3937
 
3935
3938
  ---
3936
3939
 
@@ -10,7 +10,7 @@ import {
10
10
  sseMetaFrame,
11
11
  sseTextFrame,
12
12
  sseUIFrame
13
- } from "../chunk-QOO37S2Z.mjs";
13
+ } from "../chunk-XGVKIPNY.mjs";
14
14
  import "../chunk-YLTMFW4M.mjs";
15
15
  import "../chunk-X4TOT24V.mjs";
16
16
  export {
package/dist/server.js CHANGED
@@ -4016,11 +4016,14 @@ Classify the query into ONE of the following intents:
4016
4016
 
4017
4017
  ## 5. DATA RULES
4018
4018
 
4019
- - NEVER hallucinate fields
4019
+ - NEVER hallucinate fields or data
4020
4020
  - ONLY use retrieved vector DB data
4021
4021
  - NO placeholders ("...", "N/A")
4022
4022
  - If image/link missing \u2192 REMOVE FIELD
4023
4023
  - Aggregate BEFORE rendering chart
4024
+ - IF NO DATA IS FOUND in the retrieved context:
4025
+ \u2192 DO NOT output a \`\`\`ui\`\`\` block
4026
+ \u2192 Instead, state clearly that no relevant products or data were found.
4024
4027
 
4025
4028
  ---
4026
4029
 
@@ -4927,15 +4930,21 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
4927
4930
  ).map((hint) => hint.value.trim().toLowerCase()).filter(Boolean) : [];
4928
4931
  console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
4929
4932
  console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
4930
- const cleanKeywordQuery = (text) => {
4931
- return text.toLowerCase().replace(/\b(show|me|the|product|cards|of|category|find|list|browse|what|are|display)\b/g, "").trim().replace(/\s+/g, " & ");
4933
+ const getDynamicKeywordQuery = () => {
4934
+ if (entityHints.length > 0) {
4935
+ return entityHints.map((h) => h.includes(" ") ? `"${h}"` : h).join(" & ");
4936
+ }
4937
+ if (queryText) {
4938
+ return queryText.toLowerCase().replace(/\b(show|me|the|product[s]?|item[s]?|card[s]?|of|category|find|list|browse|what|are|display|all|under|for|in|with|about)\b/g, "").trim().replace(/\s+/g, " & ");
4939
+ }
4940
+ return "";
4932
4941
  };
4942
+ const dynamicKeywordQuery = getDynamicKeywordQuery();
4933
4943
  const queryPromises = this.tables.map(async (table) => {
4934
4944
  try {
4935
4945
  let sqlQuery = "";
4936
4946
  let params = [];
4937
4947
  if (queryText) {
4938
- const cleanedText = cleanKeywordQuery(queryText) || queryText;
4939
4948
  const hasEntityHints = entityHints.length > 0;
4940
4949
  const exactNameScoreExpr = hasEntityHints ? `+ (
4941
4950
  SELECT COALESCE(MAX(
@@ -4954,7 +4963,7 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
4954
4963
  ORDER BY hybrid_score DESC
4955
4964
  LIMIT 50
4956
4965
  `;
4957
- params = [vectorLiteral, cleanedText];
4966
+ params = [vectorLiteral, dynamicKeywordQuery];
4958
4967
  } else {
4959
4968
  sqlQuery = `
4960
4969
  SELECT *,
package/dist/server.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  sseFrame,
40
40
  sseMetaFrame,
41
41
  sseTextFrame
42
- } from "./chunk-QOO37S2Z.mjs";
42
+ } from "./chunk-XGVKIPNY.mjs";
43
43
  import "./chunk-YLTMFW4M.mjs";
44
44
  import {
45
45
  PineconeProvider
@@ -325,15 +325,21 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
325
325
  ).map((hint) => hint.value.trim().toLowerCase()).filter(Boolean) : [];
326
326
  console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
327
327
  console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
328
- const cleanKeywordQuery = (text) => {
329
- return text.toLowerCase().replace(/\b(show|me|the|product|cards|of|category|find|list|browse|what|are|display)\b/g, "").trim().replace(/\s+/g, " & ");
328
+ const getDynamicKeywordQuery = () => {
329
+ if (entityHints.length > 0) {
330
+ return entityHints.map((h) => h.includes(" ") ? `"${h}"` : h).join(" & ");
331
+ }
332
+ if (queryText) {
333
+ return queryText.toLowerCase().replace(/\b(show|me|the|product[s]?|item[s]?|card[s]?|of|category|find|list|browse|what|are|display|all|under|for|in|with|about)\b/g, "").trim().replace(/\s+/g, " & ");
334
+ }
335
+ return "";
330
336
  };
337
+ const dynamicKeywordQuery = getDynamicKeywordQuery();
331
338
  const queryPromises = this.tables.map(async (table) => {
332
339
  try {
333
340
  let sqlQuery = "";
334
341
  let params = [];
335
342
  if (queryText) {
336
- const cleanedText = cleanKeywordQuery(queryText) || queryText;
337
343
  const hasEntityHints = entityHints.length > 0;
338
344
  const exactNameScoreExpr = hasEntityHints ? `+ (
339
345
  SELECT COALESCE(MAX(
@@ -352,7 +358,7 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
352
358
  ORDER BY hybrid_score DESC
353
359
  LIMIT 50
354
360
  `;
355
- params = [vectorLiteral, cleanedText];
361
+ params = [vectorLiteral, dynamicKeywordQuery];
356
362
  } else {
357
363
  sqlQuery = `
358
364
  SELECT *,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
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
6
  "license": "MIT",
@@ -203,11 +203,14 @@ Classify the query into ONE of the following intents:
203
203
 
204
204
  ## 5. DATA RULES
205
205
 
206
- - NEVER hallucinate fields
206
+ - NEVER hallucinate fields or data
207
207
  - ONLY use retrieved vector DB data
208
208
  - NO placeholders ("...", "N/A")
209
209
  - If image/link missing → REMOVE FIELD
210
210
  - Aggregate BEFORE rendering chart
211
+ - IF NO DATA IS FOUND in the retrieved context:
212
+ → DO NOT output a \`\`\`ui\`\`\` block
213
+ → Instead, state clearly that no relevant products or data were found.
211
214
 
212
215
  ---
213
216
 
@@ -151,22 +151,34 @@ export class MultiTablePostgresProvider extends BaseVectorProvider {
151
151
  console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
152
152
  console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(', ')}]`);
153
153
 
154
- // Helper to clean conversational filler for better keyword matching
155
- const cleanKeywordQuery = (text: string) => {
156
- return text
157
- .toLowerCase()
158
- .replace(/\b(show|me|the|product|cards|of|category|find|list|browse|what|are|display)\b/g, '')
159
- .trim()
160
- .replace(/\s+/g, ' & '); // Join remaining words with AND for tsquery
154
+ // Dynamic Keyword Search: Prioritize intelligently extracted hints over raw text
155
+ const getDynamicKeywordQuery = () => {
156
+ if (entityHints.length > 0) {
157
+ // Use extracted entities as high-signal keywords
158
+ return entityHints
159
+ .map(h => h.includes(' ') ? `"${h}"` : h) // Wrap multi-word hints in quotes
160
+ .join(' & ');
161
+ }
162
+
163
+ if (queryText) {
164
+ // Fallback to cleaned raw text if no high-signal hints were extracted
165
+ return queryText
166
+ .toLowerCase()
167
+ .replace(/\b(show|me|the|product[s]?|item[s]?|card[s]?|of|category|find|list|browse|what|are|display|all|under|for|in|with|about)\b/g, '')
168
+ .trim()
169
+ .replace(/\s+/g, ' & ');
170
+ }
171
+ return '';
161
172
  };
162
173
 
174
+ const dynamicKeywordQuery = getDynamicKeywordQuery();
175
+
163
176
  const queryPromises = this.tables.map(async (table) => {
164
177
  try {
165
178
  let sqlQuery = '';
166
179
  let params: unknown[] = [];
167
180
 
168
181
  if (queryText) {
169
- const cleanedText = cleanKeywordQuery(queryText) || queryText;
170
182
  const hasEntityHints = entityHints.length > 0;
171
183
  const exactNameScoreExpr = hasEntityHints
172
184
  ? `+ (
@@ -189,7 +201,7 @@ export class MultiTablePostgresProvider extends BaseVectorProvider {
189
201
  ORDER BY hybrid_score DESC
190
202
  LIMIT 50
191
203
  `;
192
- params = [vectorLiteral, cleanedText];
204
+ params = [vectorLiteral, dynamicKeywordQuery];
193
205
  } else {
194
206
  // Fallback to Vector-only Search
195
207
  sqlQuery = `