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¶

The 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.

### Response selection¶

The 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.

Confidence Statement
0.2 Good morning
0.5 Good morning
0.7 Good night

In this case, two of the logic adapters have generated the same result. When multiple logic adapters come 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.

## Methods¶

class chatterbot.logic.multi_adapter.MultiLogicAdapter(**kwargs)[source]

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.

add_adapter(adapter, **kwargs)[source]

Appends a logic adapter to the list of logic adapters being used.

get_adapters()[source]

Return a list of all logic adapters being used, including system logic adapters.

get_greatest_confidence(statement, options)[source]

Returns the greatest confidence value for a statement that occurs multiple times in the set of options.

Parameters: statement – A statement object. options – A tuple in the format of (confidence, statement).
get_initialization_functions()[source]

Get the initialization functions for each logic adapter.

insert_logic_adapter(logic_adapter, insert_index, **kwargs)[source]

Parameters: logic_adapter (str) – The string path to the logic adapter to add. insert_index (int) – The index to insert the logic adapter into the list at.
process(statement)[source]

Returns the output of a selection of logic adapters for a given input statement.

Parameters: statement – The input statement to be processed.
remove_logic_adapter(adapter_name)[source]

Removes a logic adapter from the chat bot.

Parameters: adapter_name (str) – The class name of the adapter to remove.
set_chatbot(chatbot)[source]

Set the chatbot for each of the contained logic adapters.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.15283499658107758, "perplexity": 2612.3213183102603}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-30/segments/1531676593051.79/warc/CC-MAIN-20180722061341-20180722081341-00222.warc.gz"}