Spaces:
Running
Running
EbubeJohnEnyi
commited on
Commit
•
03a5abf
1
Parent(s):
72e2a6e
Update ChatBot.py
Browse files- ChatBot.py +21 -17
ChatBot.py
CHANGED
@@ -56,26 +56,30 @@ def find_question_and_answer(json_file, question, input_ids):
|
|
56 |
generated_response = tokenizer.decode(generated_output[0], skip_special_tokens=True)
|
57 |
return generated_response
|
58 |
|
59 |
-
@app.route("/")
|
60 |
-
def index():
|
61 |
-
|
62 |
|
63 |
-
@app.route('/ask', methods=['POST'])
|
64 |
-
def ask():
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
|
79 |
|
80 |
if __name__ == '__main__':
|
81 |
-
|
|
|
|
|
|
|
|
|
|
56 |
generated_response = tokenizer.decode(generated_output[0], skip_special_tokens=True)
|
57 |
return generated_response
|
58 |
|
59 |
+
# @app.route("/")
|
60 |
+
# def index():
|
61 |
+
# return render_template('index.html')
|
62 |
|
63 |
+
# @app.route('/ask', methods=['POST'])
|
64 |
+
# def ask():
|
65 |
+
# user_input = request.form['user_input']
|
66 |
+
# if not user_input:
|
67 |
+
# response = ""
|
68 |
+
# else:
|
69 |
+
# input_ids = tokenizer.encode(user_input, return_tensors='pt')
|
70 |
+
# response = find_question_and_answer(json_file_path, user_input, input_ids)
|
71 |
|
72 |
+
# if isinstance(response, dict):
|
73 |
+
# response_type = "mapping"
|
74 |
+
# else:
|
75 |
+
# response_type = "string"
|
76 |
|
77 |
+
# return render_template('index.html', user_input=user_input, response=response, response_type=response_type)
|
78 |
|
79 |
|
80 |
if __name__ == '__main__':
|
81 |
+
user_input = st.text_area("Ask Haven AI: ")
|
82 |
+
response = find_question_and_answer(json_file_path, user_input)
|
83 |
+
st.write(response)
|
84 |
+
app.run(debug=True)
|
85 |
+
|