This repository was archived by the owner on May 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
76 lines (56 loc) · 1.79 KB
/
app.py
File metadata and controls
76 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from flask import Flask, jsonify, request
from functionalities import getResponse, loadTextGetVector
application = Flask(__name__)
@application.route('/response', methods=["POST"])
def getBotResponse():
data = request.get_json()
response = {
"status": "success",
"message": "Invalid Payload"
}
if not data:
return jsonify(response), 400
text = data.get('text')
temperature = data.get('temperature')
if not text:
response["message"] = "Text not Found"
return jsonify(response), 400
if not temperature:
temperature = 0.5
try:
temperature = float(temperature)
except ValueError:
response["message"] = "Temperature isn't Float"
return jsonify(response), 400
outText = getResponse(text.lower(), temp=temperature)
response["status"] = "success"
response["message"] = "successfully added the response"
response["response_text"] = outText
return jsonify(response), 200
@application.route('/vector', methods=["POST"])
def getVector():
data = request.get_json()
response = {
"status": "success",
"message": "Invalid Payload"
}
if not data:
return jsonify(response), 400
text = data.get('text')
if not text:
response["message"] = "Text not Found"
return jsonify(response), 400
outVec = loadTextGetVector(text.lower())
response["status"] = "success"
response["message"] = "successfully get the vector of the value"
response["response_vector"] = outVec
return jsonify(response), 200
@application.route('/')
def main():
response = {
"status": "success",
"message": "Pong"
}
return jsonify(response), 200
if __name__ == '__main__':
application.run(debug=True, host='0.0.0.0', port=80)