in infra-as-code/modules/ingest-pipeline/cf-feedback-generator/lib.py [0:0]
def get_qa_questions(self):
"""Gets all the questions from the scorecard
Returns:
dict: dictionary with the questions as key and the instructions as values
"""
latest_revision_id = self.get_latest_revision()
ccai_conversation_url = (
'https://{}/{}/projects/{}/locations/{}/qaScorecards/{}/revisions/{}/qaQuestions'
).format(self.insights_endpoint, self.insights_api_version, self.project_id,
self.ccai_insights_location_id, self.scorecard_id, latest_revision_id)
headers = {
'charset': 'utf-8',
'Content-type': 'application/json',
'Authorization': 'Bearer {}'.format(self.oauth_token),
}
r = requests.get(ccai_conversation_url, headers=headers)
response_text = json.loads(r.text)
qaQuestions = dict()
for question in response_text['qaQuestions']:
qaQuestions[question['questionBody']] = {"instructions": f"{question['answerInstructions']}"}
return qaQuestions