Hi everyone,
I am trying to map the output from GPT to an airtable database. Basically, I wanted GPT to get the key components I need for my app, coming from a scanned documents. I first had to create my own API to handle document-to-text with vision API (All the documents being scanned). I then passed the text into my GPT assistant and prompt it to return a Json document.
Here is an example of the output I get:
{
"Nom": "GÜZEL",
"Prénom": "Yan-Loïc",
"Niveau scolaire": "gymnase",
"Français": 4.5,
"Anglais": 4.5,
"Allemand": null,
"Mathématiques": 4.5,
"Niveau français": "NaN",
"Niveau Allemand": "NaN",
"Niveau Anglais": "NaN"
}
However, using JSON module to parse the data, it doesn’t work. Then, I assumed it’s because my GPT output includes ‘’‘json and ‘’’ at the end. So I tried to remove them with Regex module, but it doesn’t work out. How can I process this output to then fill my airtable ? I tried to parse directly the output from GPT but didn’t work out neither (And the more I try, the more I run my credit on API)
Your support would be beneficial. I am a steep learning curve on automation, all doing by learning online
Thanks
Gaetan
Hi @Gaetan593,
used to do the same thing, but there’s actually a much easier method now.
In the ChatGPT module, you can click on “Show advanced settings” and change the output type from text to json object and then set Parse JSON Response to yes.
Like this:
Once you have that activated, you don’t even need a seperate module to parse the json as it will already be parsed inside the chatgpt response.
Thanks for your help. I’ve changed it and I get this error message:
RuntimeError
[400] Invalid tools: all tools must be of type function
when response_format
is of type json_object
I suppose I have to write a function in my assistant on my openAI api dashboard ? I am not very familiar with those functions yet. THat’s what I see in my assistant:
Really appreciate your support Julius !
Thats weird! You just have to activate that and then give it the instruction in the promt.
I recommend you add a system message and then a user message. In the system message, after the initial instructions, add the following (change the language if needed):
Always answer in the following json format:
“”“{
“Nom”: “Nom here”,
“Prénom”: “Prenom here”,
“Niveau scolaire”: “niveau scolaire here”,
“Français”: number value,
“Anglais”: number value,
“Allemand”: number value,
“Mathématiques”: number value,
“Niveau français”: “niveau francais here”,
“Niveau Allemand”: “niveau allemand here”,
“Niveau Anglais”: “niveau anglais here”
}”“”
Once you’ve done that and you still get the error, could you send me the input bundles?
Thanks you
Hi,
Instead of using message an assistant, I used the same module as you and added my assistant prompt in the “system message”, and it worked properly.
Thank you for your solution, I spent hours today trying to figure out a solution
1 Like
Happy to hear that we figured it out!
1 Like