@retrivora-ai/rag-engine 1.1.6 → 1.1.7

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/index.js CHANGED
@@ -250,7 +250,19 @@ function MessageBubble({
250
250
  }
251
251
  return { productsFromContent: products, cleanContent: content.trim() };
252
252
  }, [message.content, isUser]);
253
- const allProducts = [...productsFromSources, ...productsFromContent];
253
+ const allProducts = import_react4.default.useMemo(() => {
254
+ if (productsFromContent.length > 0) return productsFromContent;
255
+ const uniqueProducts = [];
256
+ const seenIds = /* @__PURE__ */ new Set();
257
+ for (const p of productsFromSources) {
258
+ const identifier = p.id || p.name;
259
+ if (!seenIds.has(identifier)) {
260
+ seenIds.add(identifier);
261
+ uniqueProducts.push(p);
262
+ }
263
+ }
264
+ return uniqueProducts;
265
+ }, [productsFromSources, productsFromContent]);
254
266
  const hasProducts = allProducts.length > 0;
255
267
  return /* @__PURE__ */ import_react4.default.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ import_react4.default.createElement(
256
268
  "div",
package/dist/index.mjs CHANGED
@@ -208,7 +208,19 @@ function MessageBubble({
208
208
  }
209
209
  return { productsFromContent: products, cleanContent: content.trim() };
210
210
  }, [message.content, isUser]);
211
- const allProducts = [...productsFromSources, ...productsFromContent];
211
+ const allProducts = React4.useMemo(() => {
212
+ if (productsFromContent.length > 0) return productsFromContent;
213
+ const uniqueProducts = [];
214
+ const seenIds = /* @__PURE__ */ new Set();
215
+ for (const p of productsFromSources) {
216
+ const identifier = p.id || p.name;
217
+ if (!seenIds.has(identifier)) {
218
+ seenIds.add(identifier);
219
+ uniqueProducts.push(p);
220
+ }
221
+ }
222
+ return uniqueProducts;
223
+ }, [productsFromSources, productsFromContent]);
212
224
  const hasProducts = allProducts.length > 0;
213
225
  return /* @__PURE__ */ React4.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ React4.createElement(
214
226
  "div",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
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",
@@ -100,7 +100,26 @@ export function MessageBubble({
100
100
  return { productsFromContent: products, cleanContent: content.trim() };
101
101
  }, [message.content, isUser]);
102
102
 
103
- const allProducts = [...productsFromSources, ...productsFromContent];
103
+ const allProducts = React.useMemo(() => {
104
+ // If the LLM explicitly provided products in a structured format, only show those.
105
+ // This ensures we only show what the assistant actually "displayed" as a result.
106
+ if (productsFromContent.length > 0) return productsFromContent;
107
+
108
+ // Fallback: If no structured products, show unique products from sources.
109
+ const uniqueProducts: Product[] = [];
110
+ const seenIds = new Set();
111
+
112
+ for (const p of productsFromSources) {
113
+ const identifier = p.id || p.name;
114
+ if (!seenIds.has(identifier)) {
115
+ seenIds.add(identifier);
116
+ uniqueProducts.push(p);
117
+ }
118
+ }
119
+
120
+ return uniqueProducts;
121
+ }, [productsFromSources, productsFromContent]);
122
+
104
123
  const hasProducts = allProducts.length > 0;
105
124
 
106
125
  return (