Skip to content

v0.20.0

Compare
Choose a tag to compare
@jackmpcollins jackmpcollins released this 19 Apr 06:47
· 94 commits to main since this release

Warning

The default model for magentic is now gpt-4-turbo instead of gpt-3.5-turbo. See Configuration for how to change this.

What's Changed

Full Changelog: v0.19.0...v0.20.0


Having a default of gpt-4-turbo enables using vision with function calling by default

from pydantic import BaseModel, Field

from magentic import chatprompt, UserMessage
from magentic.vision import UserImageMessage


IMAGE_URL_WOODEN_BOARDWALK = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"


class ImageDetails(BaseModel):
    description: str = Field(description="A brief description of the image.")
    name: str = Field(description="A short name.")


@chatprompt(
    UserMessage("Describe the following image in one sentence."),
    UserImageMessage(IMAGE_URL_WOODEN_BOARDWALK),
)
def describe_image() -> ImageDetails: ...


image_details = describe_image()
print(image_details.name)
# 'Wooden Boardwalk in Green Wetland'
print(image_details.description)
# 'A serene wooden boardwalk meanders through a lush green wetland under a blue sky dotted with clouds.'