INNER CODE UNIT · Python
CategoryInfo
openfoodfacts/openfoodfacts-ai · category-detection/main.py:43
class CategoryInfo(BaseModel):
category: str = Field(..., description="Name of the category of the product.")
language: str = Field(
...,
description="Language (ISO 639-1 code) associated with the category. Example: if the `category` is in English, it should be 'en'.",
)
class CategoryPredictionResponseModel(BaseModel):
categories: list[CategoryInfo] = Field(
...,
description="List of categories associated with product. The most precise category should be returned first, then broader categories if possible. "
"Prefer categories in English, unless there there are no good translations in English available. Don't return duplicate categories in different languages. "
"If no category could not be determined, return an empty list.",
)
type: Literal[
"food",
"beauty",