Lossy Abstraction for Generated Responses #599
Replies: 8 comments 22 replies
-
That's a great point! Could you file an issue around that, and we'll see if we can provide an alternate interface that returns the parts. I think we probably should either just convert the
That's not a bad idea either. We'd have to figure out a common API that covers all of the models we want to support, but that should be possible, at least for a common subset. What do you think of that, @csells ? |
Beta Was this translation helpful? Give feedback.
-
|
+1 for consolidating those primitives in a separate package These primitives are used not just by Dash team packages, but also by user packages. Recently I faced an application that is dealing with two libraries defining these primitives, and thus gets name conflict and necessity to convert one tool call to another tool call. |
Beta Was this translation helpful? Give feedback.
-
|
Suggesting one more primitive for this list: ToolDefinition. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, @csells let's see if we can convert genui over to use |
Beta Was this translation helpful? Give feedback.
-
|
I just discussed it with @jacobsimionato Yes, let's create package @csells , do you want to create PR that constructs the initial version? |
Beta Was this translation helpful? Give feedback.
-
|
A related idea: Maybe Gen UI should switch to using Dartantic as the shared tool loop logic for people building client-side agents. Currently, we have Someone implementing a local agent with Gen UI needs a stack like:
What if we swapped the middle layer to always be So we'd just merge For server-based agents, we would still provide All of the packages above would use @sethladd and @polina-c what do you think of depending on dartantic in this way? @csells do you have any plans for a Firebase AI integration with Dartantic? |
Beta Was this translation helpful? Give feedback.
-
|
@gspencergoog makes a compelling point wrt the json schema validation for the schema builder. Of course, the ergonomics are better, too. I can see building the genai_primities on top of the schema builder package and moving dartantic to use it as well. @leoafarias I've got a PR for firebase_ai that's been waiting on my dartantic 2.0 release, which I've now landed. If you want to use dartantic as the middle layer of genui, I can land the firebase_ai PR sooner rather than later. |
Beta Was this translation helpful? Give feedback.
-
|
This is all very exciting! So to confirm: we're working towards this incredible package structure? |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
The ContentGenerator interface currently exposes AI responses as
Stream<String>, which discards the rich typed data that AI SDKs provide. The typed infrastructure (MessagePart,TextPart,ToolCallPart,ThinkingPart, etc.) already exists in GenUI but is only used for input to models, not output from them.Should GenUI expose the full typed AI response to consumers, similar to what the underlying AI clients provide?
The current
Stream<String>abstraction prevents us from accessing thinking blocks, tool calls, image/multimodal parts, finish reasons, token usage, safety ratings, and citations, all of which are available from the underlying SDK but discarded before reaching the application layer.We noticed while implementing an interface that would output all tool calls and results, just so we can review the workflow, and we noticed that we can see the calls on the logs, but we wanted them on the interface. However, I think Gen UI needs to expose all parts of the response, or we lose a lot of features that are currently in the AI SDK itself.
I am still exploring some possible workarounds on this, using the GenUI for this use case, but I think there are many use cases where they do become blockers.
As a bigger question, it seems that the https://github.com/flutter/ai also had to recreate these parts and so on, and there is overlap between the parts and implementations on these two packages. Would maybe consolidating those primitives in a separate package make sense also?
Beta Was this translation helpful? Give feedback.
All reactions