ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

After upgrade: "Statement matching query does not exist"

Open Issen007 opened this issue 9 years ago • 6 comments

After upgrading the code I got a new bug. This is happening when I type in a unknown word for the ChatterBot.

Internal Server Error: /api/chatterbot/
Traceback (most recent call last):
  File "/home/chrisp/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/chrisp/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/chrisp/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/chrisp/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/chrisp/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/chrisp/lib/python3.6/site-packages/chatterbot/ext/django_chatterbot/views.py", line 78, in post
    response = self.chatterbot.get_response(input_data, conversation.id)
  File "/home/chrisp/lib/python3.6/site-packages/chatterbot/chatterbot.py", line 119, in get_response
    self.storage.add_to_conversation(conversation_id, statement, response)
  File "/home/chrisp/lib/python3.6/site-packages/chatterbot/storage/django_storage.py", line 176, in add_to_conversation
    first_response = Statement.objects.get(text=response.text)
  File "/home/chrisp/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/chrisp/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
chatterbot.ext.django_chatterbot.models.DoesNotExist: Statement matching query does not exist.

Issen007 avatar Aug 16 '17 07:08 Issen007

A line probably needs to be modified in there to create that statement. I probably missed it when I did the conversation changes for #828

gunthercox avatar Aug 16 '17 23:08 gunthercox

+1, affected by bug.

GitCMDR avatar Dec 10 '17 07:12 GitCMDR

Solution is to downgrade to 0.7.6 for the moment. (At least that worked for me.)

GitCMDR avatar Dec 10 '17 07:12 GitCMDR

Confirm this bug is still there in 0.8.1. The workaround is to stop self-learning by adding the following to Django's settings.py: CHATTERBOT = { ####### 'read_only': True, ####### }

phdggg avatar Dec 16 '17 19:12 phdggg

agree @phdggg , this bug is still in 0.8.2.

kalentang avatar Jan 24 '18 04:01 kalentang

This should be fixed now that #1391 has resulted in the removal of the Conversation model.

gunthercox avatar Sep 15 '18 21:09 gunthercox