INNER CODE UNIT · Python
get_response
shakedzy/companion · companion.py:199
def get_response():
"""
Get response from chatbot
"""
error_message = None
first_message = ''
try:
is_initial_message = bool(int(request.form['is_initial_message']))
app_cache.message_generator = chatbot.get_response(is_initial_message)
app_cache.last_sentence = ''
app_cache.sentences_counter = 0
app_cache.bot_recordings = list()
first_message = next(app_cache.message_generator)
app_cache.generated_message = first_message
except Exception as e:
error_message = utils.get_error_message_from_exception(e)
finally:
return jsonify({'message': first_message,