Quick fix needed: Python OpenAI chatbot JSON output issue
Rozpočet: $5.0
FIXED /
⭐ 5.00 (5)
Australia
python, javascript, api, json, automation, php, node.js, django-framework, java
Hey there, I need help fixing a small but important bug in my Python customer support chatbot.
The chatbot uses the OpenAI API to process user messages and return structured JSON data like:
"intent": "...", "reply": "...", "urgency": "..."
The issue is that the response format is inconsistent. Sometimes the model returns the JSON inside markdown code blocks, and sometimes it adds extra text before or after the JSON. This causes json.loads() to fail with a JSONDecodeError.
I need someone experienced with Python and OpenAI API integration to properly fix this issue.
What I need:
- Identify why the response format is inconsistent
- Implement a reliable solution so the output is always valid, parseable JSON
- Ensure the response works correctly with json.loads()
- Provide a brief explanation of the changes made
The existing script is small, and I will provide the code along with example cases that are causing the issue.
Looking for someone available to help resolve this efficiently.
Otevřít na Upwork