Skip to content

Commit 86ddb54

Browse files
committed
Added base chatbot action to get a response
1 parent 92131cf commit 86ddb54

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from chatterbot import ChatBot
2+
from chatterbot.trainers import ChatterBotCorpusTrainer
3+
from PyMatcha.utils.static import BACKEND_ROOT
4+
5+
6+
def get_chatbot_response(bot_name, user_input):
7+
chatbot = ChatBot(
8+
bot_name,
9+
storage_adapter="chatterbot.storage.SQLStorageAdapter",
10+
database_uri=f"sqlite:///{BACKEND_ROOT}/../chatbot_database.sqlite3",
11+
)
12+
13+
trainer = ChatterBotCorpusTrainer(chatbot, show_training_progress=False)
14+
trainer.train(
15+
"chatterbot.corpus.english.conversations",
16+
"chatterbot.corpus.english.emotion",
17+
"chatterbot.corpus.english.greetings",
18+
"chatterbot.corpus.english.humor",
19+
"PyMatcha.utils.dating",
20+
)
21+
return chatbot.get_response(user_input)

0 commit comments

Comments
 (0)