-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (34 loc) · 941 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, request, render_template
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer, ChatterBotCorpusTrainer
app = Flask(__name__)
chatbot = ChatBot("Charlie", storage_adapter="chatterbot.storage.SQLStorageAdapter")
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.portuguese")
'''
chatbot = ChatBot(
'Charlie',
#logic_adapters=['chatterbot.logic.BestMatch'],
database_uri="sqlite:///db.sqlite3"
)
trainer = ListTrainer(chatbot)
trainer.train([
"Olá",
"Olá!",
"Como vai você?",
"Estou ótimo",
"Isso é bom de ouvir",
"Obrigado.",
"De nada."
])
'''
@app.route('/')
def index():
return render_template('base.html')
@app.route('/chatbot', methods=['POST'])
def chatbot():
msg = str(request.form.get('text'))
response = chatbot.get_response(msg)
return str(response)
if __name__ == "__main__":
app.run()