0

I am trying to combine multiple logic adapters in Python chatterbot. I cannot seem to get it right. I tried this:

english_bot = ChatBot("English Bot", 
storage_adapter="chatterbot.storage.SQLStorageAdapter",
multi_logic_adapter = [
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"]
)

Only BestMatch seems to be active And I tried this:

english_bot = ChatBot("English Bot", 
storage_adapter="chatterbot.storage.SQLStorageAdapter",
logic_adapter = [
    "chatterbot.logic.multi_adapter.MultiLogicAdapter", 
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"]
)

But I get this error: AttributeError: 'NoneType' object has no attribute 'confidence' and none of the logic_adapters seems to be active.

Thanks, Herb

4 Answers4

0

BestMatch

Adapter is the default adapter for chatterbot, You don't need explicitly specify that. More information http://chatterbot.readthedocs.io/en/stable/logic/index.html#best-match-adapter

And you code should like this

# -*- coding: utf-8 -*-
from chatterbot import ChatBot

bot = ChatBot(
    "English Bot",
    logic_adapters=[
        "chatterbot.logic.MathematicalEvaluation",
        "chatterbot.logic.TimeLogicAdapter"
    ]
)

# Print an example of getting one math based response
response = bot.get_response("What is 4 + 9?")
print(response)

# Print an example of getting one time based response
response = bot.get_response("What time is it?")
print(response)
Mallikarjunarao Kosuri
  • 1,023
  • 7
  • 25
  • 52
  • Thanks, but that does not address the problem. If I do what you suggest, I can get math answers and time answers, but no text answers. For example: **Who is the author of Frankenstein?** The current time is 08:52 AM **what is 4 + 7?** ( 4 + 7 ) = 11. I want to be able to answer all three kinds of questions. – user1430965 Sep 08 '17 at 15:54
0

Every logic adapter in logic_adapters=[] is automatically processed by MultiLogicAdapter. You might need to tweak the confidence levels though.

More info about the MultiLogicAdapter here: http://chatterbot.readthedocs.io/en/stable/logic/multi-logic-adapter.html

0

Multi Logic adapter is an inbuilt class and is not explicitly defined in the code.You can see this statement in the introduction part:"ChatterBot internally uses a special logic adapter that allows it to choose the best response generated by any number of other logic adapters" This is the link - http://chatterbot.readthedocs.io/en/stable/logic/multi-logic-adapter.html

Also, similar query is already available on stackover flow. Refer this as well. Error while using chatterbot

0

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 the MultiLogicAdapter internally by ChatterBot, no need to explicitly specify it.

Sheri
  • 1,383
  • 3
  • 10
  • 26