Logic Adapters
Use this sub-skill when a task asks how ChatterBot chooses a response, how to configure built-in logic adapters, how to add a custom adapter, why confidence values behave a certain way, or how experimental Ollama/OpenAI adapters expose deterministic adapters as tools.
Quick route
- Read references/logic-api.md for verified adapter signatures, parameters, and response-selection surfaces.
- Read references/workflows.md for concrete BestMatch, default response, math/time/unit conversion, specific response, custom adapter, and LLM-tool recipes.
- Read references/troubleshooting.md for optional dependencies, missing
model, provider/service failures, invalid adapter dicts, and confidence surprises.
- Run scripts/logic_adapter_demo.py for deterministic math/time/specific/default/unit adapter smoke checks.
Built-in adapters
| Adapter |
Use for |
Notes |
BestMatch |
find learned responses from storage |
default adapter; uses search + response selection |
SpecificResponseAdapter |
exact or matcher-triggered canned response |
requires input_text and output_text |
MathematicalEvaluation |
natural-language or symbolic math |
uses mathparse; also exposes calculate as a tool |
TimeLogicAdapter |
current time questions |
uses spaCy phrase matching; also exposes current time as a tool |
UnitConversion |
natural-language unit conversion |
requires pint; exposes convert_units as a tool |
OllamaLogicAdapter |
experimental local/remote Ollama responses |
requires model, client package, and an Ollama service |
OpenAILogicAdapter |
experimental OpenAI-compatible responses |
requires model, client package, and credentials/base URL |
Adapter configuration pattern
Use import paths or config dictionaries:
from chatterbot import ChatBot
bot = ChatBot(
"Logic Bot",
logic_adapters=[
{
"import_path": "chatterbot.logic.BestMatch",
"default_response": "I am sorry, but I do not understand.",
"maximum_similarity_threshold": 0.90,
},
{
"import_path": "chatterbot.logic.SpecificResponseAdapter",
"input_text": "Help me!",
"output_text": "Read the support guide.",
},
],
)
If multiple adapters can process a statement, ChatterBot returns the response with the highest confidence, with special handling when multiple adapters agree on the same statement.
Boundaries
1---2name: logic-adapters3description: "Configure ChatterBot logic adapters, response selection,4 comparison methods, custom adapters, MCP tool adapters, and experimental5 Ollama/OpenAI LLM adapters."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/logic-adapters9 disco-role: operating10license: BSD 3-Clause11---1213# Logic Adapters1415Use this sub-skill when a task asks how ChatterBot chooses a response, how to configure built-in logic adapters, how to add a custom adapter, why confidence values behave a certain way, or how experimental Ollama/OpenAI adapters expose deterministic adapters as tools.1617## Quick route18191. Read [references/logic-api.md](references/logic-api.md) for verified adapter signatures, parameters, and response-selection surfaces.202. Read [references/workflows.md](references/workflows.md) for concrete BestMatch, default response, math/time/unit conversion, specific response, custom adapter, and LLM-tool recipes.213. Read [references/troubleshooting.md](references/troubleshooting.md) for optional dependencies, missing `model`, provider/service failures, invalid adapter dicts, and confidence surprises.224. Run [scripts/logic_adapter_demo.py](scripts/logic_adapter_demo.py) for deterministic math/time/specific/default/unit adapter smoke checks.2324## Built-in adapters2526| Adapter | Use for | Notes |27| --- | --- | --- |28| `BestMatch` | find learned responses from storage | default adapter; uses search + response selection |29| `SpecificResponseAdapter` | exact or matcher-triggered canned response | requires `input_text` and `output_text` |30| `MathematicalEvaluation` | natural-language or symbolic math | uses `mathparse`; also exposes `calculate` as a tool |31| `TimeLogicAdapter` | current time questions | uses spaCy phrase matching; also exposes current time as a tool |32| `UnitConversion` | natural-language unit conversion | requires `pint`; exposes `convert_units` as a tool |33| `OllamaLogicAdapter` | experimental local/remote Ollama responses | requires `model`, client package, and an Ollama service |34| `OpenAILogicAdapter` | experimental OpenAI-compatible responses | requires `model`, client package, and credentials/base URL |3536## Adapter configuration pattern3738Use import paths or config dictionaries:3940```python41from chatterbot import ChatBot4243bot = ChatBot(44 "Logic Bot",45 logic_adapters=[46 {47 "import_path": "chatterbot.logic.BestMatch",48 "default_response": "I am sorry, but I do not understand.",49 "maximum_similarity_threshold": 0.90,50 },51 {52 "import_path": "chatterbot.logic.SpecificResponseAdapter",53 "input_text": "Help me!",54 "output_text": "Read the support guide.",55 },56 ],57)58```5960If multiple adapters can process a statement, ChatterBot returns the response with the highest confidence, with special handling when multiple adapters agree on the same statement.6162## Boundaries6364- For `ChatBot` lifecycle, `Statement`, taggers, and search classes, use [core-chatbot](../core-chatbot/SKILL.md).65- For training data that powers `BestMatch`, use [training](../training/SKILL.md).66- For SQL/Mongo/Redis storage behavior used by search, use [storage-adapters](../storage-adapters/SKILL.md).67- For Django-specific adapter usage, use [django-integration](../django-integration/SKILL.md).