-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_app.py
36 lines (27 loc) · 916 Bytes
/
start_app.py
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
import flask
import json
from utils.json_utils import dump_user_dialogue_context,load_user_dialogue_context
from main_modules import classifier,chat_robot,medical_robot
def QA(msg):
user_intent=classifier(msg)
# print(user_intent)
if user_intent in ["greet","goodbye","deny","isbot"]:
reply=chat_robot(user_intent)
elif user_intent =="accept":
pass
# reply = load_user_dialogue_context(msg.User['NickName'])
# reply = reply.get("choice_answer")
else:
reply=medical_robot(msg)
reply=reply.get('replay_answer')
return reply
if __name__=="__main__":
app=flask.Flask(__name__)
@app.route("/main",methods=["GET","POST"])
def main():
param=flask.request.get_json()
text = param['Text']
result=QA(text)
return flask.jsonify(result)
# return "123"
app.run("0.0.0.0",port=5003,debug=True)