mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
fix: More Fault Tolerance with OpenAI Schemas (#4328)
Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
parent
433336b8b4
commit
a2bdb02a7f
1 changed files with 3 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
from textwrap import dedent
|
||||
from typing import Any
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
|
@ -72,8 +73,8 @@ class OpenAIIngredient(OpenAIBase):
|
|||
),
|
||||
)
|
||||
|
||||
@field_validator("quantity")
|
||||
def coerce_none_qty(cls, v: float | None) -> float:
|
||||
@field_validator("confidence", "quantity", mode="before")
|
||||
def coerce_none_float(cls, v: Any) -> Any:
|
||||
return v or 0
|
||||
|
||||
@field_validator("confidence")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue