Skip to content

Commit

Permalink
converted answer to json object before extracting responses and citat…
Browse files Browse the repository at this point in the history
…ions from cloud func
  • Loading branch information
ayyubibrahimi committed Nov 15, 2023
1 parent eb73311 commit a283e2b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/googlecloud/functions/getanswer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def getanswer(request):

answer = answer_query(query, response_type, voting_roll_df, db_general, db_in_depth)

try:
answer = json.loads(answer)
except json.JSONDecodeError as e:
logging.error(f"Failed to parse answer string to JSON: {e}")
return ("Failed to process answer", 500, headers)

responses_data = answer.get("responses")

citations_data = answer.get("citations")
Expand Down

0 comments on commit a283e2b

Please sign in to comment.