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:
@@ -238,7 +238,7 @@
|
||||
{% if item.get('de') %}<span class="de">🇩🇪 {{ item.de }}</span>{% endif %}
|
||||
{% if item.get('note') %}<span class="note">{{ item.note }}</span>{% endif %}
|
||||
{% set d = deals.get(item.key) %}
|
||||
{% if d %}<a class="deal" href="/tilbud" title="{{ d.heading }} ({{ d.catalog }})">🏷 på tilbud: {{ "{:.2f}".format(d.price_eur).replace(".",",") }} € ≈ {{ "{:.0f}".format(d.price_eur * eur_dkk) }} kr. · {{ d.heading }}</a>{% endif %}
|
||||
{% if d %}<a class="deal" href="/tilbud" title="{{ d.heading }} ({{ d.catalog }})">🏷 på tilbud: {{ "{:.2f}".format(d.price_eur).replace(".",",") }} € ≈ {{ "{:.0f}".format(d.price_eur * eur_dkk) }} kr. · {{ d.heading_da or d.heading }}</a>{% endif %}
|
||||
</div>
|
||||
<div class="item-qty">
|
||||
<input type="text" value="{{ s.get('qty') or item.qty }}" placeholder="{{ item.qty }}"
|
||||
@@ -278,7 +278,8 @@
|
||||
<div class="item-row{% if ps.get('checked') %} checked{% endif %}" data-key="{{ o.id }}" id="pick-{{ o.id }}">
|
||||
<div class="item-check"><input type="checkbox" {% if ps.get('checked') %}checked{% endif %} onchange="toggleOffer(this)"></div>
|
||||
<div class="item-name">
|
||||
{{ o.heading }}
|
||||
{{ o.heading_da or o.heading }}
|
||||
{% if o.heading_da and o.heading_da != o.heading %}<span class="de">🇩🇪 {{ o.heading }}</span>{% endif %}
|
||||
<span class="note">{{ o.catalog }}{% if o.page %} · s. {{ o.page }}{% endif %}{% if o.unit %} · {{ o.size_from|int if o.size_from else '' }}{{ o.unit }}{% endif %}</span>
|
||||
</div>
|
||||
<div class="item-qty" style="display:flex;align-items:center;color:var(--muted);font-size:12px">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
.offer.picked { background: var(--green-light); }
|
||||
.offer input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--green); cursor: pointer; }
|
||||
.o-name { font-size: 14px; }
|
||||
.o-de { font-size: 10px; color: #b0aba3; font-style: italic; margin-top: 1px; }
|
||||
.o-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
|
||||
.o-price { text-align: right; white-space: nowrap; }
|
||||
.o-eur { font-family: var(--mono); font-weight: 600; font-size: 15px; }
|
||||
@@ -87,7 +88,8 @@
|
||||
<label class="offer{% if o.picked %} picked{% endif %}" data-name="{{ o.heading|lower }}">
|
||||
<input type="checkbox" {% if o.picked %}checked{% endif %} onchange="togglePick(this, '{{ o.id }}')">
|
||||
<div>
|
||||
<div class="o-name">{{ o.heading }}</div>
|
||||
<div class="o-name">{{ o.heading_da or o.heading }}</div>
|
||||
{% if o.heading_da and o.heading_da != o.heading %}<div class="o-de">🇩🇪 {{ o.heading }}</div>{% endif %}
|
||||
<div class="o-meta">
|
||||
{% if o.page %}s. {{ o.page }}{% endif %}
|
||||
{% if o.unit and o.size_from %} · {{ o.size_from|int }}{% if o.size_to and o.size_to != o.size_from %}–{{ o.size_to|int }}{% endif %} {{ o.unit }}{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user