Skip to content

Commit

Permalink
Merge pull request #946 from openedx/iahmad/ENT-9495
Browse files Browse the repository at this point in the history
fix: Removed json prefix from GPT response
  • Loading branch information
irfanuddinahmad authored Sep 18, 2024
2 parents 8fe4a3a + 790514a commit 210799e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions enterprise_catalog/apps/ai_curation/openai_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import json
import logging
import re

import backoff
import requests
Expand Down Expand Up @@ -83,6 +84,7 @@ def chat_completions(
LOGGER.info('[AI_CURATION] [CHAT_COMPLETIONS] Response: [%s]', response.json())
try:
response_content = response.json().get('content')
response_content = re.sub(r'```json\n?|```', '', response_content)
if response_format == 'json':
return json.loads(response_content)
return response_content
Expand Down

0 comments on commit 210799e

Please sign in to comment.