Repository navigation
fix(py): add singular ModelResponse.media accessor for first media part - #7139
huangjeff5 wants to merge 1 commit into
Conversation
`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.
There was a problem hiding this comment.
Code Review
This pull request refactors how media parts are accessed in ModelResponse, Message, and ModelResponseChunk. Specifically, the media property has been changed from returning a list of media parts to returning only the first media part (Media | None), aligning the Python SDK with the JS and Go implementations. A new media_parts property has been introduced to retrieve the full list of media parts. Documentation, tests, samples, and plugin packages (Amazon Bedrock, Google GenAI, Vertex AI) have been updated accordingly to use the new properties. There are no review comments, so I have no feedback to provide.
|
Closing: migrated to standalone repository genkit-ai/genkit-python (PR #47): genkit-ai/genkit-python#47 |
Adds a singular
.mediaaccessor toModelResponse,Message, andModelResponseChunkfor parity with JS and Go.Main Changes
response.media: Accessor returningMedia | Nonepointing to the first media part.response.media_parts: Accessor returninglist[Media]for all media parts.Document.media: KeptDocument.mediaas a list to avoid breaking existing RAG contracts.