How make OpenAI API read/query our Retool database/table?

Hi,

I'm building a tool to put all my job listings base, and have OpenAI API prioritize them (aka 'which jobs should I apply first based on my experience and tech stack).

  1. in my database, I created a few sample jobs - columns are #Job ID, TItle, Company, Description, Location, Posting URL, Date Found

  2. In my app I inserted a table, and linked the table to the database

  3. I turned on Retool AI > OpenAI API by entering my OpenAI API credential

  4. I go back to my app and Code > add query > resource Retool AI > action (by default: generate text) > model: I choose gpt-4-turbo (by default was gpt-4)

=> Input: How many jobs is there in {{ table1 }}? (just to test if it works)

I get this => * data:"Hello! It seems like the content you've posted is a string of encoded text, or you might be trying to convey something specific but it's unclear from the format provided. Could you please provide more context or clarify your request? I'm here to help!"

  • :arrow_forward:

metadata:{} 4 keys

  • success:true
  • streaming:true
  • vectorsContext: 0 items
  • totalTokens:12744

I try again, I get the same issue:

  • data:"Hello! It seems like you've pasted a long string of encrypted or encoded text. How can I assist you with it?"

How to make it works? Thanks.

How come Retool is unable to make GPT4 read the table's content?

But yet appears to be able to read it in the first place...

Hi @spnc

if you provide {{ table1 }} in the input, you're passing the whole table component to GPT-4.

You should pass only the data, such as {{ table1.data }}

Hope this help.

1 Like

Thanks. I'm completely lost here though... when I enter {{ table1.data }} I get empty arrays it seems.

And still the 'Apologies, but it seems that you've entered a string of random characters. Could you rephrase or provide more context so I can assist you better?'

Am I supposed to write further formulas/logic in the same prompt? Or to create other resources and link them all in the app later?

I've tried using 'const' logic but the Retool AI query doesn't seem to accept JS...

Damn I thought it would be much easier... any help appreciated!

*actually not empty arrays, Retool seems to be able to read each 4 of my jobs listed, but somehow Retool AI through the GPT4 API doesn't seem able to interpret them... is it a formatting issue?

If the OpenAPI method doesn't work in Retool (unless anyone made it work successfully, please advise), is it possible to bypass it and use the JS method?

  1. By going to > Queries > create a new JavaScript query
const myExperience = "Here's my work experience";
const jobDescriptions = table1.data.map(job => `${job.title} at ${job.company}: ${job.description}`).join(", ");
const prompt = `Given my experience: ${myExperience}, which of these jobs should I apply to first? ${jobDescriptions}`;
return prompt;
  1. By using the JS Query Result as Input for Retool AI:

After creating the JavaScript query, name it preparePrompt, and use the result of this query as the input for the Retool AI query
In the Retool AI query input, referencing the result like {{ preparePrompt.value }}.

  1. Run the Retool AI Query

?

If the array is not too big, you can provide a CSV version of the array that is a string and is more digestible for GPT-4:

{{ Papa.unparse(table1.data )}}

Thanks, it still works I mean the data is being read, but I'm still getting:

"It seems you've inputted a block of text consisting of random characters, symbols, and potential encodings that I'm unable to process directly. If you have any specific questions or need information regarding this text, or if it represents data you need help with, please provide more context or clarify how I can assist you"

It sounds like Retool AI is experimental at this point and doesn't work yet properly with OpenAI API.

I will look for an alternative and come back in a few weeks/months.

Cheers.