How to use the chatterbot.ChatBot function in ChatterBot

To help you get started, we’ve selected a few ChatterBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gunthercox / chatterbot-corpus / tests / base_case.py View on Github external
def setUp(self):
        self.test_data_directory = None
        self.chatbot = ChatBot('Test Bot', **self.get_kwargs())
github gunthercox / ChatterBot / tests / test_adapter_validation.py View on Github external
def test_invalid_storage_adapter(self):
        kwargs = self.get_kwargs()
        kwargs['storage_adapter'] = 'chatterbot.logic.LogicAdapter'
        with self.assertRaises(Adapter.InvalidAdapterTypeException):
            self.chatbot = ChatBot('Test Bot', **kwargs)
github gunthercox / ChatterBot / examples / hipchat_bot.py View on Github external
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from settings import HIPCHAT

'''
See the HipChat api documentation for how to get a user access token.
https://developer.atlassian.com/hipchat/guide/hipchat-rest-api/api-access-tokens
'''

chatbot = ChatBot(
    'HipChatBot',
    hipchat_host=HIPCHAT['HOST'],
    hipchat_room=HIPCHAT['ROOM'],
    hipchat_access_token=HIPCHAT['ACCESS_TOKEN'],
    input_adapter='chatterbot.input.HipChat',
    output_adapter='chatterbot.output.HipChat'
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# The following loop will execute each time the user enters input
while True:
    try:
        response = chatbot.get_response(None)
github tech-quantum / sia-cog / bot / chatbot.py View on Github external
def getBot(name):
    botfolder = "./data/__chatbot/" + name
    if not os.path.exists(botfolder):
        os.makedirs(botfolder)

    dbpath = "sqlite:///" + botfolder + "/bot.db"

    bot = ChatBot(
        name,
        storage_adapter='chatterbot.storage.SQLStorageAdapter',
        database_uri=dbpath,
        filters=["chatterbot.filters.RepetitiveResponseFilter"],
        preprocessors=[
            'chatterbot.preprocessors.clean_whitespace',
            'chatterbot.preprocessors.convert_to_ascii'
        ],
        logic_adapters=[
            {
                'import_path': 'chatterbot.logic.BestMatch',
                "statement_comparision_function": "chatterbot.comparisions.levenshtein_distance",
                "response_selection_method": "chatterbot.response_selection.get_first_response"
            }
        ]
    )
github gunthercox / ChatterBot / examples / specific_response_example.py View on Github external
from chatterbot import ChatBot


# Create a new instance of a ChatBot
bot = ChatBot(
    'Exact Response Example Bot',
    storage_adapter='chatterbot.storage.SQLStorageAdapter',
    logic_adapters=[
        {
            'import_path': 'chatterbot.logic.BestMatch'
        },
        {
            'import_path': 'chatterbot.logic.SpecificResponseAdapter',
            'input_text': 'Help me!',
            'output_text': 'Ok, here is a link: http://chatterbot.rtfd.org'
        }
    ]
)

# Get a response given the specific input
response = bot.get_response('Help me!')
github gunthercox / ChatterBot / examples / tkinter_gui.py View on Github external
def __init__(self, *args, **kwargs):
        """
        Create & set window variables.
        """
        tk.Tk.__init__(self, *args, **kwargs)

        self.chatbot = ChatBot(
            "GUI Bot",
            storage_adapter="chatterbot.storage.SQLStorageAdapter",
            logic_adapters=[
                "chatterbot.logic.BestMatch"
            ],
            database_uri="sqlite:///database.sqlite3"
        )

        self.title("Chatterbot")

        self.initialize()
github lu-ci / apex-sigma-core / sigma / modules / core_functions / chat_bot / chat_bot.py View on Github external
def get_cb(db):
    global cb_cache
    if not cb_cache:
        cb_cache = ChatBot(
            "Sigma",
            database='chatterbot',
            database_uri=db.db_address,
            storage_adapter='chatterbot.storage.MongoDatabaseAdapter',
            output_format='text'
        )
    return cb_cache
github gunthercox / ChatterBot / chatterbot / ext / django_chatterbot / management / commands / train.py View on Github external
def handle(self, *args, **options):
        from chatterbot import ChatBot
        from chatterbot.ext.django_chatterbot import settings

        chatterbot = ChatBot(**settings.CHATTERBOT)

        chatterbot.train(chatterbot.training_data)

        style = self.style.SUCCESS

        self.stdout.write(style('Starting training...'))
        training_class = chatterbot.trainer.__class__.__name__
        self.stdout.write(style('ChatterBot trained using "%s"' % training_class))
github bocadilloproject / bocadillo / docs / guide / tutorial / chatbot / bot.py View on Github external
# chatbot/bot.py
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

diego = ChatBot("Diego")

trainer = ChatterBotCorpusTrainer(diego)
trainer.train(
    "chatterbot.corpus.english.greetings",
    "chatterbot.corpus.english.conversations",
)