Get consistent JSON response from OpenAI / Chat-GPT

Sdílet
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

Komentáře • 20

  • @juleswombat5309
    @juleswombat5309 Před 4 dny +1

    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

    • @TomsTechAcademy
      @TomsTechAcademy  Před 4 dny

      Thank you for your comment Jules, glad I could be of help. Good luck with your application 🚀

  • @maxxxtermind
    @maxxxtermind Před 4 měsíci +1

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

    • @TomsTechAcademy
      @TomsTechAcademy  Před 4 měsíci

      Thank you for your comment Max, glad my tutorial was useful for you! 😀

  • @nayandey5010
    @nayandey5010 Před měsícem +1

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

    • @TomsTechAcademy
      @TomsTechAcademy  Před měsícem

      Thank you for your comment, glad to hear my video has helped you 😀

  • @tuananhngyen2985
    @tuananhngyen2985 Před 6 měsíci +1

    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 ❤

    • @TomsTechAcademy
      @TomsTechAcademy  Před 6 měsíci

      Glad my video was helpful for you :) good luck with the start of your new e-commerce business 🚀

  • @jacobshughrue
    @jacobshughrue Před 4 měsíci +2

    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

    • @TomsTechAcademy
      @TomsTechAcademy  Před 4 měsíci

      Thank you for your reply, glad my video was helpful for you 😀

  • @user-sd8yg1qe7o
    @user-sd8yg1qe7o Před 5 měsíci +1

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

    • @TomsTechAcademy
      @TomsTechAcademy  Před 3 měsíci

      I just uploaded another video on using function calling in order to enforce structured data with Chat-GPT:
      czcams.com/video/kWo3iPDsVWU/video.html

  • @tshaylatte9502
    @tshaylatte9502 Před 2 měsíci +1

    thank you

    • @TomsTechAcademy
      @TomsTechAcademy  Před 2 měsíci

      Thank you for your comment Tshay! What else would you like to see a video about? 😀

  • @Topakhok
    @Topakhok Před 8 dny

    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

    • @TomsTechAcademy
      @TomsTechAcademy  Před 5 dny

      Thanks for your feedback, greatly appreciated 😊! Will definitely use them in the next videos.

  • @plaedadies
    @plaedadies Před 3 měsíci +1

    mad to not just use an env file?

    • @TomsTechAcademy
      @TomsTechAcademy  Před 3 měsíci

      Thanks for the suggestion, I’m using .env files in some of my other videos, e.g: czcams.com/video/kWo3iPDsVWU/video.html

  • @luiscatalan3309
    @luiscatalan3309 Před 2 měsíci

    Great content! your website is down :(

    • @TomsTechAcademy
      @TomsTechAcademy  Před 2 měsíci

      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