39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class Ingredient(BaseModel):
|
||
|
|
name: str = Field(..., max_length=100)
|
||
|
|
quantity: float = Field(..., gt=0)
|
||
|
|
unit: str = Field(..., max_length=50)
|
||
|
|
|
||
|
|
|
||
|
|
class Preferences(BaseModel):
|
||
|
|
servings: int = Field(2, ge=1, le=20)
|
||
|
|
maxTimeMinutes: int = Field(60, ge=5, le=300)
|
||
|
|
difficulty: str = Field("facile", max_length=50)
|
||
|
|
diet: str = Field("nessuna", max_length=100)
|
||
|
|
allergies: list[str] = Field(default_factory=list)
|
||
|
|
avoid: list[str] = Field(default_factory=list)
|
||
|
|
tools: list[str] = Field(default_factory=list)
|
||
|
|
|
||
|
|
|
||
|
|
class RecipeRequest(BaseModel):
|
||
|
|
ingredients: list[Ingredient] = Field(..., min_length=1, max_length=30)
|
||
|
|
preferences: Preferences = Field(default_factory=Preferences)
|
||
|
|
|
||
|
|
|
||
|
|
class Recipe(BaseModel):
|
||
|
|
title: str
|
||
|
|
servings: int
|
||
|
|
timeMinutes: int
|
||
|
|
difficulty: str
|
||
|
|
whyThisRecipe: str
|
||
|
|
usedIngredients: list[str]
|
||
|
|
optionalMissingIngredients: list[str]
|
||
|
|
steps: list[str]
|
||
|
|
notes: list[str]
|
||
|
|
|
||
|
|
|
||
|
|
class RecipeResponse(BaseModel):
|
||
|
|
recipes: list[Recipe]
|