Retool AI — Convert Document to Text Not Working

The documentation says to use the file upload component but the AI Query will not list the upload component in the dropdown no matter what I try. When I try to set the value using the 'fx' dynamically to {{fileDropZone.value}} I get a bunch of nonsense back as the text.

Hey @neilbalthaser,

I think you have to trigger the query its working perfectly.


1 Like

Hmm I'm building for mobile and I can't seem to get the behavior that you are showing. There is no drop zone component for mobile apps. There is a File Upload component and it functionally looks to be the same but it is not the same and its UI design appears different. I wonder if this has something to do with it?

Thanks for flagging this, @neilbalthaser! There's definitely some unexpected behavior here that I'll report to the team.

You already pointed out the issue with the "File source" dropdown, but fileInput.value is also incorrect. It should be an array of objects with all the attributes that the OpenAI API expects: name, type, sizeBytes, and base64Data. I've included a code snippet below that you can use in a JS query to properly generate this array:

const res = fileInput1.files.map(async ({ uri, size, name, type }) => {
  const base64Data = await utils.getDataByObjectURL(uri);
  return {
    sizeBytes: size,
    name,
    type,
    base64Data: base64Data.split('base64,')[1] };
});

return await Promise.all(res);

I recognize that there's a lot of moving parts here, so I've included an app export (13.8 KB) that you can look at! Let me know if you have any additional questions.

1 Like