in experiments/legacy/backend/api.py [0:0]
def suggest_categories(product: Product) -> list[list[str]]:
"""Suggest categories for product.
Args:
- description: Sparse description of product
- category (optional): If one or more category levels is known
include this to restrict the suggestions space.
- example 1: ['Mens']
will only return suggestiongs with top level category 'Mens'
- example 2: ['Mens', 'Pants']
will only return suggestions with top level category 'Mens'
and second level category 'Pants'
- main_image_base64 (optional): base64 encoded string representing product
image.
Returns:
The category suggestions ordered from high to low confidence. Returned as
a list of lists. Each inner list represents one fully qualified category
with each string in the list representing a category level e.g.
['Mens', 'Pants', 'Jeans']
"""
return category.retrieve_and_rank(
product.description,
product.main_image_base64,
base64=True,
filters=product.category)