def update_dialog_history(session, request, dialog_history_attribute_name = 'dialog_history'): dialog_history = session.attributes.get(dialog_history_attribute_name) if dialog_history is None: dialog_history = [] dialog_turn = {"intent" : request.get('intent'), "type" : request.get("type"), "timestamp": request.get("timestamp") } dialog_history.append(dialog_turn) session.attributes[dialog_history_attribute_name] = dialog_history # print('*** Updated Dialog History:\n\n{}\n'.format(json.dumps(dh, indent=2))) return dialog_history
def update_dialog_history(session, request, dialog_history_attribute_name='dialog_history'): dialog_history = session.attributes.get(dialog_history_attribute_name) if dialog_history is None: dialog_history = [] dialog_turn = { "intent": request.get('intent'), "type": request.get("type"), "timestamp": request.get("timestamp") } dialog_history.append(dialog_turn) session.attributes[dialog_history_attribute_name] = dialog_history return dialog_history
def decorated_function(*args, **kwargs): kodi = Kodi(config, context) if kodi.config_error: response_text = render_template('config_missing').encode('utf-8') card_title = render_template('card_config_missing').encode('utf-8') return statement(response_text).simple_card(card_title, response_text) CAN_STREAM = music.has_music_functionality(kodi) if not CAN_STREAM: response_text = render_template('config_missing').encode("utf-8") return statement(response_text) # Since we're not getting any of the actual args passed in, we have to create them here slots = request.get('intent', {}).get('slots', {}) for key, value in slots.iteritems(): kwargs.update({key: value.get('value')}) kwargs.update({'kodi': kodi}) return f(*args, **kwargs)
def get_locale(default=default_locale): return request.get('locale', default)