Get consistent JSON response from OpenAI / Chat-GPT

preview_player
Показать описание
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.

⭐️ Copy the source code here ⭐

⭐️ Links ⭐

⭐️ Other helpful videos⭐

⭐️ Follow me ⭐

#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

juleswombat
Автор

Dude, abstracting the schema is a genius move. Thanks for the advice!

maxxxtermind
Автор

thannks man youre a great help for a 2 day long issue, thanks again very much appreciated.

nayandey
Автор

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 ❤

tuananhngyen
Автор

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

jacobshughrue
Автор

I believe you can use function calling to force the response to be a certain JSON structure. Have you looked into / tried this? Thanks

sdygqeo
Автор

response_format is not reliable. I resorted to using a package on github to just fix the json. I don't expect it to be 100%, but it will help.

luigipace
Автор

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

Topakhok
Автор

Great content! your website is down :(

luiscatalan