I'm trying to make a simple QnA program using Python chatterbot.
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
bot = ChatBot(
"SQLMemoryTerminal",
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
"import_path": "chatterbot.logic.BestMatch",
"statement_comparison_function":
"chatterbot.comparisons.levenshtein_distance"
},
{
'import_path' : 'chatterbot.logic.LowConfidenceAdapter',
'threshold' : 0.3,
'default_response' : "Sorry. I can not find the exact answer."
},
'chatterbot.logic.multi_adapter.MultiLogicAdapter',
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
read_only= True
)
print("input question")
while True:
try:
print("Q : ",end="")
bot_input = bot.get_response(None)
except (KeyboardInterrupt, EOFError, SystemExit):
break
However, when I try to use the multiadapter function built in chatterbot, I get an error.
Traceback (most recent call last):
File "C:/Users/KPvoice/PycharmProjects/Contact/ChatterbotTest.py", line
30, in <module>
bot_input = bot.get_response(None)
File "C:\Python36\lib\site-packages\chatterbot\chatterbot.py", line 113,
in get_response
statement, response = self.generate_response(input_statement,
conversation_id)
File "C:\Python36\lib\site-packages\chatterbot\chatterbot.py", line 132,
in generate_response
response = self.logic.process(input_statement)
File "C:\Python36\lib\site-packages\chatterbot\logic\multi_adapter.py",
line 52, in process
output = adapter.process(statement)
File "C:\Python36\lib\site-packages\chatterbot\logic\multi_adapter.py",
line 89, in process
result.confidence = max_confidence
AttributeError: 'NoneType' object has no attribute 'confidence'
I do not know how to solve it.
The working environment is Windows 10, Python 3.7
The
MultiLogicAdapter
typically doesn't get used directly in this way.Each logic adapter that you add to the
logic_adapters=[]
will get processed by theMultiLogicAdapter
internally by ChatterBot, no need to explicitly specify it.