Lavender825 commited on
Commit
029de51
·
1 Parent(s): bb3bf66

Use real product catalog in consumer interface

Browse files
Files changed (2) hide show
  1. app.py +18 -1
  2. data/product_catalog.json +0 -0
app.py CHANGED
@@ -118,6 +118,23 @@ def _load_products_from_json():
118
  return []
119
 
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  def _load_products_from_explanation_csv():
122
  path = REPORT_DIR / "explanation_attention_summary.csv"
123
  if not path.exists():
@@ -178,7 +195,7 @@ def _coerce_product(item, idx=0):
178
 
179
 
180
  def _load_products():
181
- products = _load_products_from_json() or _load_products_from_explanation_csv()
182
  if products:
183
  return products
184
  return FALLBACK_PRODUCTS
 
118
  return []
119
 
120
 
121
+ def _load_products_from_catalog():
122
+ path = DATA_DIR / "product_catalog.json"
123
+ try:
124
+ if path.exists():
125
+ products = json.loads(path.read_text(encoding="utf-8"))
126
+ if isinstance(products, list) and products:
127
+ out = []
128
+ for i, item in enumerate(products):
129
+ item = dict(item)
130
+ item.setdefault("source", "real product catalog")
131
+ out.append(_coerce_product(item, i + 1))
132
+ return out
133
+ except Exception:
134
+ pass
135
+ return []
136
+
137
+
138
  def _load_products_from_explanation_csv():
139
  path = REPORT_DIR / "explanation_attention_summary.csv"
140
  if not path.exists():
 
195
 
196
 
197
  def _load_products():
198
+ products = _load_products_from_catalog() or _load_products_from_json() or _load_products_from_explanation_csv()
199
  if products:
200
  return products
201
  return FALLBACK_PRODUCTS
data/product_catalog.json ADDED
The diff for this file is too large to render. See raw diff