gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.07k stars 4.44k forks source link

Django app on Heroku will not return response to a statement #1173

Closed engrphil closed 6 years ago

engrphil commented 6 years ago

I am using ChatterBot for a project and I have successfully deployed the modified Django app on Heroku. I had to install WhiteNoise and added it to the MIDDLEWARE_CLASSES. The app interface works fine on Heroku after fixing issue with css and static files but when I entered a message, chatterbot doesn't return any statement when I click on the button. I trained the bot and tested it okay locally before deploying. Any idea what I could be doing wrong? Thank you.

vkosuri commented 6 years ago

Did you tried this package https://github.com/vkosuri/chatterbot-live-example? If possible could you share stack trace of this error? Others can respond your question very easily.

gunthercox commented 6 years ago

@engrphil I haven't used Heroku in a while, but I recall that there was a way to view the error log for the application. Are there any exceptions listed in your error log?

engrphil commented 6 years ago

I just cloned the heroku example suggested by @vkosuri and it worked fine. Chatbot is responding however, the response doesn't correspond the question I am asking even though I have trained the bot on heroku many times with my corpus. The heroku logs show no error whatsoever. Why is the bot not responding accurately?

I am using Heroku free version for now (does that affect the database query?).

gunthercox commented 6 years ago

@engrphil I'm fairly certain that using the free tier of Heroku won't effect your database queries.

Is the app you just deployed an exact copy of @vkosuri's example? (If so I'll deploy my own copy to try to recreate the issue)

Also, what method did you use to train your bot running on Heroku? If the responses weren't accurate it may be an indication that training failed for some reason.

engrphil commented 6 years ago

@gunthercox I specified the path for the corpus data in settings.py and then run $ heroku run python manage.py train:

MacBook-Pro:chatterbot-live-example Phil$ heroku run python manage.py train ai.yml Training: [####################] 100% botprofile.yml Training: [####################] 100% computers.yml Training: [####################] 100% conversations.yml Training: [####################] 100% emotion.yml Training: [####################] 100% food.yml Training: [####################] 100% gossip.yml Training: [####################] 100% greetings.yml Training: [####################] 100% history.yml Training: [####################] 100% humor.yml Training: [####################] 100% literature.yml Training: [####################] 100% money.yml Training: [####################] 100% movies.yml Training: [####################] 100% onemtdataone.yml Training: [####################] 100% politics.yml Training: [####################] 100% psychology.yml Training: [####################] 100% science.yml Training: [####################] 100% sports.yml Training: [####################] 100% trivia.yml Training: [####################] 100%

Basically, I used the exact copy of @vkosuri since my customized version failed to talk to ChatterBot. The reason for that was the missing app.json in my own deployment. Maybe I should try train the bot locally before deploying to heroku.

engrphil commented 6 years ago

I just tried to train the bot locally before deploying to heroku. I got the following error of non-existing table:

File "/var/root/eb-virt/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such table: django_chatterbot_tag

@gunthercox you are right, that means the bot was never trained properly on heroku.

engrphil commented 6 years ago

$ python manage.py migrate --run-syncdb

solved the database error

gunthercox commented 6 years ago

Awesome! I'm glad to hear it was fixed.

engrphil commented 6 years ago

As a follow up. The app wasn't responding due no SQLite on heroku. To have app working on heroku, you will need the dj_database_url package to nicely use PostgreSQL DB on heroku since SQLite is not supported. You will modify your settings.py as follows:

import dj_database_url

db_from_env = dj_database_url.config()

DATABASES={'default': dj_database_url.config()}

vkosuri commented 6 years ago

Thanks, I have added your notes here https://github.com/vkosuri/chatterbot-live-example

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.