OrionBot

Chatbot Class

The Chatbot class is the core of the OrionBot library. It provides the functionality to train a bot with sample text data and to respond to user input with an appropriate response.

Setup

To use the Chatbot class, you will need to import it from the orionbot library:

from orionbot import Chatbot

Once you have imported the Chatbot class, you can create a new instance of it like this:

bot = Chatbot(name='MyBot')

Parameters

The Chatbot class constructor takes the following parameters:

Methods

The Chatbot class has the following methods:

train(input_text: str, response_text: str)

Train the chatbot with the provided input text and response text.

get_response(input_text: str)

Get a response from the chatbot for the provided input text.

Returns a string containing the response generated by the chatbot.

enable_training()

Enable training mode for the chatbot. It will prompt the user for feedback when the bot cannot find a suitable response for the message.

disable_training()

Disables training mode for the chatbot. It will send the “No Response” message, without prompting the user to provide an answer for the bot to remember.

_preprocess(text: str)

Preprocesses the provided text, cleans it up and makes it easier to understand for the bot

Returns a string, cleaned up and optimized for the bot.

set_no_response_message(message: str)

Sets the message, sent by the bot when no suitable answer has been found for the user text.

train_from_file(file_path: str)

Traines the bot from an existing JSON dataset, provided by the user.

train_from_default_file()

Trains the bot from the default dataset, which can also be specified in the class instance.

Table of Contents