-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (24 loc) · 752 Bytes
/
app.py
File metadata and controls
32 lines (24 loc) · 752 Bytes
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
import logging
from flask import Flask, request, render_template
from engine import generate_datablocks_embeddings, chatbot_qa
# Definir nivel de logger
logging.basicConfig(level=logging.DEBUG)
# Criar embeddings para o conteudo
generate_datablocks_embeddings()
logging.info("Dados preparados. Pronto!")
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
# Obter o input to utilizador
user_input = request.args.get("msg")
if user_input:
# Gerar resposta ao input do utilzador
response = chatbot_qa(user_input)
else:
response = "Peço desculpa, não entendi."
return response
if __name__ == "__main__":
app.run()