fix(match): prefer standard/cheapest variant, not premium, for truthful estimates
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.
This commit is contained in:
12
app.py
12
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)
|
||||
|
||||
Reference in New Issue
Block a user