def get_bot_response(): print(request.json) msg = request.json.get('msg') print(f'QUESTION: {msg}') answer = chatbot_response(msg) print(f'ANSWER: {answer}') return jsonify({'msg': msg, 'answer': answer})
def get_bot_response(): print(request.json) question = request.json.get('question') print(f'QUESTION: {question}') answer = chatbot_response(question) print(f'ANSWER: {answer}') return jsonify({'question': question, 'answer': answer})
def post(self): message = {"id": str(uuid.uuid4()), "body": self.get_argument("body")} # render_string() returns a byte string, which is not supported # in json, so we must convert it to a character string. retmsg = {"id": str(uuid.uuid4()), "body": self.get_argument("body")} retmsg["body"] = bot.chatbot_response(message["body"]) retmsg["html"] = tornado.escape.to_unicode( self.render_string("message.html", message=retmsg)) message["html"] = tornado.escape.to_unicode( self.render_string("message.html", message=message)) if self.get_argument("next", None): self.redirect(self.get_argument("next")) else: self.write(message) global_message_buffer.add_message(message) global_message_buffer.add_message(retmsg)
def get(): msg = request.args.get("msg") answer = chatbot_response(msg) return answer