PricingDocsAcademy
Bluesky ...
Wed, Dec 11, 10:35 PM

Streaming Issue

  • /attachments/1305497414035312782/1305497414374916146/image.png

    Jerry

    1 month ago

    Hey! I'm trying to set up streaming but it's not working. I'm not sure if this is a problem from my backend set up (via Xano) or Toddle.

    I receive the first message instantly, and then the rest of the stream will load at once. It does come in different events.

    I've used event stream + turned off server side fetching
    image.png
    βœ…1
  • Kedde

    1 month ago

    Hi Jerry. I've just tried setting a simple Xano stream up too and it appears that messages do come in really fast which is fine.

    To visualize that its actually streaming I added a Sleep of 1 second in between each event in Xano.
    Another way to verify that you do actually get messages in as a stream of events is to create an event on message from the Event tab. This event will trigger every time toddle receives a message from Xano. So if you for example increment a counter variable in your component/page for each message, you can verify that you do get the expected number of messages returned by printing the counter.
  • Jerry

    1 month ago

    Yes, the sleep fixed! Thank you πŸ˜„
    πŸ™Œ1
  • Jerry

    1 month ago

    Do you perhaps know how to show paragraphs when it's streaming? I see it included \n\n but it doesn't render in Toddle
  • /attachments/1305497414035312782/1305535376424697896/image.png

    Jerry

    1 month ago

    this is how it shows up in Toddle and this is what it's streaming:

    ["Here","'s a 2-paragraph sentence:","\n\nAs the sun began to set behind the distant mountains, casting"," long shadows across the valley and painting the sky in"," brilliant shades of orange and purple, the ol","d farmer slowly made his way back to his weather","ed farmhouse, his boots heavy with mu","d from the day's work in the fields,"," and his faithful dog trotting contentedly beside"," him, occasionally stopping to sniff at interesting"," scents in the evening air.\n\nThe warm"," glow from the kitchen window beckoned them"," both homeward, where the farmer's wife was"," preparing a hearty stew that fille","d the air with savory aromas, an","d the promise of a peaceful evening ahea","d helped ease the aches in the farmer's tire","d muscles, while the gentle chirping of crickets provide","d a soothing soundtrack to their final"," steps toward the porch, where a"," comfortable rocking chair awaited its daily visitor","."]
    image.png
  • Kedde

    1 month ago

    toddle doesnt parse the content of the message and \n\n is not something that can be used as new lines in html. So you would need to manually parse it and render it correctly. A way to do that is to:
    1. use the Join-formula to join all strings in the array together
    2. Use the Split-formula on the string from 1. splitting it on "\n\n". This will create a new array where each entry is its own paragraph
    3. Use the new array in a repeat formula to render the paragraph in the correct tag on your page/component
  • /attachments/1305497414035312782/1305537877379256341/Screenshot_2024-11-11_at_15.20.53.png

    Kedde

    1 month ago

    So it would be something like this where the first array is your data you pasted above πŸ™‚
    Screenshot_2024-11-11_at_15.20.53.png
    Screenshot_2024-11-11_at_15.20.44.png
  • And the formula in "Text" is just the "item"
  • Jerry

    1 month ago

    You the man!! Thank you so much πŸ˜„
  • /attachments/1305497414035312782/1305573405105328138/image.png

    Jerry

    1 month ago

    and sorry one more question πŸ˜…
    how does the copy to clipboard work

    One problem is that it now ignores all the chunks with \n\ and therefor I can't split it and also results in broken sentences. Any idea what could be wrong here?
    image.png
  • Jerry

    1 month ago

    Sorry, this is probably a Xano issue πŸ˜„
  • Lucas G

    1 month ago

    If you’re displaying it as an HTML block you can use the replace all node to replace \n for <br>

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code β€” but accessible to your entire team!

Try toddle β€” it's free!

Β© Copyright 2024 toddle. All rights reserved.