def get_prediction_mask():
    try:
        input_text = ' '.join(request.json['input_text'].split())
        top_k = request.json['top_k']
        res = main.get_all_predictions(input_text, top_clean=int(top_k))
        return app.response_class(response=json.dumps(res), status=200, mimetype='application/json')
    except Exception as error:
        err = str(error)
        print(err)
        return app.response_class(response=json.dumps(err), status=500, mimetype='application/json')
Example #2
0
def get_prediction_eos():
    try:
        input_text = " ".join(request.json["input_text"].split())
        input_text += " <mask>"
        top_k = request.json["top_k"]
        res = main.get_all_predictions(input_text, top_clean=int(top_k))
        return app.response_class(response=json.dumps(res),
                                  status=200,
                                  mimetype="application/json")
    except Exception as error:
        err = str(error)
        print(err)
        return app.response_class(response=json.dumps(err),
                                  status=500,
                                  mimetype="application/json")