Skip to main content

ChatbotCreator

ChatbotCreator is a python package for creating chatbots(Including discord bots).

Installation

Use the package manager pip to install ChatbotCreator.

pip install chatbot-creator

Data format

First you need to create a json data file and save it as "data.json" in the current directory for creating the machine learning model.

example:

{"data": [
        {"class": "greeting",
         "patterns": ["Hi", "How are you", "Is anyone there?", "Hello", "Good day"],
         "responses": ["Hello!", "Good to see you again!", "Hi there, how can I help?"]
        },
        {"class": "goodbye",
         "patterns": ["cya", "See you later", "Goodbye", "I am Leaving", "bye"],
         "responses": ["Sad to see you go :(", "Talk to you later", "Goodbye!"]
        },
        {"class": "name",
         "patterns": ["what is your name", "what should I call you", "whats your name"],
         "responses": ["You can call me Nacky.", "I'm Nacky!"]
        }
   ]
}

here "class" is the label, "patterns" are the questions for the label and "responses" are the responses or answer for the label.

[NOTE]: You should create the "data.json" file like the given example where it should first have the "data" tag and then other tags exlained in the example.

Usage

To create a simple chatbot, first you need to create the pickle data files

Creating the model.

from ChatbotCreator import ChatbotCreator

main = ChatbotCreator("model.hdf5") # Model file name to save
main.createData("data.json") # The data file that you created. This will create the pickle data files.
main.createModel()'''This will create a neural network model and save it 
with the name that you gave in the first step.
'''

After you have created the pickle data files and the model using the above code, you can remove that.

from ChatbotCreator import Run

run_model = Run("model.hdf5")''' Enter the model file name.'''

while True:
    inp = input("Enter cmd: ")
    if inp == "q":
        break
    pred, response, results, results_index = run_model.run(input_variable=inp) ''' specify the input variable through which you will parse in the input values.
    '''
    print(response)
    # this will run the model

Here- "pred" is the predicted label, "response" is the response for the predicted label, results are the probabilities for every single label and "results_index" is the predicted label's index in "results"

If the chatbot is not confident about a particular question then it will save that question in a text file named "low-confidence-patterns.txt" in your current directory. You can use the queries in the text file to train the model again.

Creating a discord bot

To create a discord bot:

from ChatbotCreator import CreateDiscordBot

discord_bot = CreateDiscordBot("model_file_name", "bot_token", use_wikipedia=True)

'''
model_file_name is the name of the model file, bot_token is the bot_token that you can get in discord and when use_wikipedia is set to True, it will send wikipedia results when the model is not confident about a particular question.
'''

discord_bot.run() # this will run the discord bot

Languages support

To use different spaCy trained pipeline languages (to make your bot speak spanish or french) you may also specify the pipeline name:

discord_bot = CreateDiscordBot("model_file_name", "bot_token", "pt_core_news_lg")

then

run_model = Run("model.hdf5", lang_model="pt_core_news_lg")

You may find different trained models at: Trained Models & Pipelines

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

See the source code here /chatbot-creator/ChatbotCreator/

Issues and Problems

Currently, the CreateDiscordBot class has some issues which are:

1st issue) It can't be ran as a python notebook, it raises an error which needs help. It can only be ran as a python script.(class CreateDiscordBot)

2nd problem) When running the discord bot, it will function normally and send messages to the discord server for the queries but it will not return the predicted label to us.(class CreateDiscordBot) 

License

MIT License

Metadata

Release files for chatbot-creator 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chatbot-creator 0.0.7
File Size Uploaded Provenance Actions
chatbot-creator-0.0.7.tar.gz 6.3 kB Without provenance Details for chatbot-creator-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chatbot-creator 0.0.7
File Interpreter ABI Platform Actions
chatbot_creator-0.0.7-py3-none-any.whl Python 3 none any Details for chatbot_creator-0.0.7-py3-none-any.whl

Total release size: 14.7 kB

Release files / chatbot-creator-0.0.7.tar.gz

Download URL chatbot-creator-0.0.7.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ff2ae9784f7e6226c443f52eae4f665e883009084b84cb1f5152b0b66c7265d8
BLAKE2b-256 checksum
How to use checksums
c0834759a16443bfd0bd4ac02010979d70eaa88ed5624adf2d6d0be95d856029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / chatbot_creator-0.0.7-py3-none-any.whl

Download URL chatbot_creator-0.0.7-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97af4322b8de79908b0edd23730c00075967bb38fe6ebe083505ec1ecfeba774
BLAKE2b-256 checksum
How to use checksums
181014ba25e8baa96ab6cf02addfb4bdf20b8b0aab46ed66b335a9f6dfa157b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Security for chatbot-creator 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page