Hey, after I started using the mongodb storage adapter, I keep getting this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 247, in _run_extra
yield from coro(*args, **kwargs)
File "./mods/AI.py", line 47, in on_message
msg = "**{0}**\n".format(message.author.name)+str(chatbot.get_response(message.content))
File "/usr/local/lib/python3.5/dist-packages/chatterbot/chatterbot.py", line 149, in get_response
self.storage.update(input_statement)
File "/usr/local/lib/python3.5/dist-packages/chatterbot/adapters/storage/mongodb.py", line 126, in update
data = statement.serialize()
File "/usr/local/lib/python3.5/dist-packages/chatterbot/conversation/statement.py", line 80, in serialize
data["in_response_to"].append(response.serialize())
File "/usr/local/lib/python3.5/dist-packages/chatterbot/conversation/statement.py", line 80, in serialize
data["in_response_to"].append(response.serialize())
AttributeError: 'dict' object has no attribute 'serialize'
This sounds like an issue that may have been fixed in a recent release of ChatterBot, can you confirm what version you are using?
I installed 2 weeks ago, I'll try pip upgrade, if nothing I'll update from the repo.
It seems as I was on the latest version, 0.4.3 but I've went ahead and uninstalled pip and installed from source. Hope the issue is fixed, closed for now.
Hey, I'm still getting it for some reason even after a full update,
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 247, in _run_extra
yield from coro(_args, *_kwargs)
File "./mods/AI.py", line 47, in on_message
msg = "{0}\n".format(message.author.name)+str(chatbot.get_response(message.content))
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.3-py3.5.egg/chatterbot/chatterbot.py", line 149, in get_response
self.storage.update(input_statement)
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.3-py3.5.egg/chatterbot/adapters/storage/mongodb.py", line 126, in update
data = statement.serialize()
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.3-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
data["in_response_to"].append(response.serialize())
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.3-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
data["in_response_to"].append(response.serialize())
AttributeError: 'dict' object has no attribute 'serialize'
Hi, I can't seem to replicate this issue. Can you post some more information to help me debug this:
ChatBot() constructor.Python version: 3.5
chatbot = ChatBot("NotSoBot",
storage_adapter="chatterbot.adapters.storage.MongoDatabaseAdapter",
logic_adapter="chatterbot.adapters.logic.ClosestMeaningAdapter",
input_adapter="chatterbot.adapters.input.VariableInputTypeAdapter",
output_adapter="chatterbot.adapters.output.OutputFormatAdapter",
format='text',
database='chatterbot-database',
database_uri='mongodb://localhost:27017/')
chatbot.set_trainer(ChatterBotCorpusTrainer)
chatbot.train("chatterbot.corpus.english")
It works first time, few times actually but then for no reason starts to error. I receive it around 50 times and then no responses work until I reload it and it starts working again.
Alright, thank you. I will see if I can track down where this is happening.
@NotSoSuper Not sure if this is part of the issue, but I believe you may needs to specify output_format='text' instead of format='text' in your code. It appears this was incorrect in the documentation.
Alright, testing it now, thanks for the update!
Seems to be working good now, had a few testers. Thanks!
and its back :(
Sorry about the long wait on this. I believe I have finally tracked down the source of the issue. It appears that in some cases, statement objects were being added to the response list of other statements. While this should have been Ok in theory since both objects share a similar API, it actually caused a problem during deserialization because some of the attributes remained in dictionary form. #224 should correct this issue.
Just upgraded @gunthercox and it's back but in a new format,
`Traceback (most recent call last):
File "./mods/AI.py", line 51, in on_message
msg = "{0}\n".format(message.author.name)+str(chatbot.get_response(message.content))
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/chatterbot.py", line 149, in get_response
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/adapters/storage/mongodb.py", line 128, in update
data = statement.serialize()
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
def serialize(self):
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
def serialize(self):
AttributeError: 'dict' object has no attribute 'serialize'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 247, in _run_extra
yield from coro(_args, *_kwargs)
File "./mods/AI.py", line 54, in on_message
msg = "{0}\n".format(message.author.name)+str(chatbot.get_response(message.content))
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/chatterbot.py", line 149, in get_response
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/adapters/storage/mongodb.py", line 128, in update
data = statement.serialize()
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
def serialize(self):
File "/usr/local/lib/python3.5/dist-packages/ChatterBot-0.4.5-py3.5.egg/chatterbot/conversation/statement.py", line 85, in serialize
def serialize(self):
AttributeError: 'dict' object has no attribute 'serialize'`
sorry for all the issue this bug is causing :(
@NotSoSuper I haven't created a new release on PyPy with the changes I made yet. Did you upgrade with pip or from the code on GitHub?
Also, its good that you are reporting the issue. It all helps to improve ChatterBot for everyone who uses it.
I pulled from github and ran python3.5 setup.py install
It seems as the error is different as you made the serialize in a function now
You think wiping my mongodb for the data would work? I would rather not because I have a lot of data from users using it however I will if needed.
You could specify a different database name and your old data would be safe while you test your theory.
yeah, that's what I was thinking. I'll try it when I get home, thanks.
@NotSoSuper Any success?
Oh sorry, forgot to respond. After updating again with your new commits a few days later, I haven't received the error again. Everything seems well at this point and it's fast. Thanks for keeping in check and continuing development of this project!
Awesome, glad to hear!
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.