def addToMessageHistory(self, session: DialogSession) -> bool: if session.message.topic in self._INTENTS or session.message.topic == self._INTENT_ANSWER_YES_OR_NO or 'intent' not in session.message.topic: return try: customData = session.customData if 'speaker' not in customData: customData['speaker'] = session.user data = session.payload data['customData'] = customData session.payload = data self._history.appendleft(session) except Exception as e: self._logger.error(f'Error in {self.name} module: {e}') return True
def addToMessageHistory(self, session: DialogSession) -> bool: if session.message.topic in self.supportedIntents or session.message.topic == self._INTENT_ANSWER_YES_OR_NO or 'intent' not in session.message.topic: return False try: customData = session.customData if 'speaker' not in customData: customData['speaker'] = session.user data = session.payload data['customData'] = customData session.payload = data self._history.append(session) except Exception as e: self.logError('Error adding to intent history: {e}') return True
def addToMessageHistory(self, session: DialogSession): if session.message.topic in self._SUPPORTED_INTENTS or session.message.topic == self._INTENT_ANSWER_YES_OR_NO or 'intent' not in session.message.topic: return try: customData = session.customData if 'speaker' not in customData: customData['speaker'] = session.user data = session.payload data['customData'] = customData session.payload = json.dumps(data) self._history.append(session) if len(self._history) > 10: self._history.pop(0) except Exception as e: self._logger.error('Error in {} module: {}'.format(self.name, e))