Skip to content

Instantly share code, notes, and snippets.

@jxnl
Last active September 10, 2020 18:56
Show Gist options
  • Save jxnl/eb4bb76b60ae48bf0dfa3545e249ff8c to your computer and use it in GitHub Desktop.
Save jxnl/eb4bb76b60ae48bf0dfa3545e249ff8c to your computer and use it in GitHub Desktop.
@flight.expose("/pdp/carousel/")
async def carousels_from_category(
client_id: int,
anchor_class: str = "shirt",
anchor_department: str = "Tops",
num_results: int = 9,
filter_type: str = "[match|pair]",
debug_mode: bool = False,
verbose: bool = False,
):
FilterSwitch = {"match": CarouselMatchAttribute(), "pair": PairsWithAnchor()}
recommender = Flight(
client_id=client_id,
item_type="sku_id",
)
recommender = await (
recommender.initialize(
include_candidates=[
AvailableSkusByChannel(channel="shop_your_look"),
Qualifications(),
],
scorer=MixerScoring(functionality="shop_p_sale"),
)
)
recommender = (
recommender
| SkuAugment(columns=[ "style_variant_id", "class", "department", "silhouette", "seasonal_intent"])
| Equals(column="seasonal_intent", value="fall/winter")
| Equals(column="department", value=department)
| Sort(order_by="score")
| Kaleidoset(n=num_results, rho=0.5)
)
resp = recommender.response()
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment