def listUsers(): print('debug1') users = getUsers() schema = UserSchema(many=True) print('debug2') return ResponseHttp(response=json.dumps(schema.dump(users)), status=200, mimetype="application/json")
def getAllCvsWLowClassify(): try: conversations = getAllCvsWithLowClassify() schema = ConversationSchema(many=True) return ResponseHttp(response=json.dumps(schema.dump(conversations)), status=200, mimetype="application/json") except exc.SQLAlchemyError: return errorResp()
def getUser(id): try: print('debug1') user = getSingleUser(id) schema = UserSchema() return ResponseHttp(response=json.dumps(schema.dump(user)), status=200, mimetype="application/json") except exc.SQLAlchemyError: return errorResp()
def loginUser(): try: userJSON = request.get_json() user = getUserByUsername(userJSON['username']) print(user) if(user != None): schema = UserSchema() if(user.password == userJSON['password']): return ResponseHttp(response=json.dumps(schema.dump(user)), status=200, mimetype="application/json") else: return errorResp() else: return errorResp() except exc.SQLAlchemyError: return errorResp()
def responseChatbot(): question = request.get_json() print(question) classi = chatBotClassify(question['question']) print(len(classi)) print(question['question'],classi) classi_dict={} for classification in classi: classi_dict[classification[0]] = "{!s}".format(classification[1]) cv = Conversation() if(len(classi) != 0): classify = classi[0] cv.classify = classify[1] responseDict = chatBotResponse(question['question']) cv.response = Response() cv.response = getSingleResponse(responseDict['id']) cv.intent = Intent() cv.intent = getIntentByName(classify[0]) else: cv.classify = 0 cv.intent = Intent() cv.intent = getIntentByName("NAO_SEI") cv.response = random.choice(cv.intent.responses) cv.user = getSingleUser(question['idUser']) cv.question = question['question'] addConversation(cv) conversationSchema = ConversationSchema() return ResponseHttp(response=json.dumps(conversationSchema.dump(cv)), status=200, mimetype="application/json")
def getIntentByTag(tagName): intent = getIntentByName(tagName) schema = IntentSchema() return ResponseHttp(response=json.dumps(schema.dump(intent)), status=200, mimetype="application/json")
def listIntents(): intents = getIntents() schema = IntentSchema(many=True) return ResponseHttp(response=json.dumps(schema.dump(intents)), status=200, mimetype="application/json")