Streaming generated text variable in a Xano collection item

Hello,

I have a collection from Xano which is a list of objects containing a text. A button allow to generate the text of one item of this collection.

I want to stream the response. What is the best practice for that since my initial value is linked to the item.text, and not to the [streamingResponse] variable for now.

I am wondering if there is a best practice for that. Anyone set up something similar ?

So the first approach I tried was to :

  1. Create a workflow on mounted: initialize a component variable “Comment” that takes the value of my text from my collection

  2. I created a boolean variable to know when the streaming is running to generate which text of my collection (partCommentLoader)

  3. So like this when the generation workflow is running, I do not print the variable “Comment” wich comes from Xano, but the new value being generated: streamTest. Xano saves this new comment in the DB.

However : I want to have several comments so the user can access the previous modifications by clicking on arrows like this (bind to my component variable comment visible, that I match to the index of my list Part.ai_comment_of_part) :

The problem I’m facing now with this complex solution is that my generation workflow is outside my component. So at the end of generating a new comment, I can’t change the component variable “comment visible” easily. For each component :

  • comment visible = 1 means the comment visible is the first one
  • comment visible = 2 means the comment visible is the second one
  • …

I’m trying to figure out which solution is less complex for scalability and debugging. Let me know if you have any ideas.

Hi @Vi56 :wave:

Could you please DM me with your project’s link so I can have a better look?

1 Like

Hi @danlopes

Thank you for offering your help. I finally found an alternative by duplicating the text. So when the text is generting I print a text block with the streaming variable updating and hiding the comment already generated. It works great ! I didn’t think about it…

1 Like

I guess this is the best practice.