ChatterBot internally uses a special logic adapter that allows it to choose the best response generated by any number of other logic adapters.
Selecting a response from multiple logic adapters¶
MultiLogicAdapter is used to select a single response from the responses
returned by all of the logic adapters that the chat bot has been configured to use.
Each response returned by the logic adapters includes a confidence score that indicates
the likeliness that the returned statement is a valid response to the input.
MultiLogicAdapter will return the response statement that has the greatest
confidence score. The only exception to this is a case where multiple logic adapters
return the same statement and therefore agree on that response.
For this example, consider a scenario where multiple logic adapters are being used. Assume the following results were returned by a chat bot’s logic adapters.
In this case, two of the logic adapters have generated the same result. When multiple logic adapters come to to the same conclusion, that statement is given priority over another response with a possibly higher confidence score. The fact that the multiple adapters agreed on a response is a significant indicator that a particular statement has a greater probability of being a more accurate response to the input.
When multiple adapters agree on a response, the greatest confidence score that was generated for that response will be returned with it.
MultiLogicAdapter allows ChatterBot to use multiple logic adapters. It has methods that allow ChatterBot to add an adapter, set the chat bot, and process an input statement to get a response.
Appends a logic adapter to the list of logic adapters being used.
Parameters: adapter (LogicAdapter) – The logic adapter to be added.
Return a list of all logic adapters being used, including system logic adapters.
Returns the greatest confidence value for a statement that occurs multiple times in the set of options.
- statement – A statement object.
- options – A tuple in the format of (confidence, statement).
insert_logic_adapter(logic_adapter, insert_index, **kwargs)¶
Adds a logic adapter at a specified index.
Returns the outout of a selection of logic adapters for a given input statement.
Parameters: statement – The input statement to be processed.
Removes a logic adapter from the chat bot.
Parameters: adapter_name (str) – The class name of the adapter to remove.
Set the chatbot for each of the contained logic adapters.