chase199600
chase19960011mo ago

Open AI --> JSON Output

Has anyone had any luck doing function calling JSON output using OpenAI API in BuildShip? I have tried 1) using ChatGPT to generate NodeJS logic code that I can insert manually into the node logic 2) modifying the logic code of the OpenAI chat node template to include type": "json_object" under the message (and changing model to gpt-3.5-turbo-1106 or gpt-4-1106-preview) 3) using the AI feature to generate a node But none of them have seemed to work properly so far. The closest I got was using the Chat template but that did not seem to output JSON, but rather string in the structure of JSON (indicating to me that the function calling is not being triggered properly) I’m not a developer by background but learn fast so appreciate any hacks/tips to be able to figure this out myself
8 Replies
Gaurav Chadha
Gaurav Chadha11mo ago
Hi @chase199600, I tested with one of the Open AI Chat Nod, and the response is in JSON format with starting and ending /. It is a valid JSON. In case I missed any part of your request here. Feel free to ask more questions.
No description
No description
chase199600
chase19960011mo ago
@Gaurav Chadha Thanks for running a test. Specifically, it is when I try to use a specific object from the chat output JSON. In the example above, I just want to use the “ingredients” string for the next node but when trying to test using return node, I get undefined output. I can output the entire JSON object, but if I try to return “output.ingredients” for example, I get undefined result. Am I likely doing something wrong when I try to return a single objection from the JSON output?
No description
No description
chase199600
chase19960011mo ago
Hi @Gaurav Chadha it seems like I’m missing something quite simple here but I have failed to realize it. Any advice?
Gaurav Chadha
Gaurav Chadha11mo ago
Hi @chase199600, Sorry I missed your last message. I see you'll require to use dot notation to get the required one from the JSON. Something like this.
No description
chase199600
chase19960011mo ago
No worries @Gaurav Chadha . Yes, the output.ingredients is what it tried above, but that yields an “undefined” output. The full JSON output is: { "ingredients": "80g oats, 1 scoop Kino Collagen blueberry muffin protein powder, 50g blueberries, 16g natural peanut butter, 1 cup unsweetened cashew milk, 1/4 tsp of Cinnamon, a pinch of Sea salt", "instructions": ["Cook the oats with the cashew milk in the microwave for 2-3 minutes", "Add the collagen powder and salt, mix well", "Add the blueberries, cinnamon, peanut butter and some zero calorie maple syrup"] } Ingredients is just a string, so I don’t think I need to use [] but maybe it’s the way the output is structured by ChatGPT?
Gaurav Chadha
Gaurav Chadha11mo ago
Could you please paste your workflow here or submit via in-app support? Docs to copy paste workflow - https://docs.buildship.com/workflow-operations.
chase199600
chase19960011mo ago
I just sent via support as it was too long for Discord to send
swipe
swipe11mo ago
Did you ever come to resolution here? Running into a similar issue.