Get consistent JSON response from OpenAI / Chat-GPT

Thomas Janssen · Beginner ·🧠 Large Language Models ·2y ago

Key Takeaways

Ensures consistent JSON response from OpenAI/Chat-GPT using response_format parameter

Original Description

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 ⭐ 🔗 https://tomstechacademy.com/code-example-get-consistent-json-response-from-openai-chat-gpt/ ⭐️ Links ⭐ 🔗 Python Open File function: https://www.w3schools.com/python/python_file_open.asp 🔗 JSON Mode Documentation: https://platform.openai.com/docs/guides/text-generation/json-mode ⭐️ Other helpful videos⭐ https://www.youtube.com/watch?v=aVog4J6nIAU ⭐️ Follow me ⭐ 💼 LinkedIn: https://www.linkedin.com/in/thomas--janssen/ ✅ Instagram: https://www.instagram.com/tomstechacademy/ #python #chatgpt #artificialintelligence
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →