Repository navigation
v0.35.0
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
- Accept Sequence[Message] instead of list for Chat by @alexchandel in #390
- Bump astral-sh/setup-uv from 4 to 5 by @dependabot in #393
- Support images directly in UserMessage by @jackmpcollins in #387
- Add DocumentBytes for submitting PDF documents by @jackmpcollins in #395
New Contributors
- @alexchandel made their first contribution in #390
Full Changelog: v0.34.1...v0.35.0