Skip to content

Commit

Permalink
Use ChatterBot for Sesheta (#117)
Browse files Browse the repository at this point in the history
* Use ChatterBot for Sesheta

* Use fork to install chatterbot on Python 3.8

* Update aicoe/sesheta/chatbot.py

Co-authored-by: Fridolín Pokorný <fpokorny@redhat.com>

Co-authored-by: Saisankar Gochhayat <saisankargochhayat@gmail.com>
  • Loading branch information
fridex and saisankargochhayat committed Dec 4, 2020
1 parent 1143ad5 commit e08f1c8
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 58 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ oauth2client = "*"
expiringdict = "*"
prometheus-async = {extras = ["aiohttp"],version = "*"}
aiographql-client = "*"
chatterbot-corpus = "*"
chatterbot = {ref = "relax-py38", git = "https://github.com/fridex/ChatterBot.git"}

[dev-packages]
pylint = "*"
Expand Down
173 changes: 118 additions & 55 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions aicoe/sesheta/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@


import os
import asyncio
import pathlib
import logging
import random

import aiohttp
from aiohttp import web
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

from aicoe.sesheta.messages import HELP_MESSAGE

Expand All @@ -52,6 +52,9 @@
"sub-mod",
"xtuchyna",
]
_CHATBOT = ChatBot("Sesheta", read_only=True)
_TRAINER = ChatterBotCorpusTrainer(_CHATBOT)
_TRAINER.train("chatterbot.corpus.english")


routes = web.RouteTableDef()
Expand Down Expand Up @@ -148,7 +151,7 @@ async def process_user_text(thread_id: str, text: str) -> str:
return f"⭐ In this Universe, based on relative position of planets and all the galaxies " \
f"I picked {hangouts_userid(random.choice(_THOTH_INHABITANTS))} ⭐"

return "Sorry, I didnt get that... try 'deliver' or 'get tags of'"
return _CHATBOT.get_response(text)


@routes.get("/")
Expand Down

0 comments on commit e08f1c8

Please sign in to comment.