forked from msamogh/schema_attention_model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
30 lines (21 loc) · 696 Bytes
/
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
from sanic import Sanic
from sanic.response import json
from data_model_utils import load_saved_model
from chat import chat, load_schema_json
DOMAIN = "ride"
TASK = "ride_book"
app = Sanic(__name__)
app.schema = load_schema_json(TASK)
app.model = load_saved_model(task=TASK)
@app.route("/chat", methods=["POST"])
async def chat(request):
history = request.json["context"]
user_message = request.json["message"]
response = await chat.handle_web_message(
history, user_message, app.model, app.schema, TASK, DOMAIN
)
return json(response)
@app.route("/restart_from", methods=["POST"])
async def restart_from(request):
pass
app.run(host="0.0.0.0", port=5000)