From 925174d80e6c791af60ae1519b71d12f9323917f Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Fri, 30 Oct 2026 14:51:18 +0100 Subject: [PATCH] fix(match): prefer standard/cheapest variant, not premium, for truthful estimates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A generic catalog item (e.g. 'Entrecote ½ kg') could match a premium offer (Wagyu 250 €/kg, US-Beef), inflating the estimate — correct math, wrong product. Tell the matcher to pick the ordinary/standard variant at the lowest price and avoid premium/luxury (Wagyu, Dry-Aged, US-Beef, øko-premium) unless the item names it. No price caps (that would be guesswork) — the estimate stays raw offer price × quantity. Version marker in the match signature forces a re-match so the new logic takes effect. --- app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index a9444f4..2e932b7 100644 --- a/app.py +++ b/app.py @@ -423,9 +423,12 @@ def match_offers_ai(): # Skip the (daily) match call when the offer set hasn't changed since the # last successful match — the avis only turns over weekly, so this avoids a - # pointless Claude call most days. + # pointless Claude call most days. The leading version forces a re-match + # whenever the matching logic/prompt changes (bump it when editing them). + MATCH_VERSION = "v2-standard-not-premium" sig = hashlib.md5( - "\n".join(sorted(o['id'] + '|' + (o.get('heading') or '') for o in offers)) + (MATCH_VERSION + "\n" + "\n".join( + sorted(o['id'] + '|' + (o.get('heading') or '') for o in offers))) .encode('utf-8')).hexdigest() with get_db() as c: if _meta_get(c, 'last_match_sig') == sig and \ @@ -452,7 +455,10 @@ def match_offers_ai(): "findes. Vær striks: match kun når det tydeligt er samme varetype " "(fx entrecôte↔entrecôte-tilbud). Match IKKE blot på mærke eller løst " "beslægtede varer (fx 'Nutella 1kg glas' må IKKE matche 'Nutella " - "julekalender'). Vælg det billigste ved flere ens. Returnér KUN et " + "julekalender'). Når varen er generisk (fx 'Entrecote ½ kg'), vælg den " + "ALMINDELIGE/standard variant til den LAVESTE pris — undgå premium-/" + "luksus-varianter (Wagyu, Dry-Aged, US-Beef, øko-premium) medmindre varen " + "selv nævner det, da de giver et urealistisk højt estimat. Returnér KUN et " 'JSON-array [{"item_key":"...","offer_id":"..."}] med de sikre match, ' "intet andet.") client = anthropic.Anthropic(max_retries=CLAUDE_MAX_RETRIES)