3

I have a piece of code I took from an example. It was running fine on repl.it, like a response after few secs. But, some time later, it started returning a response after like 1-3 mins, even more or never.
That started happening suddenly on a run restart. I tried resetting the database. That didn't help. Then I tried making a new repl. That didn't help either

Here is my code:

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import logging


'''
This is an example showing how to train a chat bot using the
ChatterBot Corpus of conversation dialog.
'''

# Enable info level logging
logging.basicConfig(level=logging.INFO)

chatbot = ChatBot('Example Bot')

# Start by training our bot with the ChatterBot corpus data
chatbot.set_trainer(ChatterBotCorpusTrainer)

chatbot.train(
    'chatterbot.corpus.english'
)
while True:
    inp = input("=> ")
    print(chatbot.get_response(inp))

It starts working fine but gets stuck at:

/opt/virtualenvs/python3/lib/python3.8/site-packages/chatterbot/storage/jsonfile.py:24: UnsuitableForProductionWarning:The JsonFileStorageAdapter is not recommended for production environments.
warnings.warn(
=> Hello
INFO:chatterbot.adapters:Recieved input statement: Hello
INFO:chatterbot.adapters:"Hello" is a known statement

Here is the repl link: https://repl.it/@blackskull12/chatterbottest#main.py


If I replace:

chatbot.set_trainer(ChatterBotCorpusTrainer)

chatbot.train(
    'chatterbot.corpus.english'
)

to:

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train(
    'chatterbot.corpus.english'
)

This change works fine on my pc. But gives error on repl. ChatBot has no atribute 'find'

I have no idea where to continue. Can anybody help me and brink some life back to my bot?

Nouman
  • 6,947
  • 7
  • 32
  • 60

1 Answers1

0

TDRL; I'm not sure why it gets "stuck" there but if it works fine on your PC then the problem is likely that the version of chatterbox on Repl.it is an old version (though the repl might not work due to permission issues or performance checks/limits).

The "find" error

As seen in the following github issue tracker:

The find attribute was recently removed in the 1.0.0a1 release, but I'm uncertain why you'd be getting this message from version 0.8.7.

You can either downgrade to a previous version on your PC (to match the version in repl.it)1:

pip3 install chatterbot==0.8.6

or reinstall chatterbox & upgrade it past 1.0.0a1 to working with the chatbot.set_trainer(ChatterBotCorpusTrainer)) method. On your PC that would be:

sudo pip3 uninstall chatterbot
sudo pip3 install chatterbot --no-cache-dir

For Repl.it:2 they have a GUI package manager you can use to install a package as per their docs:

Click on the "Package Box" symbol:

picture of adding package_box on left top

Search for and click on the package then on the Plus sign to add it

Then click on the plus sign

Which should show it as installing version 1.1 ....

Shows dependency installing

To check which version your using on your home desktop & repl use the following (with whatever your Python alias is):

python3 -m chatterbot --version

1: I don't recommend this as it is working on your PC so an upgrade seems the more likely solution.

2: I don't recommend using Repl.it for this as it is a lot for a small repl to handle - took a long time to install the 9 dependencies in my system and repl.it has several CPU limits in place as one would expect. I also have a paid account so that gives me different permissions. If it doesn't work contact their customer service.

LinkBerest
  • 1,281
  • 3
  • 22
  • 30
  • Alright, so I tried updating the module every way in repl. It always installs the old module – Nouman May 27 '20 at 17:58
  • @BlackThunder I added the link to repl.it's package manager and a picture of it showing version >1 – LinkBerest May 27 '20 at 19:25
  • Did you try installing it yourself? Cause when I install from there, it installs version `0.6.3` – Nouman May 27 '20 at 21:48
  • @BlackThunder Then contact Repl.it as the issue would be on their side (works fine for me) and/or ensure your using python3 not python 2 (they still have repls for that and 1.0 doesn't work for 2 as far as I recall so wouldn't be installed) – LinkBerest May 27 '20 at 23:04
  • "`works fine for me`" Do you mean on repl.it or your pc? Cause if it works fine on your pc, works fine on mine as well. The problem is repl. And yeah, my python version there is 3.8.2 so that can't be it. – Nouman May 28 '20 at 13:07
  • I mean repl.it installed 1.0.5 – LinkBerest May 28 '20 at 13:42
  • For me it always installs 0.6.3 on repl.it in python 3.8. How did you install the module? – Nouman May 28 '20 at 18:34
  • 1
    @BlackThunder Same here. – Red Jun 08 '20 at 13:59
  • @AnnZen see note number 2 in the post - if it doesn't work for you it's an issue with Repl.it permissions or limitations and you would need to contact them or move to a system which is meant to be used for this type of application (which a small repl is not). – LinkBerest Jun 09 '20 at 14:08