@reactionary/meilisearch 0.6.4 → 0.6.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.
|
@@ -31,6 +31,10 @@ class MeilisearchProductRecommendationsCapability extends ProductRecommendations
|
|
|
31
31
|
console.warn("AI embedding is not enabled in configuration. Similar product recommendations will be based on keyword matching, which may not provide optimal results.");
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
34
|
+
if (this.context.isBot && !this.config.useRecommendationsForBots) {
|
|
35
|
+
console.warn("Bot traffic detected. Recommendations are disabled for bots in configuration to save on API costs. Returning empty recommendations.");
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
34
38
|
try {
|
|
35
39
|
const response = await index.searchSimilarDocuments(this.getSimilarProductsRecommendationsPayload(query));
|
|
36
40
|
return this.parseRecommendations(response, "similar");
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/meilisearch",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"vitest": "^4.0.9",
|
|
9
9
|
"@nx/vite": "22.4.5",
|
|
10
|
-
"@reactionary/core": "0.6.
|
|
10
|
+
"@reactionary/core": "0.6.6",
|
|
11
11
|
"zod": "4.1.9",
|
|
12
12
|
"meilisearch": "^0.55.0"
|
|
13
13
|
},
|
|
@@ -4,7 +4,8 @@ const MeilisearchConfigurationSchema = z.looseObject({
|
|
|
4
4
|
apiKey: z.string(),
|
|
5
5
|
indexName: z.string(),
|
|
6
6
|
orderIndexName: z.string(),
|
|
7
|
-
useAIEmbedding: z.string().optional()
|
|
7
|
+
useAIEmbedding: z.string().optional(),
|
|
8
|
+
useRecommendationsForBots: z.boolean().default(false).meta({ description: "Whether to use recommendations for bot traffic. By default, recommendations are not used for bots to save on API costs, but enabling this can provide a better experience for bot traffic such as search engine crawlers." })
|
|
8
9
|
});
|
|
9
10
|
export {
|
|
10
11
|
MeilisearchConfigurationSchema
|
|
@@ -5,5 +5,6 @@ export declare const MeilisearchConfigurationSchema: z.ZodObject<{
|
|
|
5
5
|
indexName: z.ZodString;
|
|
6
6
|
orderIndexName: z.ZodString;
|
|
7
7
|
useAIEmbedding: z.ZodOptional<z.ZodString>;
|
|
8
|
+
useRecommendationsForBots: z.ZodDefault<z.ZodBoolean>;
|
|
8
9
|
}, z.core.$loose>;
|
|
9
10
|
export type MeilisearchConfiguration = z.infer<typeof MeilisearchConfigurationSchema>;
|