r/LocalLLM • • 3d ago

Tutorial Built an open-source e-commerce RAG widget that syncs Google Shopping XML into SQLite and blocks invented promo codes with Clef-Flash (13s demo)

1 Upvotes

2 comments sorted by

0

u/[deleted] 2d ago

[removed] — view removed comment

1

u/Regolo_ai 2d ago

Another validation step, not a SQLite match. SQLite only stores the Google Shopping SKU feed (stock, price, sale_price, custom_label_0), not a promo code table.

What catches invented codes is Stage 3 in engine.py, which runs on the draft before it goes back to the user:

  1. A Clef-Flash check on /v1/systemone (promises_unauthorized_discount, threshold 0.50) that evaluates candidate_reply against store_facts and the retrieved policy context.
  2. A small deterministic check (_deterministic_output_checks) for word count and a forbidden_phrases list in policies/retail-store.yaml.

If either trips, SiteGate rewrites the draft and runs Clef-Flash a second time, falling back to a fixed refusal string if the rewrite still fails.

The trade-off is that catching a plausible fake code like WINTER15 relies on the classifier knowing this store does not issue chat promo codes. If a store actually has active coupon codes the bot is allowed to share, you would want a promo allowlist in SQLite (or a live discount API lookup) so any code string in the reply has to match an active record.