https://www.boundaryml.com logo
🟡 Question about handling loading states in gener...
# questions
f
@Vaibhav (BAML 🐑) @aaronv (BAML) Its been a while! Hope things are going well. I had a quick question that isnt very clear to me in docs that I am hoping to resolve quickly. We are adding some generative UI features to Ape AI, and I am trying to figure out the best way to achieve the following. Our BAML func returns a union of message types such as Markdown | Component. For the component types we want to show a loading state untilt that Component is done streaming so we can render the Component. What I can gather from the docs is that I should use stream.done on a field lets call it stream_completed? Based on that the clients can either show the loading state or the component (once that type is streamed).
actually I think I am stumbling on an answer my self, think I need to wrap the Components in a parent type to accomplish this which is a bit annoyying cause ill have to do some runtime shenanigans to turn this into a clean contract for the frontend clients
a
stream.with_state should give you the state so you can view if a field is completed or not
f
I need to know if the entire type is complete
so yea I can use with_state with the parent type just need to create a parent type
thats what I ended up with, just sucks because it requires an additional type that we dont exactly need
2 Views