Skip to content

Commit

Permalink
Merge pull request #28 from microsoft/anpethel/openaicallfix
Browse files Browse the repository at this point in the history
fixing response json
  • Loading branch information
WonSong authored Sep 17, 2024
2 parents 60c12d3 + 7de9dbd commit 734f0c2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Server/modules/career_game.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from uuid import uuid4
from time import time
import json


class CareerGame:
Expand Down Expand Up @@ -44,8 +45,15 @@ def __process_game__(self, conversation_id):
try:
# This seems to sometimes generate 10 scenarios or 1.... need to make the result consistent
open_ai_response = self.open_ai.chat(messages)
print(open_ai_response)

return open_ai_response
if open_ai_response.startswith("```") and open_ai_response.endswith("```"):
open_ai_response = open_ai_response.strip("```json").strip()

content_dict = json.loads(open_ai_response)
print(content_dict)

return content_dict
except Exception as e:
self.telemetry.info("RetryingOpenAIChat", {
"conversationId": conversation_id,
Expand Down

0 comments on commit 734f0c2

Please sign in to comment.