Python: fixed image handling in anthropic and added convenience method on datacontent#2083
Merged
eavanvalkenburg merged 6 commits intomicrosoft:mainfrom Nov 12, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes image handling in the Anthropic integration by properly converting DataContent images to Anthropic's expected base64 format and adds convenience methods for extracting data from data URIs.
- Added
get_data_bytes()andget_data_bytes_as_str()methods to DataContent for extracting base64 data from data URIs - Updated Anthropic client to correctly format image DataContent with base64 source type
- Added integration test for image handling with the Anthropic API
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_types.py | Added convenience methods to DataContent class for extracting base64 data from data URIs |
| python/packages/anthropic/agent_framework_anthropic/_chat_client.py | Fixed image handling by using the new convenience method to properly format image data in Anthropic's expected format with base64 source type, and added debug logging for unsupported media types |
| python/packages/anthropic/tests/test_anthropic_client.py | Added integration test for image description functionality using a sample JPEG image |
| python/packages/anthropic/tests/assets/sample_image.jpg | Added sample image file for testing image handling |
| python/packages/anthropic/pyproject.toml | Added local development configuration for anthropic package (should not be committed) |
| python/uv.lock | Updated lock file with dependency changes |
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
788d642 to
ce61e14
Compare
ce61e14 to
f3c78e5
Compare
giles17
approved these changes
Nov 11, 2025
dmytrostruk
approved these changes
Nov 11, 2025
moonbox3
approved these changes
Nov 12, 2025
Contributor
|
@eavanvalkenburg looks like there are some conflicts we should resolve. |
f69086b to
a4cf944
Compare
a4cf944 to
d242dd1
Compare
markwallace-microsoft
approved these changes
Nov 12, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…d on datacontent (microsoft#2083) * fixed image handling in anthropic and added convenience method on datacontent * remove wheel path * updated docstrings * fixed image handling in anthropic and added convenience method on datacontent * remove wheel path * updated lock
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #2041
Adds handling of data content with an image in the right way.
added integration test
Description
Contribution Checklist