Package: baker-python
BakerBot-MakerBaker! Is a framework to create chatbots with Python in the easiest and simplest route, train your chatbot by texting or adding data in XML, JSON or YAML files.InstallationYou can install Baker with pippipinstallbaker-pythonUsageInitial TasksUsing Baker is very easy, all you have to do is to create a YAML, JSON or XML file first. However, files should have been defined in a specific format:For XML files<responses><Hello><response>Hello!</response><response>Hithere!</response></Hello></responses>TheHellotag is defining that if the user will writeHelloto the chatbot the chatbot will return one of the responses in theresponsetag.For JSON files{"Hello":["Hi","Heyy","Hello"]}Same goes with JSON files. Even if the response is only one, it must be in a list []. Here, if user inputsHellothen the response must be random in the list.For YAML filesHello:-Hello!-Hi there!How are you:-I am fine-I am doing good, thanks for askingSame process is with the YAML files with a bit different syntax and nothing else.The files can also be empty for example a JSON file can be like this:{}TrainingTo train the chatbot, use theTrainerclass. Here is an example of basic training:frombakerimporttrainerbot=trainer.Trainer('database.yaml')user_input=input("You: ")response=bot.get_response(user_input)print("Bot:",response)# Train the bot with a new responsenew_response=input("New response: ")bot.train_response(user_input,new_response)print("Bot has been trained with the new response!")from this route the keyword (user's question) must be already created in the file or else the trainer will not be able to train because the trainer will not find the keyword in the file. For example if you want to train the chatbot for responses ofHellothenHelloshould be created in the data file.But with this way to train you can train the chatbot as long you want to with custom keywords (no need to define them in the data file) and their infinite responses:trainer=Trainer("database.json")trainer.loop_training()'''The data file can either be empty or it can have keywords, pre-defined keyowrds can be trained too.ParsingTo parse the chatbot to run and test it use theParserclass:frombakerimportparserdeftest_chatbot(bot):whileTrue:user_input=input("You: ")ifuser_input.lower()=="exit":print("Testing session ended.")breakresponse=bot.get_response(user_input)print("Bot:",response)bot=parser.Parser('database.json')test_chatbot(bot)The above code will run the chatbot, but there is anther simpler way to run the chatbot with it's specified name which is to use theChatbotclass:frombakerimporttrainerfrombakerimportparserfrombakerimportchatbottrainer=trainer.Trainer('database.json')parser=parser.Parser('database.json')my_chatbot=chatbot.Chatbot("MyChatbot")my_chatbot.interactive_session(trainer,parser)Parserclass has more functions regarding the data file:Exporting responses :response_file_name="responses.json"Parser=Parser(response_file_name)parser.export_responses("exported_responses.xml")Reset resposesparser.reset_responses("A_User_Question")Removing responses:user_input="What is the weather like?"response_to_remove="I'm not sure."parser.remove_response(user_input,response_to_remove)List questions:key_questions=parser.list_questions()print("List of Key Questions:")forquestioninkey_questions:print(question)Count responses:user_input="Tell me a joke"response_count=parser.count_responses(user_input)print(f"Number of Responses for '{user_input}':{response_count}")Keep training your chatbot by texting or adding words in the database and then run it!