No video

How to get OpenAI API response in JSON format reliably🔥: Python & Node.js - OpenAI #1

  Рет қаралды 1,826

Code AI with Rok

Code AI with Rok

Күн бұрын

💸 Become a beta tester for my "From 0 to OpenAI API hero" course! Enjoy the already discounted rate of just 15€ (50% off the original price) in exchange for your valuable feedback. 👉 rok-benko-s-sc...
In today's tutorial, we are going to look at a feature that was released on OpenAI's first-ever DevDay, which is how to get an OpenAI API response in JSON format. I'll show you an example in both Python and Node.js.
⭐ Code ⭐
GitHub repository: github.com/rok...
Code for this tutorial: github.com/rok...
🙌 Support 🙌
If you would like to support me, subscribe to my KZfaq channel ( / @rokbenko ). Don't forget to click the bell 🔔 to get a notification when I release a new video.
👇 Contact 👇
GitHub: github.com/rok...
StackOverflow: stackoverflow....
LinkedIn: / rokbenko
🎞️ Timestamps 🎞️
00:00 - Intro
00:14 - Code for this tutorial
00:28 - OpenAI DevDay announcement
00:42 - SDK update
00:57 - Python and Node.js examples
02:10 - Check if the response is a valid JSON
02:23 - Run Python and Node.js examples
03:01 - Outro
#AI #OpenAI

Пікірлер: 11
@rokbenko
@rokbenko 7 ай бұрын
Hey everyone! 👋 Did you know that 97.5% of my viewers aren’t subscribed? If you found this tutorial helpful, consider subscribing to the channel. It’s free and doesn’t hurt anyone, but it means a lot to me. Plus, it’s a great way to stay updated with the latest coding tips and tricks. Thanks for your support! 🙏
@DataSnippets-si3cw
@DataSnippets-si3cw Ай бұрын
thank you. Is this your real voice OR using a TTS? You speak awesomely fluent
@rokbenko
@rokbenko Ай бұрын
If something seems too good to be true, then it probably isn't. 😉 I'm using an AI voiceover (i.e., TTS). The reason behind my decision to have a faceless KZfaq channel with an AI voiceover is that it helps me focus on the content more and care about anything else way less. Content is the king, IMHO.
@DataSnippets-si3cw
@DataSnippets-si3cw Ай бұрын
@@rokbenko Nice work honestly. May I know which TTS voice model/service you are using?
@rokbenko
@rokbenko Ай бұрын
@@DataSnippets-si3cw Thanks! I'm using PlayHT: www.play.ht/?via=rokbenko
@DataSnippets-si3cw
@DataSnippets-si3cw 28 күн бұрын
@@rokbenko Thank you!
@patricklanquetin9373
@patricklanquetin9373 9 ай бұрын
Great speaking. Thank you! It will be possible to make a zoom to the line or part of the code following your speak in the next video? On my pc, caracteres are too small for my small eyes :-)
@rokbenko
@rokbenko 8 ай бұрын
Thanks for the feedback. In my future tutorials, I'll try to improve on this aspect.
@ryguywy
@ryguywy 9 ай бұрын
Whats you preferred way of working with the completion response? .loads .dumps, .get? Thanks
@rokbenko
@rokbenko 9 ай бұрын
I suggest you read the following: - stackoverflow.com/a/32911421 - www.educative.io/answers/what-is-the-difference-between-jsonloads-and-jsondumps
@ryguywy
@ryguywy 9 ай бұрын
@@rokbenko Thanks, I'm not an expert working with jsons so I'm still a little confused. response_format={ "type": "json_object" } is supposed to return a json_object. However checking that: print (f'object type of completion.choices[0].message.content: {type(completion.choices[0].message.content)}') returns -> completion type: object type of completion.choices[0].message.content: So what is being returned in the content is a string and we use .loads to convert it to a dictionary. I can get that to work fine. However, if I was expecting a json_object to be returned, I would expect to have to first .dumps it to convert it to a string, then .loads it to a python dict. What i'm seeing is that response_format={ "type": "json_object" } doesn't really return an actual json_object (maybe that's not possible in the api repsonse). But a string in json format that we convert to a python dictionary.
Function Calling in Ollama vs OpenAI
8:49
Matt Williams
Рет қаралды 32 М.
OpenAI Embeddings and Vector Databases Crash Course
18:41
Adrian Twarog
Рет қаралды 443 М.
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 38 МЛН
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 10 МЛН
Вы чего бл….🤣🤣🙏🏽🙏🏽🙏🏽
00:18
Box jumping challenge, who stepped on the trap? #FunnyFamily #PartyGames
00:31
Family Games Media
Рет қаралды 30 МЛН
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 395 М.
Get consistent JSON response from OpenAI / Chat-GPT
11:25
Thomas Janssen | Tom's Tech Academy
Рет қаралды 13 М.
Python RAG Tutorial (with Local LLMs): AI For Your PDFs
21:33
pixegami
Рет қаралды 194 М.
Svelte 5's Secret Weapon: Classes + Context
18:14
Huntabyte
Рет қаралды 16 М.
Why You NEED To Learn FastAPI | Hands On Project
21:15
Travis Media
Рет қаралды 158 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 261 М.
The OpenAI (Python) API | Introduction & Example Code
23:46
Shaw Talebi
Рет қаралды 28 М.
Gitlab DELETING Production Databases | Prime Reacts
17:27
ThePrimeTime
Рет қаралды 322 М.
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 38 МЛН