PricingBlog

calling an api to populate inner lists

  • rscott-1198864080887365713

    Bishop

    2 years ago

    I have a list of questions and answer boxes. I would like each one to have a suggest button that'll take a prompt i pregenerated and send it to chatgpt, and then use that to populate the inner list, inside the question/answer area from where it was called.

    In the image you can see the suggestions (they are all coming from a single static list, which is why they are the same. this is not the behavior i am shooting for)

    All the suggestions are in a list. Each question has a tag associated with it like [topic] or [title]

    So I'm thinking that maybe i need to create and bind a complex object that's an object with "tag":[list of suggestions] in a variable in order to maintain all the suggestions and have them display properly in the inner lists?

    If I have learned anything with toddle its that I keep trying to do things the hard way so I would like to know how I can make this work easier than maintaining that object, or even if the object idea is the way to do it. I was hoping there was a simpler way.
    1198864081256448101-Screenshot_2024-01-21_at_11.29.09_PM.png
  • rscott-1198865782180954194

    Bishop

    2 years ago

    trying it, if i set a variable and query the database again it'll change previous answers... unless i guess i store it in a complex variable, that sounds like it makes sense.
    1198865782235471933-Screenshot_2024-01-21_at_11.43.38_PM.png
  • rscott-1198866625902948382

    Bishop

    2 years ago

    it seems like the only way to create that variable to populate with the suggestions would be to read it from a database.
  • rscott-1198869774701179013

    Bishop

    2 years ago

    all suggestions coming from the same place all change at same time. 😐
  • andreasmoller-1199021722175807488

    Andreas Møller

    2 years ago

    I am not 100% sure I understand how it should work, but it sounds like you want to make seperate requests to chatGPT for each item in the list?
    If so consider creating a component for each item, they way they can have their own internal apis.
  • rscott-1199185946478911510

    Bishop

    2 years ago

    yes this worked thanks
  • andreasmoller-1199220297564430356

    Andreas Møller

    2 years ago

    Oh great 👍