Get consistent JSON response from OpenAI / Chat-GPT
Vložit
- čas přidán 8. 12. 2023
- As from GPT-3.5- Turbo, Chat-GPT allows to set response_format as part of the parameters of an API call. But even using this parameter doesn't guarantee the response is in a consistent format. In this video I show how you can ensure a consistent response and how to avoid invalid JSON response because of insufficient tokens.
💭 Join my Discord community and get help from many other Python developers:
/ discord
⭐️ Copy the source code here ⭐
🔗 tomstechacademy.com/code-exam...
⭐️ Links ⭐
🔗 Python Open File function: www.w3schools.com/python/pyth...
🔗 JSON Mode Documentation: platform.openai.com/docs/guid...
⭐️ Other helpful videos⭐
• How to get an Open AI ...
⭐️ Follow me ⭐
💼 LinkedIn: / thomas--janssen
✅ Instagram: / tomstechacademy
#python #chatgpt #artificialintelligence
Interesting. I was trying to figure out how to get some structured responses to my Chat GPT requests. This json format, and Json example approach looks very useful way to coerce the responses into a useful syntax for my overall NPC adventure application. Many Thanks
Thank you for your comment Jules, glad I could be of help. Good luck with your application 🚀
Dude, abstracting the schema is a genius move. Thanks for the advice!
Thank you for your comment Max, glad my tutorial was useful for you! 😀
thannks man youre a great help for a 2 day long issue, thanks again very much appreciated.
Thank you for your comment, glad to hear my video has helped you 😀
oh damn, I have a business idea for e-commerce website where automate customers purchase with the help of an AI assistant. This JSON stuff is exactly what I need to implement the idea. Thank you so much. Keep up your amazing work ❤
Glad my video was helpful for you :) good luck with the start of your new e-commerce business 🚀
thanks this provided me the code snippet i was looking for when Chat GPT 4 wasn't familiar with the latest updates past > v0.0.28
Thank you for your reply, glad my video was helpful for you 😀
I believe you can use function calling to force the response to be a certain JSON structure. Have you looked into / tried this? Thanks
I just uploaded another video on using function calling in order to enforce structured data with Chat-GPT:
czcams.com/video/kWo3iPDsVWU/video.html
thank you
Thank you for your comment Tshay! What else would you like to see a video about? 😀
Man, there are f-strings in python and they are awesome. Please use them instead of string concatenation - this way there is no need to manually convert integers to strings
Thanks for your feedback, greatly appreciated 😊! Will definitely use them in the next videos.
mad to not just use an env file?
Thanks for the suggestion, I’m using .env files in some of my other videos, e.g: czcams.com/video/kWo3iPDsVWU/video.html
Great content! your website is down :(
Thanks, yes - I'm working hard to get it back online. Reach me via Discord in case you need any of the resources hosted there :) discord.gg/a4qUrRuZ