From 6c1ff531135312144223025149a6d5c49d887856 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Sat, 30 Nov 2024 14:41:02 -0600 Subject: [PATCH] utcnow is deprecated --- cookbook/structured_outputs.py | 2 +- src/marvin/types.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cookbook/structured_outputs.py b/cookbook/structured_outputs.py index b764b328b..aaae5618a 100644 --- a/cookbook/structured_outputs.py +++ b/cookbook/structured_outputs.py @@ -7,7 +7,7 @@ import marvin from pydantic import AfterValidator, Field -result = marvin.extract( +result: list[str] = marvin.extract( data="nO, i HaVe NeVeR HeaRd oF uV", target=Annotated[ str, diff --git a/src/marvin/types.py b/src/marvin/types.py index 104948750..f5ad1e58b 100644 --- a/src/marvin/types.py +++ b/src/marvin/types.py @@ -283,7 +283,9 @@ class Image(MarvinType): data: Optional[bytes] = Field(default=None, repr=False) url: Optional[str] = None format: str = "png" - timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow) + timestamp: datetime.datetime = Field( + default_factory=lambda: datetime.datetime.now(datetime.UTC) + ) detail: Literal["auto", "low", "high"] = "auto" def __init__(self, data_or_url=None, **kwargs): @@ -354,7 +356,9 @@ class Audio(MarvinType): data: bytes = Field(repr=False) _data_stream: Optional[AsyncIterator[bytes]] = PrivateAttr() url: Optional[Path] = None - timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow) + timestamp: datetime.datetime = Field( + default_factory=lambda: datetime.datetime.now(datetime.UTC) + ) format: Literal["wav", "mp3", "pcm"] = "pcm" def __init__(self, _data_stream: AsyncIterator[bytes] = None, **data):