Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/turbopuffer-0.1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Nov 30, 2024
2 parents 4e83a92 + 9ae60e1 commit 82576f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
12 changes: 7 additions & 5 deletions cookbook/gh_util/custom_assistant.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["marvin", "gh-util"]
# ///

from gh_util.api import functions # pip install gh-util
from marvin.beta.applications import Application
from pydantic import BaseModel, Field
Expand All @@ -13,8 +17,6 @@ class Memory(BaseModel):
tools=[f for f in functions if f.__name__ != "run_git_command"],
)

# $ marvin assistant register cookbook/gh_util/custom_assistant.py:octocat

# > what's the latest release of prefecthq/marvin?

# see https://github.com/PrefectHQ/marvin/pull/875
if __name__ == "__main__":
# uv run cookbook/gh_util/custom_assistant.py
octocat.chat("what's the latest release of prefecthq/marvin?")
20 changes: 20 additions & 0 deletions cookbook/structured_outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# /// script
# dependencies = ["marvin"]
# ///

from typing import Annotated

import marvin
from pydantic import AfterValidator, Field

result: list[str] = marvin.extract(
data="nO, i HaVe NeVeR HeaRd oF uV",
target=Annotated[
str,
Field(description="letters, only vowels"),
AfterValidator(lambda x: x.upper()),
],
)

assert isinstance(result, list)
assert set(sorted(result)) == {"A", "E", "I", "O", "U"}
8 changes: 6 additions & 2 deletions src/marvin/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.timezone.utc)
)
detail: Literal["auto", "low", "high"] = "auto"

def __init__(self, data_or_url=None, **kwargs):
Expand Down Expand Up @@ -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.timezone.utc)
)
format: Literal["wav", "mp3", "pcm"] = "pcm"

def __init__(self, _data_stream: AsyncIterator[bytes] = None, **data):
Expand Down

0 comments on commit 82576f8

Please sign in to comment.