Spaces:
Sleeping
Sleeping
fixed a bug
Browse files- ui_expanded_matching.py +10 -1
ui_expanded_matching.py
CHANGED
@@ -168,6 +168,9 @@ def categorize_products_with_openai_reranking(product_input, is_file=False, use_
|
|
168 |
return product, []
|
169 |
|
170 |
candidates = all_similarities[product][:embedding_top_n]
|
|
|
|
|
|
|
171 |
if not candidates:
|
172 |
return product, []
|
173 |
|
@@ -175,10 +178,16 @@ def categorize_products_with_openai_reranking(product_input, is_file=False, use_
|
|
175 |
expanded_text = expanded_descriptions.get(product, product) if use_expansion else product
|
176 |
|
177 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
# Pass 0.0 as threshold to get all results - apply threshold at display time
|
179 |
category_matches = rank_categories_openai(
|
180 |
product=product,
|
181 |
-
categories=
|
182 |
expanded_description=expanded_text,
|
183 |
client=openai_client,
|
184 |
model="gpt-4o-mini",
|
|
|
168 |
return product, []
|
169 |
|
170 |
candidates = all_similarities[product][:embedding_top_n]
|
171 |
+
|
172 |
+
print(f"candidates: {candidates}")
|
173 |
+
|
174 |
if not candidates:
|
175 |
return product, []
|
176 |
|
|
|
178 |
expanded_text = expanded_descriptions.get(product, product) if use_expansion else product
|
179 |
|
180 |
try:
|
181 |
+
# FIXED: Filter categories to only include those in the current product's candidates
|
182 |
+
product_category_ids = [cat_id for cat_id, _ in candidates]
|
183 |
+
filtered_categories = {cat_id: category_descriptions[cat_id]
|
184 |
+
for cat_id in product_category_ids
|
185 |
+
if cat_id in category_descriptions}
|
186 |
+
|
187 |
# Pass 0.0 as threshold to get all results - apply threshold at display time
|
188 |
category_matches = rank_categories_openai(
|
189 |
product=product,
|
190 |
+
categories=filtered_categories, # Pass only this product's relevant categories
|
191 |
expanded_description=expanded_text,
|
192 |
client=openai_client,
|
193 |
model="gpt-4o-mini",
|