HelloWorld0204 commited on
Commit
57c3bdc
·
verified ·
1 Parent(s): fa05545

Upload 22 files

Browse files
Files changed (1) hide show
  1. app.py +44 -2
app.py CHANGED
@@ -3726,13 +3726,21 @@ def ai_recommend_outfits(payload: dict[str, Any] = Body(default_factory=dict)) -
3726
  "engine_version": "scoring-v2",
3727
  }
3728
 
3729
- if occasion == "wedding":
 
3730
  others_only = [
3731
  i for i in wardrobe_items
3732
  if i.get("type") == "others" or i.get("type") not in {"topwear", "bottomwear"}
3733
  ]
3734
  if others_only:
3735
- wardrobe_items = _filter_garments_for_wedding(others_only)
 
 
 
 
 
 
 
3736
 
3737
  top_selected = _normalize_wardrobe_item(top_selected_raw) if isinstance(top_selected_raw, dict) else None
3738
  bottom_selected = _normalize_wardrobe_item(bottom_selected_raw) if isinstance(bottom_selected_raw, dict) else None
@@ -3766,6 +3774,40 @@ def ai_recommend_outfits(payload: dict[str, Any] = Body(default_factory=dict)) -
3766
  if i.get("type") == "others" or i.get("type") not in {"topwear", "bottomwear"}
3767
  ]
3768
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3769
  if other_selected and (other_selected.get("type") == "others" or other_selected.get("type") not in {"topwear", "bottomwear"}):
3770
  return _maybe_cache(_fallback_rule_recommendations(
3771
  occasion=occasion,
 
3726
  "engine_version": "scoring-v2",
3727
  }
3728
 
3729
+ is_wedding = str(occasion or "").strip().lower() == "wedding"
3730
+ if is_wedding:
3731
  others_only = [
3732
  i for i in wardrobe_items
3733
  if i.get("type") == "others" or i.get("type") not in {"topwear", "bottomwear"}
3734
  ]
3735
  if others_only:
3736
+ wedding_filtered = _filter_garments_for_wedding(others_only)
3737
+ for item in wedding_filtered:
3738
+ item["type"] = "others"
3739
+ wardrobe_items = wedding_filtered
3740
+ else:
3741
+ wardrobe_items = []
3742
+ top_selected_raw = None
3743
+ bottom_selected_raw = None
3744
 
3745
  top_selected = _normalize_wardrobe_item(top_selected_raw) if isinstance(top_selected_raw, dict) else None
3746
  bottom_selected = _normalize_wardrobe_item(bottom_selected_raw) if isinstance(bottom_selected_raw, dict) else None
 
3774
  if i.get("type") == "others" or i.get("type") not in {"topwear", "bottomwear"}
3775
  ]
3776
 
3777
+ if is_wedding:
3778
+ if other_selected and (
3779
+ other_selected.get("type") == "others"
3780
+ or other_selected.get("type") not in {"topwear", "bottomwear"}
3781
+ ):
3782
+ return _maybe_cache(_fallback_rule_recommendations(
3783
+ occasion=occasion,
3784
+ case_name="E",
3785
+ tops=[],
3786
+ bottoms=[],
3787
+ others=[other_selected],
3788
+ top_k=max(1, min(top_k, 20)),
3789
+ include_pair_outfits=False,
3790
+ include_other_outfits=True,
3791
+ ))
3792
+ if all_others:
3793
+ return _maybe_cache(_fallback_rule_recommendations(
3794
+ occasion=occasion,
3795
+ case_name="E",
3796
+ tops=[],
3797
+ bottoms=[],
3798
+ others=all_others,
3799
+ top_k=max(1, min(top_k, 20)),
3800
+ include_pair_outfits=False,
3801
+ include_other_outfits=True,
3802
+ ))
3803
+ return _maybe_cache({
3804
+ "occasion": occasion, "case": "A",
3805
+ "selected_outfit_score": None, "recommendations": [],
3806
+ "total_combinations_checked": 0,
3807
+ "notice": "Add at least one item in Others to get wedding recommendations.",
3808
+ "engine_version": "scoring-v2",
3809
+ })
3810
+
3811
  if other_selected and (other_selected.get("type") == "others" or other_selected.get("type") not in {"topwear", "bottomwear"}):
3812
  return _maybe_cache(_fallback_rule_recommendations(
3813
  occasion=occasion,