mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-23 18:55:15 -05:00
feat: ✨ Add brute strategy to ingredient processor (#744)
* fix UI column width * words * update parser to support diff strats * add new model url * make button more visible * fix nutrition error * feat(backend): ✨ add 'brute' strategy for parsing ingredients * satisfy linter * update UI for creation page * feat(backend): ✨ log 422 errors in detail when not in PRODUCTION * add strategy selector Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import enum
|
||||
from typing import Optional, Union
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
@@ -30,10 +31,40 @@ class IngredientUnit(CreateIngredientUnit):
|
||||
class RecipeIngredient(CamelModel):
|
||||
title: Optional[str]
|
||||
note: Optional[str]
|
||||
unit: Optional[Union[CreateIngredientUnit, IngredientUnit]]
|
||||
food: Optional[Union[CreateIngredientFood, IngredientFood]]
|
||||
unit: Optional[Union[IngredientUnit, CreateIngredientUnit]]
|
||||
food: Optional[Union[IngredientFood, CreateIngredientFood]]
|
||||
disable_amount: bool = True
|
||||
quantity: float = 1
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class IngredientConfidence(CamelModel):
|
||||
average: float = None
|
||||
comment: float = None
|
||||
name: float = None
|
||||
unit: float = None
|
||||
quantity: float = None
|
||||
food: float = None
|
||||
|
||||
|
||||
class ParsedIngredient(CamelModel):
|
||||
input: Optional[str]
|
||||
confidence: IngredientConfidence = IngredientConfidence()
|
||||
ingredient: RecipeIngredient
|
||||
|
||||
|
||||
class RegisteredParser(str, enum.Enum):
|
||||
nlp = "nlp"
|
||||
brute = "brute"
|
||||
|
||||
|
||||
class IngredientsRequest(CamelModel):
|
||||
parser: RegisteredParser = RegisteredParser.nlp
|
||||
ingredients: list[str]
|
||||
|
||||
|
||||
class IngredientRequest(CamelModel):
|
||||
parser: RegisteredParser = RegisteredParser.nlp
|
||||
ingredient: str
|
||||
|
||||
Reference in New Issue
Block a user