-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support images directly in UserMessage (#387)
* Move OpenaiChatModel UserImageMessage support into openai_chat_model.py * Implement message_to_anthropic_message for UserImageMessage * Get test passing using _combine_messages * WIP: Add ImageBytes, ImageUrl. Expand UserMessage types. * Remove duplicate message_to_x_message for UserImageMessage * Add make test-fix-snapshots * Move image_bytes fixtures into top-level conftest * Fix typing for ImageBytes.mime_type. Add tests * Fix mypy errors on UserMessage conversion typing * Validate bytes are valid image * Use ImageBytes in UserImageMessage conversion functions * Add typevar UserMessageContentT * Fix mypy errors due to UserMessage now generic * Attempt to coerce type in Placeholder.format * Fix: list -> Iterable in UserMessage serialization * Fix: return message in message_to_openai_message * Make Placeholder a BaseModel * Make ContentT covariant * Add covariant PlaceholderT * Fix type checking for UserMessage format * Remove unused type ignores * Require pydantic 2.10 to fix generic in BaseModel * Revert "Remove unused type ignores" This reverts commit 87b81ca. * Remove pydantic url from error messages in tests * Add TypeAlias UserMessageContentBlock * Add trailing .0 to pydantic version in pyproject * Use TypeAdapter for Placeholder coercion * Add typing-extensions as dependency * Remove todo for testing AssistantMessage with FunctionCall * Ignore logfire not configured warnings * Deprecate UserImageMessage * Add make test-snapshots-create and improve naming * Add tests for UserMessage with ImageBytes/Url * Upgrade mypy version * Add tests for ImageBytes with ChatModel * Improve AssistantMessage typing, add tests * Handle Literal string in AssistantMessage.format typing * Add NotPlaceholder Protocol * Fix type hints for UserMessage * Add github issue link for failing type tests * Improve handling of Literal in AssistantMessage typing * Rename to PlaceholderTypeT * Remove done todo re name not in kwargs error * Add top-level imports for ImageBytes, ImageUrl * Update docs for vision * Add note about Placeholder coercion
- Loading branch information
1 parent
755b553
commit 0cb9e7b
Showing
31 changed files
with
1,348 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.