Repository navigation
feat(py)!: add singular response.media accessor for first media part - #47
Merged
Merged
Conversation
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 19:08
c84bf3f to
8c80129
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 19:52
8c80129 to
fa6ce23
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 9, 2026 20:02
8af18ce to
227b9fe
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 20:02
fa6ce23 to
8f25d33
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 9, 2026 20:20
227b9fe to
1ecf3a9
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
2 times, most recently
from
November 9, 2026 21:22
0588ca1 to
09d6041
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 9, 2026 21:25
9d9f14a to
8fb2195
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 21:26
09d6041 to
d5c173d
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 9, 2026 22:03
8fb2195 to
f023c4c
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 22:03
d5c173d to
42f95c4
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 9, 2026 23:18
f023c4c to
0d515ca
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 9, 2026 23:18
42f95c4 to
461fd3f
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 10, 2026 07:44
0d515ca to
c528553
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 10, 2026 07:44
461fd3f to
9f173e3
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 10, 2026 18:14
c528553 to
e9ee864
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 10, 2026 18:37
9f173e3 to
5155fe0
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 10, 2026 21:57
e9ee864 to
8d16198
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 10, 2026 21:57
5155fe0 to
8bf395f
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 10, 2026 22:16
8d16198 to
8e52c49
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 10, 2026 22:16
8bf395f to
70c7f38
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
2 times, most recently
from
November 10, 2026 23:48
afd23c9 to
b0db9b6
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
2 times, most recently
from
November 11, 2026 02:35
c8451e5 to
1ae2d7b
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 11, 2026 02:35
b0db9b6 to
c3aa280
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr2-static-typing
branch
from
November 11, 2026 06:22
1ae2d7b to
95ec0ef
Compare
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 11, 2026 06:22
c3aa280 to
c65bb39
Compare
`ModelResponse.media` returned `list[Media]`, while JS `response.media`, Go `Media()`, and Python's own `AgentResponse.media` return the first media part. The `res.media.url` snippets in the google-genai README and docstrings raised `AttributeError`, and `res.media[0]` raised `IndexError` on empty replies. - `ModelResponse.media -> Media | None` (first media part). - New `ModelResponse.media_parts -> list[Media]` for the full list. - `.media` on `Message` and `ModelResponseChunk`. - `Document.media` stays a list. - Update in-repo `.media[0]` users (bedrock README/docstrings/tests, operation docstrings, veo tests, samples) and add a migration line.
…guide The guide covers 0.12 -> 0.13. The 1.0 note goes to the release notes.
huangjeff5
force-pushed
the
fix/py-1.0-pr3-media-accessor
branch
from
November 11, 2026 18:06
c65bb39 to
97a00a8
Compare
huangjeff5
changed the base branch from
fix/py-1.0-pr2-static-typing
to
main
November 11, 2026 18:07
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.
response.mediais now the first media part (Media | None) instead of a list.MessageandModelResponseChunkget the same.media, andresponse.media_partskeeps the full list.Main Changes
.mediais the first media part, orNone: PreviouslyModelResponse.mediareturnedlist[Media], while the agent client's.mediaalready returnedMedia | None. One name meant two shapes in the same SDK. Most image/audio/video replies carry one part, so the singular read is the common case.Noneon a text-only reply avoids anIndexError.media_partsfor the full list: Multi-part replies readresponse.media_parts.MessageandModelResponseChunk:.mediaon a chunk is the first media part in that chunk only; it doesn't accumulate earlier chunks, same aschunk.textvsaccumulated_text.Document.mediastays a list: Retrieved documents are often multi-part, and retrievers and embedders already index them as lists.samples/google-genai-mediaandsamples/vertexai-imageread.mediain this PR so they stay type-clean. Plugin README and docs snippets that show.mediaare in the docs PR at the top of the stack.Breaking changes
ModelResponse.mediachanges fromlist[Media]toMedia | None. Replaceresponse.media[0]withresponse.media, andfor m in response.mediawithfor m in response.media_parts. Note thatfor m in response.mediadoes not raise at runtime because iterating a PydanticMediamodel yields(field, value)tuples;pyright,pyrefly, andtyall flag it statically.Cross-SDK
Matches JS (
GenerateResponse.media,Message.media, andGenerateResponseChunk.mediareturn{ url, contentType? } | nullfor the first media part) and takes themedia_partsplural name from Go'sModelResponse.MediaParts().