in functions/source/kendra_search_intent_handler_lambda/helpers.py [0:0]
def get_kendra_answer(intent_request):
"""
Get answer from the JSON response returned by the Kendra Index
:param question: Question string
:return: Answer returned from Kendra
"""
try:
first_result_type = intent_request['resultItems'][0]['type']
except KeyError:
return None
except (IndexError, TypeError):
error_txt = '\"Sorry, we do not have the answer currently. Please try again later!\"'
logger.error(error_txt)
return error_txt
answer_text = None
if first_result_type == 'QUESTION_ANSWER':
answer_text = question_result_type(intent_request)
elif first_result_type == 'ANSWER':
answer_text = answer_result_type(intent_request)
elif first_result_type == 'DOCUMENT':
answer_text = document_result_type(intent_request)
return answer_text