Skip to content

v0.35.0

Compare
Choose a tag to compare
@jackmpcollins jackmpcollins released this 06 Jan 03:33
· 13 commits to main since this release

What's Changed

UserMessage now accepts image urls, image bytes, and document bytes directly using the ImageUrl, ImageBytes, and DocumentBytes types.

Example of new UserMessage syntax and DocumentBytes

from pathlib import Path

from magentic import chatprompt, DocumentBytes, Placeholder, UserMessage
from magentic.chat_model.anthropic_chat_model import AnthropicChatModel


@chatprompt(
    UserMessage(
        [
            "Repeat the contents of this document.",
            Placeholder(DocumentBytes, "document_bytes"),
        ]
    ),
    model=AnthropicChatModel("claude-3-5-sonnet-20241022"),
)
def read_document(document_bytes: bytes) -> str: ...


document_bytes = Path("...").read_bytes()
read_document(document_bytes)
# 'This is a test PDF.'

PRs

New Contributors

Full Changelog: v0.34.1...v0.35.0