3d330655a6
Python 3.11 + FastAPI con tre endpoint (/health, /auth/test, /recipes/generate). Autenticazione via header X-App-Password, validazione input Pydantic, chiamata in streaming a NVIDIA NIM (nemotron-3-ultra-550b-a55b) con thinking. Dockerizzato con docker-compose; configurazione tramite .env. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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]
|