Skip to content

Commit 765b4bd

Browse files
Skip analyzer agent when user preferences are None or empty (#2)
- Add check before calling ingredientAnalyzerAgent - Check for null, empty string, or 'None' preferences - This prevents unnecessary API calls and reduces failures Fixes EIG-247 Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 1c9ac4d commit 765b4bd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

supabase/functions/ingredicheck/analyzer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ export async function analyze(ctx: Context) {
5959
}
6060
}
6161

62+
// Skip analyzer agent if user has no preferences set
63+
const hasValidPreferences = requestBody.userPreferenceText &&
64+
requestBody.userPreferenceText.trim() !== "" &&
65+
requestBody.userPreferenceText.trim().toLowerCase() !== "none"
66+
6267
const ingredientRecommendations =
63-
product.ingredients && product.ingredients.length !== 0
68+
product.ingredients && product.ingredients.length !== 0 && hasValidPreferences
6469
? await ingredientAnalyzerAgent(ctx, product, requestBody.userPreferenceText)
6570
: []
6671

0 commit comments

Comments
 (0)