def post(self): """ Returns a answer on a question. * Privileges required: **none** """ data = request.json data_q = data.get('question') intent = intent_classifier.predict(data_q) if intent == 'Code': lang = None code_ans, lang = code(data_q, intent, lang) if type(lang) != str: lang = data.get('question_lang') code_ans, lang = code(data_q, intent, lang) if type(code_ans) != str: result = {} result["options"] = [{ "answer": code_ans[i], "answer_options": i } for i in code_ans] return result, 200, security_headers() elif type(code_ans) == str and type(lang) != str: result = {} result["options"] = [{ "answer": code_ans, "answer_options": i, "answer_lang": lang[i] } for i in lang] return result, 200, security_headers() else: result = { "options": [{ "answer": code_ans, "answer_options": 0, "answer_lang": lang }] } return result, 200, security_headers() else: result1 = des_sol(data_q, intent) if type(result1) != str: result = {} result["options"] = [{ "answer": result1[i], "answer_options": i, "answer_intent": None } for i in result1] return result, 200, security_headers() else: result = { "options": [{ "answer": result1, "answer_options": 0, "answer_intent": None }] } return result, 200, security_headers()
def post(self): """ Returns a answer on a question. * Privileges required: **none** """ data = request.json data_q=data.get('question') intent=intent_classifier.predict(data_q) if intent=='Code': lang=None code_ans,lang=code(data_q,intent,lang) if type(lang)!=str: lang=data.get('question_lang') code_ans,lang=code(data_q,intent,lang) if type(code_ans)!=str: result={} result["options"] = [{"answer": code_ans[i],"answer_options": i} for i in code_ans] return result, 200, security_headers() elif type(code_ans)==str and type(lang)!=str: result={} result["options"] = [{"answer": code_ans,"answer_options": i,"answer_lang":lang[i]} for i in lang] return result, 200, security_headers() else: result={ "options": [{"answer": code_ans ,"answer_options": 0,"answer_lang":lang}] } return result, 200, security_headers() else: result1 = des_sol(data_q,intent) if type(result1)!=str: result={} result["options"] = [{"answer": result1[i],"answer_options": i,"answer_intent":None} for i in result1] return result, 200, security_headers() else: result={ "options": [{"answer": result1 ,"answer_options": 0,"answer_intent":None}] } return result, 200, security_headers()