feat(offers): Danish translation and AI matching via Claude
Offers come from the German avis, so add Claude-backed language help, reusing BlaaAi's ANTHROPIC_API_KEY + Haiku pattern. Both degrade gracefully: without a key, offers stay German and the token heuristic still matches. - Translate offer headings DE→DA in the fetch job, cached per heading in a translations table (only new headings cost a call). UI shows Danish primary + German subtitle for in-store navigation. - AI match the fixed list against offers (offer_matches table): Claude returns same-product matches, far more precise than the token heuristic (which false-matched e.g. Nutella jar → advent calendar). load_deals() prefers AI matches, falls back to the heuristic. - Haiku 5.5 by default (MATCH_MODEL/TRANSLATE_MODEL env overridable to Sonnet); no temperature param (Haiku 5.5 rejects non-default). - requirements: add anthropic
This commit is contained in:
@@ -95,7 +95,7 @@
|
||||
<div class="row{% if r.bought %} bought{% endif %}">
|
||||
<div>
|
||||
<div class="r-name">{{ r.sec.emoji }} {{ r.item.name }}{% if r.bought %} ✓{% endif %}</div>
|
||||
<div class="r-meta">{{ r.offer.heading }} · {{ r.offer.catalog }}{% if r.offer.page %} · s. {{ r.offer.page }}{% endif %}</div>
|
||||
<div class="r-meta">🏷 {{ r.offer.heading_da or r.offer.heading }} · {{ r.offer.catalog }}{% if r.offer.page %} · s. {{ r.offer.page }}{% endif %}</div>
|
||||
</div>
|
||||
<div class="r-right">
|
||||
<div class="r-price">{{ "{:.2f}".format(r.offer.price_eur).replace(".",",") }} € <span class="r-dkk">≈ {{ "{:.0f}".format(r.offer_dkk) }} kr.</span></div>
|
||||
@@ -124,7 +124,7 @@
|
||||
<div class="sec-group">
|
||||
<div class="sec-h">🏷 Lübeck-tilbud</div>
|
||||
<div class="chips">
|
||||
{% for p in picks_remaining %}<span class="chip">{{ p.heading }}</span>{% endfor %}
|
||||
{% for p in picks_remaining %}<span class="chip">{{ p.heading_da or p.heading }}</span>{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -140,8 +140,8 @@
|
||||
{% for o in other %}
|
||||
<div class="row">
|
||||
<div>
|
||||
<div class="r-name">{{ o.heading }}</div>
|
||||
<div class="r-meta">{{ o.catalog }}{% if o.page %} · s. {{ o.page }}{% endif %}{% if o.unit and o.size_from %} · {{ o.size_from|int }} {{ o.unit }}{% endif %}</div>
|
||||
<div class="r-name">{{ o.heading_da or o.heading }}</div>
|
||||
<div class="r-meta">{% if o.heading_da and o.heading_da != o.heading %}🇩🇪 {{ o.heading }} · {% endif %}{{ o.catalog }}{% if o.page %} · s. {{ o.page }}{% endif %}{% if o.unit and o.size_from %} · {{ o.size_from|int }} {{ o.unit }}{% endif %}</div>
|
||||
</div>
|
||||
<div class="r-right">
|
||||
<div class="r-price">{{ "{:.2f}".format(o.price_eur).replace(".",",") }} €</div>
|
||||
|
||||
Reference in New Issue
Block a user