-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
(I'm starting with my specific usecase and generalize from there...)
It's currently pretty inconvenient to see if a ModelResponse contained a TextPart and if so to extract it.
It would be awesome to have a has_text_part() -> bool paired with get_text_part() -> TextPart or just get_text_part() -> TextPart | None interface in the ModelResponse potentially even implemented as a property.
Subsequently it would be the question if it might be useful to do the same thing for the other Message Parts or maybe even in general.
What would be a little complicated is that some getters might need to default to a list while others don't (there are multiple tool calls possible but only one(?) content / reasoning part). And how would you handle the instructions (on the request part) since they don't seem to be their own class.
This request might bloat the interface of the ModelResponse on the other hand it would make the handling way more convenient. Also because the getters would be typed, removing the need for lots of typechecks on the user's side...
And the navigation of the Message Parts is surprisingly inconvenient for a framework that is designed to make it less painful to build production grade applications with Generative AI.
--
This was already discussed on Slack The slack thread the idea was brought up in with members of the team @DouweM and @dmontagu.
Since they were neither actively supporting nor opposing this idea I decided to put it in an issue to have it documented (and open for discussion) outside of a slack thread.
References
Slack Thread: https://pydanticlogfire.slack.com/archives/C083V7PMHHA/p1756933362513579