I am using openai, Requestesting json response, few times it works fine and few times it failed to load.
Is there any way I can convert unsaturated data to dict and below is example sting
{
'finishReason': 'STOP',
'response': ' { "short_description": "some issue", "detail_description": "", "action_items": [ { "action_name": "Raise ticket", "assignee": "NOC" }, { "action_name": "Involve Java team oncall", "assignee": "NOC" }, { "action_name": "Involve PKI team", "assignee": "NOC" } ], "followups": [ "Check if issue is limited to xyz", "Check if issue M", "Check if issue is related to any latest changes in the configs" ], "issue_start_time": ISO 8601 string, "urgency": 1, "impact": 1, "priority": 1 }'
}
I am trying below code
json.loads(data["response"])
Error:
Expecting value: line 1 column 1598 (char 1597)
2
Answers
If you manually format the
data
part, you’ll see that there is unqouted string under "issue_start_time":yaml
parses the data string (already a dict) to a better formatted dict