Save text output from Smart Query into a table and save the text

Hi there,

I am creating an app where a smart query output is in text. Can it be converted into a table where the table renders the text output from the smart query and saves it as well? The output rendered in the table should not disappear when the app refreshes. When the end user runs the smart query again, it should append the new data to the table. As of now I have displayed it in a table format but in using the Markdown.

@fpm Can you share some screenshots and example of how you are manipulating the text?

@ScottR I have created a Smart query with instructions to give output in table format, and it does it successfully as you can see in the screenshot.
I can also easily convert it using markdown to display in tabular format. (See in screenshot).
However, I want to create an actual table that renders the output from the Smart Query, which saves the output, and allows to append the data when an end user invokes/runs the smart query next time.

You should let smart query output the json format and save it in the database.

Thanks @AnsonHwang but I am not following how to

let smart query output the json format and save it in the database

That's the challenge I'm facing. Where should the json be added?

I need the Serial No. to be 1,2,3.....Suggested Title under the column Suggested Title, and description under the column Description.

change data source to {{transfer2.value["text"]["Content Ideas"]}}

sorry for the typo.

So you should tell to GPT4 to the structure of json of output.

The GPT4 query is already asking to give output in json. See in the screenshot, just above table1.

yes, you should add some description more detail to GPT4 to output the JSON as your description.
such as Please provide output in json format - i.e and array of object which have tree key (serial_no, suggested_title, description).

I don't think this is working. I used exact same words, and the data source, but it's giving same errors and not populating anything in the table. Also, as I had mentioned earlier in my reply, I am also noticing that the Smart Query shows results in JSON that are not consistent. For example, the "Content Ideas" is missing after I ran the query again.

So here is different from API and GPT4.
Don't rely on the result of GPT4 if you need some structure data. For me, I use it to handle some text. And construct the data(maybe json) manually with the text return from GPT4.

Retool does ask for a specific JSON format for tables, the following prompt seems to work well for me:

generate five content ideas for {{textArea1.value}} with a short suggestion on what the article will discuss. please provide output as an array of objects, each with three keys - Serial No., Suggested Title, and Description

1 Like

Thanks for getting back on this one, @Kabirdas . This works! I had created the app with work arounds but this is exactly what I needed. Thanks.
However, now I am trying to add data from this table to PostgreSQL DB using bulk upsert query, but I am getting this error. What am I missing?
insert into "demo_content_suggestion" ("Description", "Serial No"."", "Suggested Title") values ($1, $2, $3) - zero-length delimited identifier at or near """"

Never mind. This is solved.