-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (25 loc) · 820 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
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask, render_template, request, jsonify
from program1 import perform_web_scraping
from program2 import query_question
app = Flask(__name__)
@app.route("/")
def index():
return render_template('chat.html')
@app.route("/get", methods=["GET", "POST"])
def chat():
msg = request.form["msg"]
input = msg
return get_Chat_response(input)
def get_Chat_response(text):
answer=query_question(text)[0]['answer']
score=query_question(text)[0]['score']
if score> 0.35:
return answer
else:
web_answer = perform_web_scraping(text)
if web_answer is not None :
return web_answer
else:
return "No suitable answer found."
if __name__ == '__main__':
app.run(debug=True)