![]() 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. ![]() You can use the queries in the text file to train the model again. 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. 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" ''' print ( response ) # this will run the model run ( input_variable = inp ) ''' specify the input variable through which you will parse in the input values. 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. '''Īfter you have created the pickle data files and the model using the above code, you can remove that. createModel () '''This will create a neural network model and save it with the name that you gave in the first step. createData ( "data.json" ) # The data file that you created. from ChatbotCreator import ChatbotCreator main = ChatbotCreator ( "model.hdf5" ) # Model file name to save main. To create a simple chatbot, first you need to create the pickle data files Creating the model. : 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. Here "class" is the label, "patterns" are the questions for the label and "responses" are the responses or answer for the label. pip install chatbot-creatorįirst you need to create a json data file and save it as "data.json" in the current directory for creating the machine learning model.Įxample: Use the package manager pip to install ChatbotCreator. ChatbotCreator is a python package for creating chatbots(Including discord bots).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |