def get_context_callback(self, response, handler: WebSocketHandler, message: dict): handler.context = self.json_decode(response.body) handler.context_rev = handler.context["_rev"] if not any(x for x in handler.context["entities"] if x["source"] == "detection"): handler.suggest_id = self.suggest.post_suggest( handler.user_id, handler.application_id, handler.session_id, handler.locale, handler.context, callback=lambda res: self.post_suggest_callback(res, handler, message) ) else: # TODO No idea what to do here pass
def get_context_callback(self, response, handler: WebSocketHandler, message: dict): self.logger.debug("get_context_callback") handler.context = self.json_decode(response.body) handler.context_rev = handler.context["_rev"] self.context_responder.unsupported_entities(handler, handler.context) self.suggest.post_suggest( handler.user_id, handler.application_id, handler.session_id, handler.locale, handler.context, callback=lambda res: self.post_suggest_callback(res, handler, message) )
def get_context_callback(self, response, handler: WebSocketHandler, message: dict): self.logger.debug("get_context_callback") handler.context = self.json_decode(response.body) handler.context_rev = handler.context["_rev"] self.context_responder.unsupported_entities(handler, handler.context) self.suggest.post_suggest(handler.user_id, handler.application_id, handler.session_id, handler.locale, handler.context, callback=lambda res: self. post_suggest_callback(res, handler, message))
def on_view_product_details_message(self, handler: WebSocketHandler, message: dict): handler.context_rev = self.post_context_feedback( handler.context_id, handler.user_id, handler.application_id, handler.session_id, message["product_id"], message["feedback_type"], message["meta_data"] if "meta_data" in message else None)
def get_context_callback(self, response, handler: WebSocketHandler, message: dict): handler.context = self.json_decode(response.body) handler.context_rev = handler.context["_rev"] if not any(x for x in handler.context["entities"] if x["source"] == "detection"): handler.suggest_id = self.suggest.post_suggest( handler.user_id, handler.application_id, handler.session_id, handler.locale, handler.context, callback=lambda res: self.post_suggest_callback( res, handler, message)) else: # TODO No idea what to do here pass
def on_view_product_details_message(self, handler: WebSocketHandler, message: dict): handler.context_rev = self.post_context_feedback( handler.context_id, handler.user_id, handler.application_id, handler.session_id, message["product_id"], message["feedback_type"], message["meta_data"] if "meta_data" in message else None )
def open(self, handler: WebSocketHandler): self.logger.debug( "context_id=%s,suggestion_id=%s", str(handler.context_id), handler.suggest_id ) if handler.context_id is None: handler.context_id, handler.context_rev = self.post_context( handler.user_id, handler.application_id, handler.session_id, handler.locale ) new_context = True else: new_context = False if str(handler.context_id) not in self._client_handlers: self._client_handlers[str(handler.context_id)] = {} if handler.id not in self._client_handlers[str(handler.context_id)]: self.logger.debug("add handler, context_id=%s,handler_id=%s", str(handler.context_id), handler.id) self._client_handlers[str(handler.context_id)][handler.id] = handler self.sender.write_to_context_handlers( handler, { "type": "connection_opened", "context_id": str(handler.context_id) } ) if new_context: def post_context_callback(response, handler): self.logger.debug("post_context_message") self.context.post_context_message( handler.context_id, 0, "Hi, how can I help you?", callback=lambda res: post_context_callback(res, handler) )
def open(self, handler: WebSocketHandler): self.logger.debug("context_id=%s,suggestion_id=%s", str(handler.context_id), handler.suggest_id) if handler.context_id is None: handler.context_id, handler.context_rev = self.post_context( handler.user_id, handler.application_id, handler.session_id, handler.locale) new_context = True else: new_context = False if str(handler.context_id) not in self._client_handlers: self._client_handlers[str(handler.context_id)] = {} if handler.id not in self._client_handlers[str(handler.context_id)]: self.logger.debug("add handler, context_id=%s,handler_id=%s", str(handler.context_id), handler.id) self._client_handlers[str( handler.context_id)][handler.id] = handler self.sender.write_to_context_handlers( handler, { "type": "connection_opened", "context_id": str(handler.context_id) }) if new_context: def post_context_callback(response, handler): self.logger.debug("post_context_message") self.context.post_context_message( handler.context_id, 0, "Hi, how can I help you?", callback=lambda res: post_context_callback(res, handler))
def post_suggest_callback(self, response, handler: WebSocketHandler, message: dict): self.logger.debug("post_suggest_callback") handler.suggest_id = response.headers["_id"] self.suggest.write_new_suggestion(handler)
def post_suggest_callback(self, response, handler: WebSocketHandler, message: dict): handler.suggest_id = response.headers["_id"] self.suggest.write_new_suggestion(handler)