-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (24 loc) · 855 Bytes
/
main.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
# ================================================================================
# Main script
# ================================================================================
from flask import Flask, render_template, request
from utils import setup_dbqa
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/get", methods=["GET", "POST"])
def chat():
msg = request.form["msg"]
input = msg
try:
return get_chat_response(input)
except ValueError:
return "You have exceeded the token limit! Sorry for the inconvenience!"
# Gets the response by passing the prompt to QA Object
def get_chat_response(input):
response = dbqa({"query": input})
return response["result"]
if __name__ == "__main__":
dbqa = setup_dbqa()
app.run(debug=True, port=2000)