MCPcopy
hub / github.com/gunthercox/ChatterBot

github.com/gunthercox/ChatterBot @1.2.14 sqlite

repository ↗ · DeepWiki ↗ · release 1.2.14 ↗
1,640 symbols 5,035 edges 157 files 517 documented · 32%
README

ChatterBot: Machine learning in Python

ChatterBot

ChatterBot is a machine-learning based conversational dialog engine built in Python which makes it possible to generate responses based on collections of known conversations. The language independent design of ChatterBot allows it to be trained to speak any language.

Package Version Python 3.12 Coverage Status Follow on Bluesky Join the chat at https://gitter.im/chatterbot/Lobby

An example of typical input would be something like this:

user: Good morning! How are you doing?
bot: I am doing very well, thank you for asking.
user: You're welcome.
bot: Do you like hats?

How it works

An untrained instance of ChatterBot starts off with no knowledge of how to communicate. Each time a user enters a statement, the library saves the text that they entered and the text that the statement was in response to. As ChatterBot receives more input the number of responses that it can reply to, and the accuracy of each response in relation to the input statement increases. The program selects the closest matching response by searching for the closest matching known statement that matches the input, it then returns the most likely response to that statement based on how frequently each response is issued by the people the bot communicates with.

Documentation

View the documentation for ChatterBot.

Installation

This package can be installed from PyPi by running:

pip install chatterbot

Basic Usage

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

# Get a response to an input statement
chatbot.get_response("Hello, how are you today?")

Training data

ChatterBot comes with a data utility module that can be used to train chat bots. At the moment there is training data for over a dozen languages in this module. Contributions of additional training data or training data in other languages would be greatly appreciated. Take a look at the data files in the chatterbot-corpus package if you are interested in contributing.

from chatterbot.trainers import ChatterBotCorpusTrainer

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train based on the english corpus
trainer.train("chatterbot.corpus.english")

# Train based on english greetings corpus
trainer.train("chatterbot.corpus.english.greetings")

# Train based on the english conversations corpus
trainer.train("chatterbot.corpus.english.conversations")

Corpus contributions are welcome! Please make a pull request.

Examples

For examples, see the examples section of the documentation.

History

See release notes for changes https://github.com/gunthercox/ChatterBot/releases

Contributing

Contributions are welcomed, to help ensure a smooth process please start with the contributing guidelines in our documentation: https://docs.chatterbot.us/contributing/

Sponsors

ChatterBot is sponsored by:

License

ChatterBot is licensed under the BSD 3-clause license.

Core symbols most depended-on inside this repo

filter
called by 201
chatterbot/storage/mongodb.py
create
called by 170
chatterbot/storage/mongodb.py
get
called by 142
examples/django_example/django_example/views.py
get_response
called by 80
chatterbot/chatterbot.py
get_tags
called by 69
chatterbot/conversation.py
train
called by 53
chatterbot/trainers.py
update
called by 48
chatterbot/storage/mongodb.py
jQuery
called by 47
examples/django_example/django_example/static/js/jquery.js

Shape

Method 860
Class 587
Function 193

Languages

Python89%
TypeScript11%

Modules by API surface

chatterbot/languages.py403 symbols
examples/django_example/django_example/static/js/jquery.js77 symbols
tests/test_parsing.py56 symbols
examples/django_example/django_example/static/js/bootstrap.js51 symbols
tests/storage/test_mongo_adapter.py49 symbols
tests/django_integration/test_django_adapter.py48 symbols
tests/storage/test_sql_adapter.py46 symbols
tests/test_chatbot.py44 symbols
tests/storage/test_redis_adapter.py39 symbols
docs/_static/silktide-consent-manager.js39 symbols
chatterbot/trainers.py30 symbols
chatterbot/logic/llm_adapters.py30 symbols

Dependencies from manifests, versioned

chatterbot1.2 · 1×
django4.2 · 1×
tqdm

Datastores touched

(mongodb)Database · 1 repos
chatterbot-databaseDatabase · 1 repos
chatterbot_test_databaseDatabase · 1 repos

For agents

$ claude mcp add ChatterBot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact