CHATGPT API SETUP:
#where <responseCount> = Counter Widget
#where<userPrompt> = Text Input Filed
Body:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Provide <responseCount> suggestions on <userPrompt>. For each suggestion, give: {\"Name\": \"[name here]\", \"Description\": \"[description here]\", \"Link\": \"[link here]\"}."
}
],
"max_tokens": 1000,
"temperature": 0.7,
"stop": [
".",
"?",
"!"
]
}
The above is my prompt to chatGPT. On the 'Response and Test' tab I preview the output/format and it looks like this:
{
"id": "chatcmpl-8HzoHXy0CiGIpwGnexuIsUUI0fF6d",
"object": "chat.completion",
"created": 1699299865,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"Name\": \"TripAdvisor\", \"Description\": \"A popular travel website offering reviews and recommendations for hotels, restaurants, attractions, and more"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 40,
"completion_tokens": 28,
"total_tokens": 68
}
}
ADDED JSON PATHS:
$.choices[0].message.content.Name
$.choices[0].message.content.Description
When I am in both the API Response & Test page AND when testing my actual app, I get 'NULL' back for these paths. I have been searching everywhere and followed the tutorial but cannot find why those paths will not extracted the desired data (e.g. Name = 'TripAdvisor', Description = 'A popular travel website offering reviews and recommendations for hotels, restaurants, attractions, and more'
My assumption is that perhaps my JSON output is perhaps in the wrong format/structure. If anyone can help me with finding a solution to this I would be very grateful. Thanks in advance! JP
Screenshot Showing API Response & Test Page with Name previewing as Null vs TripAdvisor