-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
P2An issue we'd like to fix eventually, but it's not being actively worked on.An issue we'd like to fix eventually, but it's not being actively worked on.
Description
In order to reduce perceived latency, we should support streaming of UI responses.
Behavior
- User sends query as usual
- Developer integrates Gen UI as usual, with some minor modifications to hook up streamed responses or function calls
- Behind the scenes, Gen UI should progressively build the widget tree, so new elements appear one-by-one as they stream back.
- We should have this functionality behind some configuration flag that the developers sets initially. In the future, this may become the default approach.
Technical approach
- We need some permissive JSON parser for partial responses that can close brackets etc.
- We should consider how to handle IDs references, which must be able to be temporarily broken. Maybe we can have an optional 'Placeholder' widget which is rendered when IDs refer to widgets that haven't been loaded yet. Alternatively, we can have children refer to their parents by ID, but that makes it difficult to represent ordering in lists etc.
- The schema we already have should be close what is necessary to support streamed results because the widget list is flat
- We may need to switch from a function call integration to structured output integration due to Gemini limitations - see below
- Ideally, we'd still provide the JSON schema and have the LLM require conformance
- We may need to do some tweaks to make sure the fields are outputted in the right order, or make the schema not care. For example, we have a "root" field with the root widget ID which is adjacent to the actual widgets, so it is possible that we don't know the root widget initially and therefore may not be able to start rendering. We could somehow enforce field order (I think @gspencergoog had an idea on how to achieve this?) or else change the format, e.g. have the first element implicitly be the root, have
root=true
as a field of the root element etc.
Gemini streaming function calls limitation
Once complication here is that we currently integrate with Gemini API via function calls / tool use, but it seems that Gemini does not support streamed function calls - see google-gemini/cookbook#47.
Hopefully, we can work around this by giving the developer the option of using structured output instead.
It sounds like OpenAI and Anthropic models don't have this limitation, so we could try them too.
Metadata
Metadata
Assignees
Labels
P2An issue we'd like to fix eventually, but it's not being actively worked on.An issue we'd like to fix eventually, but it's not being actively worked on.