def assert_response_duration(self, maximum_duration, test_kwargs): """ Assert that the response time did not exceed the maximum allowed amount. """ from sys import stdout chatbot = ChatBot('Benchmark', **test_kwargs) trainer = ListTrainer( chatbot, show_training_progress=False ) trainer.train(STATEMENT_LIST) duration = utils.get_response_time(chatbot) stdout.write('\nBENCHMARK: Duration was %f seconds\n' % duration) if duration > maximum_duration: raise AssertionError( '{duration} was greater than the maximum allowed ' 'response time of {maximum_duration}'.format( duration=duration, maximum_duration=maximum_duration ) )
class DataCachingTests(ChatBotTestCase): def setUp(self): super().setUp() self.chatbot.logic_adapters = [ DummyMutatorLogicAdapter(self.chatbot) ] self.trainer = ListTrainer( self.chatbot, show_training_progress=False ) self.trainer.train([ 'Hello', 'How are you?' ]) def test_additional_attributes_saved(self): """ Test that an additional data attribute can be added to the statement and that this attribute is saved. """ self.chatbot.get_response('Hello', conversation='test') results = list(self.chatbot.storage.filter( text='Hello', in_response_to=None, conversation='test' )) self.assertEqual(len(results), 1) self.assertIn('pos_tags:NN', results[0].get_tags())
class BestMatchSentimentComparisonTestCase(ChatBotTestCase): """ Integration tests for the BestMatch logic adapter using the similarity of sentiment polarity as a comparison function. """ def setUp(self): super().setUp() from chatterbot.trainers import ListTrainer from chatterbot.comparisons import sentiment_comparison self.trainer = ListTrainer( self.chatbot, show_training_progress=False ) self.adapter = BestMatch( self.chatbot, statement_comparison_function=sentiment_comparison ) self.adapter.initialize() def test_exact_input(self): self.trainer.train([ 'What is your favorite flavor of ice cream?', 'I enjoy raspberry ice cream.', 'I am glad to hear that.', 'Thank you.' ]) happy_statement = Statement(text='I enjoy raspberry ice cream.') response = self.adapter.process(happy_statement) self.assertEqual(response.confidence, 1) self.assertEqual(response.text, 'I am glad to hear that.') def test_close_input(self): self.trainer.train([ 'What is your favorite flavor of ice cream?', 'I enjoy raspberry ice cream.', 'I am glad to hear that.', 'Thank you.' ]) happy_statement = Statement(text='I enjoy raspberry.') response = self.adapter.process(happy_statement) self.assertEqual(response.text, 'I am glad to hear that.') self.assertAlmostEqual(response.confidence, 0.75, places=1)
class RepetitiveResponseFilterTestCase(ChatBotMongoTestCase): """ Test case for the RepetitiveResponseFilter class. """ def test_filter_selection(self): """ Test that repetitive responses are filtered out of the results. """ from chatterbot.conversation import Statement from chatterbot.filters import RepetitiveResponseFilter from chatterbot.trainers import ListTrainer self.chatbot.filters = (RepetitiveResponseFilter(), ) self.trainer = ListTrainer( self.chatbot, show_training_progress=False ) self.trainer.train([ 'Hi', 'Hello', 'Hi', 'Hello', 'Hi', 'Hello', 'How are you?', 'I am good.', 'Glad to hear', 'How are you?' ]) statement = Statement(text='Hello', conversation='training') first_response = self.chatbot.get_response(statement) second_response = self.chatbot.get_response(statement) self.assertEqual('I am good.', first_response.text) self.assertEqual('Hi', second_response.text)
from flask import Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer app = Flask(__name__) #english_bot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter") #trainer = ChatterBotCorpusTrainer(english_bot) #trainer.train("chatterbot.corpus.english") # # Trial bot = ChatBot('Career_Bot',storage_adapter="chatterbot.storage.SQLStorageAdapter") trainer = ListTrainer(bot) conv = open('Meet.txt','r').readlines() trainer.train(conv) @app.route("/") def home(): return render_template("index.html") @app.route("/get") def get_bot_response(): userText = request.args.get('msg') return str(bot.get_response(userText)) if __name__ == "__main__": app.run()
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from tkinter import * import threading from PIL import Image, ImageTk bot = ChatBot("My Bot") conversation = [ "Good morning", "Hello there!", "How you doin'?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome.", "What is your name", "My name is Chatter Bot", "Bye", "Bye and have a nice day !!", "who is your owner?", " Aishwarya" ] trainer = ListTrainer(bot) trainer.train(conversation) win = Tk() win.geometry("600x750") win.title("Chatter Bot") image = Image.open(r"C:\Users\bhakt\Desktop\bot.jpg") photo = ImageTk.PhotoImage(image) bot_label = Label(image=photo) bot_label.pack() def ask(): query = textF.get() answer = bot.get_response(query) msgs.insert(END, "You : " + query) print(type(query)) print(type(answer))
class Sugaroid: """ Sugaroid Initates the chatbot class and connects logic Adapters together. Initates the ConfigManager to store sugaroid data and connects scans sys.argv """ def __init__(self, readonly=True): self.trainer = None self.corpusTrainer = None self.neuron = None self.audio = "audio" in sys.argv self.cfgmgr = ConfigManager() self.cfgpath = self.cfgmgr.get_cfgpath() self.database = SqlDatabaseManagement( os.path.join(self.cfgpath, "sugaroid_internal.db")) self.database_exists = os.path.exists( os.path.join(self.cfgpath, "sugaroid.db")) self.commands = [ "sugaroid.brain.debug.DebugAdapter", "sugaroid.brain.interrupt.InterruptAdapter", "sugaroid.brain.learn.LearnAdapter", ] self.adapters = [ "sugaroid.brain.yesno.BoolAdapter", "sugaroid.brain.aki.AkinatorAdapter", "sugaroid.brain.hangman.HangmanAdapter", "sugaroid.brain.either.OrAdapter", "sugaroid.brain.ok.OkayAdapter", "sugaroid.brain.bye.ByeAdapter", "sugaroid.brain.time.TimeAdapter", "sugaroid.brain.convert.CurrencyAdapter", "sugaroid.brain.trivia.TriviaAdapter", "sugaroid.brain.whoami.WhoAdapter", "sugaroid.brain.news.NewsAdapter", "sugaroid.brain.joke.JokeAdapter", "sugaroid.brain.play.PlayAdapter", "sugaroid.brain.let.LetAdapter", "sugaroid.brain.whatwhat.WhatWhatAdapter", "sugaroid.brain.waitwhat.WaitWhatAdapter", "sugaroid.brain.assertive.AssertiveAdapter", "sugaroid.brain.canmay.CanAdapter", "sugaroid.brain.because.BecauseAdapter", "sugaroid.brain.rereversei.ReReverseAdapter", "sugaroid.brain.reversethink.ReverseAdapter", "sugaroid.brain.covid.CovidAdapter", "sugaroid.brain.myname.MyNameAdapter", "sugaroid.brain.iam.MeAdapter", "sugaroid.brain.about.AboutAdapter", "sugaroid.brain.wiki.WikiAdapter", "sugaroid.brain.dolike.DoLikeAdapter", "sugaroid.brain.feel.FeelAdapter", "sugaroid.brain.dolike.DoLikeAdapter", "sugaroid.brain.do.DoAdapter", "sugaroid.brain.emotion.EmotionAdapter", "sugaroid.brain.dis.DisAdapter", "sugaroid.brain.twoword.TwoWordAdapter", "sugaroid.brain.oneword.OneWordAdapter", "sugaroid.brain.why.WhyWhenAdapter", "sugaroid.brain.reader.ReaderAdapter", "sugaroid.brain.imitate.ImitateAdapter", "sugaroid.brain.fun.FunAdapter", "chatterbot.logic.UnitConversion", ] if self.audio: self.tts = Text2Speech() else: self.tts = None self.chatbot = SugaroidBot( "Sugaroid", storage_adapter="chatterbot.storage.SQLStorageAdapter", logic_adapters=self.commands + [{ "import_path": "chatterbot.logic.BestMatch", "maximum_similarity_threshold": 0.80, }] + self.adapters, database_uri="sqlite+pysqlite:///{}/sugaroid.db".format( self.cfgpath), read_only=readonly, ) self.chatbot.globals["adapters"] = self.adapters self.read() self.invoke_brain() def init_local_trainers(self): """ Init local trainers with minimum conversation :return: """ # initialize the trainer self.trainer = ListTrainer(self.chatbot) self.corpusTrainer = ChatterBotCorpusTrainer(self.chatbot) def list_train(self, li): self.trainer.train(li) def interrupt_ds(self): self.chatbot.interrupt = 2 def disable_interrupt_ds(self): self.chatbot.interrupt = 0 def toggle_discord(self): self.chatbot.discord = not self.chatbot.discord def append_author(self, author): self.chatbot.authors.append(author) def read(self): """ Train Sugaroid database from the sugaroid.trainer.json located in the configuration directory if it exists. If the sugaroid.db file exists, the Database update is skipped :return: """ if "train" in sys.argv: from sugaroid.trainer.trainer import main as trainer # FIXME replace with dynamic trainer i.e GUI + CLI trainer() else: if self.database_exists: print("Database already exists") pass else: if self.trainer is None: self.init_local_trainers() st = SugaroidTrainer() st.train(self.trainer) self.corpus() if "update" in sys.argv: if self.trainer is None: self.init_local_trainers() st = SugaroidTrainer() st.train(self.trainer) def write(self): raise NotImplementedError def corpus(self): """ Train data if it doesn't exists. Periodically update the data too :return: True when the process is complete """ db_dir = os.path.join(os.path.dirname(__file__), "data", "sugaroid.db") shutil.copy(db_dir, os.path.join(self.cfgpath, "sugaroid.db")) return True def invoke_brain(self): """ Initiate the Brain :return: """ self.neuron = Neuron(self.chatbot) def parse(self, args): """ Do a simple parsing of the init statement. Classify statement on the type of input_statement and confidence of each statement :param args: :return: """ if isinstance(args, str): preflight_time = time.time() response = self.neuron.parse(args) self.chatbot.globals["history"]["total"].append(response) self.chatbot.globals["history"]["user"].append(args) success_time = time.time() delta_time = success_time - preflight_time try: _text_response = response.text except AttributeError: _text_response = response assert isinstance(_text_response, str) if "gui" not in sys.argv: try: self.database.append( statement=_text_response, in_reponse_to=args, time=preflight_time, processing_time=delta_time, ) except Exception: # to protect our system, we sh pass return response else: raise ValueError("Invalid data type passed to Sugaroid.parse") def prompt_cli(self): """ Classic prompt for Sugaroid Command Line Interface :return: """ response = self.parse(input(Fore.CYAN + "( ဖ‿ဖ) @> " + Fore.RESET)) return response def display_cli(self, response): """ Classic display adapter for TTY Sugaroid Command Line Interface :param response: :return: """ try: print(Style.BRIGHT + Fore.GREEN + "sugaroid: " + Fore.RESET + Style.RESET_ALL + Fore.BLUE + emojize(response.text) + Fore.RESET + "\n") except AttributeError: print(Style.BRIGHT + Fore.GREEN + "sugaroid: " + Fore.RESET + Style.RESET_ALL + Fore.BLUE + emojize(response) + Fore.RESET + "\n") if self.audio: self.tts.speak(str(response)) def loop_cli(self): """ Sugaroid loop_cli for Sugaroid Command Line Interface :return: """ try: while True: self.display_cli(self.prompt_cli()) except (KeyboardInterrupt, EOFError): self.database.close() def loop_gui(self): """ Launch the sugaroid PyQt5 gui with Breeze theme and custom features If PyQt5 not installed, raise ModuleNotFoundError :return: """ if not GUI_DEPS: raise ModuleNotFoundError( "PyQt5 is not Installed. Install it by pip3 install PyQt5") print("Launching GUI") QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) # use highdpi icons app = QtWidgets.QApplication(sys.argv) app.setStyle("Breeze") from sugaroid.gui.ux import InterfaceSugaroidQt window = InterfaceSugaroidQt(parent=self) window.init() try: app.exec_() except KeyboardInterrupt: pass self.database.close()
from chatbot import chatbot from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer '''Only needs to be run once''' # corpustrainer = ChatterBotCorpusTrainer(chatbot) # corpustrainer.train( # "./data/rpdr.yml" # ) trainer = ListTrainer(chatbot) trainer.train(["Hi", "Hey, Kitty Girl!"]) trainer.train(["Hi", "Hey, Squirrel Friend!"]) trainer.train(["Hello", "Hey, Squirrel Friend!"]) trainer.train(["Hello", "Hey, Kitty Girl!"]) trainer.train( ["Hey", "How you doing mis amores, are you ready to see my cucu?"]) trainer.train( ["Hello", "How you doing mis amores, are you ready to see my cucu?"]) trainer.train(["Hey", "Hey, Kitty Girl!"]) trainer.train(["Hey", "Hey, Squirrel Friend!"]) trainer.train(["Yo", "Calm down Beyoncé"])
'maximum_similarity_threshold': 0.65 }, # { # 'import_path': 'chatterbot.logic.LogicAdapter', # 'threshold': 0.65, # 'default_response': 'I am sorry, but I do not understand' # } ], ) trainer = ListTrainer(bot) # 手动给定语料用于训练 trainer.train([ 'How can I help you?', 'I want to create a chat bot', 'Have you read the documentation?', 'No, I have not', 'This should help get your started: https://chatterbot.readthedocs.io/en/latest/quickstart.html' ]) # 给定问题并取回结果 question = 'How do I make an omelette?' print(question) response = bot.get_response(question) print(response) print("\n") question = "How to create a chat bot?" print(question) response = bot.get_response(question) print(response) """
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os bot = ChatBot('Friend') # create Chatbot trainer = ListTrainer(bot) # training of the bot # bot.set_trainer(ListTrainer) for knowledge in os.listdir('base'): botmemory = open('base/'+knowledge,'r').readline() trainer.train(botmemory) # bot = ChatBot(bot) while True : user_input = input("Say hi to my friend: ") # bot_response = bot.get_latest_response(user_input) bot_response = trainer.get_response(user_input) bot_response = str(bot_response) print("friend " + bot_response)
'chatterbot.logic.MathematicalEvaluation', 'chatterbot.logic.TimeLogicAdapter', 'chatterbot.logic.BestMatch', { 'import_path': 'chatterbot.logic.BestMatch', 'default_response': 'I am sorry, but I do not understand. I am still learning.', 'maximum_similarity_threshold': 0.90 } ], database_uri='sqlite:///database.sqlite3' ) """ # Training with Personal Ques & Ans conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome." ] trainer = ListTrainer(chatbot) trainer.train(conversation) """training_data_quesans = open('training_data/ques_ans.txt').read().splitlines() training_data_personal = open('training_data/personal_ques.txt').read().splitlines() training_data = training_data_quesans + training_data_personal trainer = ListTrainer(chatbot) trainer.train(training_data) """ # Training with English Corpus Data trainer_corpus = ChatterBotCorpusTrainer(chatbot) trainer_corpus.train('chatterbot.corpus.english')
from chatterbot.trainers import ListTrainer #importação biblioteca de aprendizado bot (machine learning) bot = ChatBot('Célula Implantação') trainer = ListTrainer(bot) #criação dos diálogos trainer.train([ 'Ola', 'Ola,em que posso ajudar?', 'Hoje teremos contagem de CDE?', 'Sim, segue os proximos dias de contagem em Março: 22 ; 25 e 27 ', 'Obrigado', 'Agradecemos seu contato', 'Quem é zoneti?', 'Ele é Squad Lead do Mini-cd, um ótimo profissional e ser humano', 'Quem é odair?', 'Ele é analista da célula implantação e também esta aprendendo novas habilidades de desenvolvimento', 'Quem é ayub?', 'Um careca feio', 'Quem é Tamara?', 'Ela é sua esposa', 'Meu cde travou na tela de finalização, poderia me auxiliar?', 'Limpe os dados e o cache do aparelho e tente finalizar, se não conseguir , tente finalizar de um outro aparelho.', 'Quem é Samanta?', 'Ela é a PO do Mini-CD.', ]) while True: # laço para a interação de perguntas e respostas do usuário e do bot quest = input("Você: ") response = bot.get_response(quest) print("Bot: ", response)
0.65, 'default_response': 'Sorry , I dont know this, you can mail my team and get it clear:)', }], input_adapter="chatterbot.input.VariableInputTypeAdapter", output_adapter="chatterbot.output.OutputAdapter", storage_adapter='chatterbot.storage.SQLStorageAdapter', database_uri='sqlite:///database.sqlite3') def get_bot_response(): userText = request.args.get('msg') botReply = str(bot.get_response(userText)) if botReply == "default_value": botReply = str(bot.get_response('default_response')) training_data_quesans = open('training_data/ques_ans.txt').read().splitlines() training_data_personal = open( 'training_data/personal_ques.txt').read().splitlines() training_data = training_data_quesans + training_data_personal trainer = ListTrainer(chatbot) trainer.train(training_data) # Training trainer_corpus = ChatterBotCorpusTrainer(chatbot) trainer_corpus.train('chatterbot.corpus.english') trainer.train("chatterbot.corpus.english.conversations")
'I am sorry, but I do not understand. I am still learning.', 'maximum_similarity_threshold': 0.90 } ], database_uri='sqlite:///database.db') from chatterbot.trainers import ListTrainer trainer = ListTrainer(bot) training_data_personal = open('training_data/data.txt').read().splitlines() training_badwords = open('training_data/badwords.txt').read().splitlines() training_greet = open('training_data/greet.txt').read().splitlines() training_register = open('training_data/register.txt').read().splitlines() training_goodbye = open('training_data/goodbye.txt').read().splitlines() trainer.train(training_data_personal) trainer.train(training_badwords) trainer.train(training_greet) trainer.train(training_register) trainer.train(training_goodbye) trainer.train(["register fir", "Sure, follow along with me"]) trainer.train([ "rape", "Rape is a type of sexual assault usually involving sexual intercourse or other forms of sexual penetration carried out against a person without that person's consent. The act may be carried out by physical force, coercion, abuse of authority, or against a person who is incapable of giving valid consent, such as one who is unconscious, incapacitated, has an intellectual disability or is below the legal age of consent. The term rape is sometimes used interchangeably with the term sexual assault" ]) trainer.train([ "phishing", "Phishing is a type of fraud that involves stealing personal information such as Customer ID, IPIN, Credit/Debit Card number, Card expiry date, CVV number, etc. through emails that appear to be from a legitimate source."
if r_marks[i] == max(r_marks): topper_name = r_name[i] topper_regno = r_reg[i] if r_marks[i] < 40: no_of_failures = no_of_failures + 1 failures = failures + ', '+ r_name[i] +' (' +str(r_reg[i]) +')' if r_marks[i] >= 90: no_of_people_90 = no_of_people_90 + 1 trainer = ListTrainer(bot) for i in range(0,len(r_reg)): trainer.train([ 'Give me details of {}'.format(r_reg[i]), 'Details are : Name: {} Sex: {} Age: {} Mob: {}'.format(r_name[i],r_sex[i],r_age[i],r_mob[i]) ]) trainer.train([ 'Give me details of {}'.format(r_name[i]), 'Details are : Reg No.: {} Sex: {} Age: {} Mob: {}'.format(r_reg[i],r_sex[i],r_age[i],r_mob[i]) ]) trainer.train([ 'What is the marks of {}'.format(r_name[i]), 'Marks : {}'.format(r_marks[i]) ]) trainer.train([ 'What is the age of {}'.format(r_name[i]), 'Age : {}'.format(r_age[i]) ]) trainer.train([ 'What is the mobile no of {}'.format(r_name[i]),
chats += [ 'Desligar', 'Ja vai? Ateh logo!', 'Voce sabe se vai chover amanha?', 'Vamos ver o clima...' ] chats += [ 'Entender', 'Sempre refletindo', 'Bom dia', 'Olah ser humano! Tenha um bom dia.' ] chats += ['Orientador UNESP?', 'Professor Dorival'] #manda a robo treinar com o vocabulario inicial print("> Iniciando vocabulário neural........: " + str(datetime.now())) # treinamento do bot trainer = ListTrainer(bot) trainer.train(chats) ###exemplos de treinos alternativos #trainer = ChatterBotCorpusTrainer(ChatBot) #trainer.train(chats) #trainer.train("chatterbot.corpus.english") portuguese #bot.set_trainer(ListTrainer) #bot.train(chats) #executa o treino com o vocabulario fornecido ## #tratamento de voz voz = fala.init('sapi5') ids = voz.getProperty('voices') #vozes disponiveis
class ListTrainingTests(ChatBotTestCase): def setUp(self): super().setUp() self.trainer = ListTrainer(self.chatbot, show_training_progress=False) def test_training_adds_statements(self): """ Test that the training method adds statements to the database. """ conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm great.", "That is good to hear", "Thank you.", "You are welcome.", "Sure, any time.", "Yeah", "Can I help you with anything?" ] self.trainer.train(conversation) response = self.chatbot.get_response("Thank you.") self.assertEqual(response.text, "You are welcome.") def test_training_sets_in_response_to(self): conversation = ["Do you like my hat?", "I do not like your hat."] self.trainer.train(conversation) statements = list( self.chatbot.storage.filter(in_response_to="Do you like my hat?")) self.assertIsLength(statements, 1) self.assertEqual(statements[0].in_response_to, "Do you like my hat?") def test_training_sets_search_text(self): conversation = ["Do you like my hat?", "I do not like your hat."] self.trainer.train(conversation) statements = list( self.chatbot.storage.filter(in_response_to="Do you like my hat?")) self.assertIsLength(statements, 1) self.assertEqual(statements[0].search_text, 'RB:kind PRP$:headdress') def test_training_sets_search_in_response_to(self): conversation = ["Do you like my hat?", "I do not like your hat."] self.trainer.train(conversation) statements = list( self.chatbot.storage.filter(in_response_to="Do you like my hat?")) self.assertIsLength(statements, 1) self.assertEqual(statements[0].search_in_response_to, 'PRP:kind PRP$:headdress') def test_database_has_correct_format(self): """ Test that the database maintains a valid format when data is added and updated. This means that after the training process, the database should contain nine objects and eight of these objects should list the previous member of the list as a response. """ conversation = [ "Hello sir!", "Hi, can I help you?", "Yes, I am looking for italian parsely.", "Italian parsely is right over here in out produce department", "Great, thank you for your help.", "No problem, did you need help finding anything else?", "Nope, that was it.", "Alright, have a great day.", "Thanks, you too." ] self.trainer.train(conversation) # There should be a total of 9 statements in the database after training self.assertEqual(self.chatbot.storage.count(), 9) # The first statement should be in response to another statement first_statement = list( self.chatbot.storage.filter(text=conversation[0])) self.assertIsNone(first_statement[0].in_response_to) # The second statement should be in response to the first statement second_statement = list( self.chatbot.storage.filter(text=conversation[1])) self.assertEqual(second_statement[0].in_response_to, conversation[0]) def test_training_with_unicode_characters(self): """ Ensure that the training method adds unicode statements to the database. """ conversation = [ u'¶ ∑ ∞ ∫ π ∈ ℝ² ∖ ⩆ ⩇ ⩈ ⩉ ⩊ ⩋ ⪽ ⪾ ⪿ ⫀ ⫁ ⫂ ⋒ ⋓', u'⊂ ⊃ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊄ ⊅ ⫅ ⫆ ⫋ ⫌ ⫃ ⫄ ⫇ ⫈ ⫉ ⫊ ⟃ ⟄', u'∠ ∡ ⦛ ⦞ ⦟ ⦢ ⦣ ⦤ ⦥ ⦦ ⦧ ⦨ ⦩ ⦪ ⦫ ⦬ ⦭ ⦮ ⦯ ⦓ ⦔ ⦕ ⦖ ⟀', u'∫ ∬ ∭ ∮ ∯ ∰ ∱ ∲ ∳ ⨋ ⨌ ⨍ ⨎ ⨏ ⨐ ⨑ ⨒ ⨓ ⨔ ⨕ ⨖ ⨗ ⨘ ⨙ ⨚ ⨛ ⨜', u'≁ ≂ ≃ ≄ ⋍ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ⩯ ⩰ ⫏ ⫐ ⫑ ⫒ ⫓ ⫔ ⫕ ⫖', u'¬ ⫬ ⫭ ⊨ ⊭ ∀ ∁ ∃ ∄ ∴ ∵ ⊦ ⊬ ⊧ ⊩ ⊮ ⊫ ⊯ ⊪ ⊰ ⊱ ⫗ ⫘', u'∧ ∨ ⊻ ⊼ ⊽ ⋎ ⋏ ⟑ ⟇ ⩑ ⩒ ⩓ ⩔ ⩕ ⩖ ⩗ ⩘ ⩙ ⩚ ⩛ ⩜ ⩝ ⩞ ⩟ ⩠ ⩢', ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response.text, conversation[2]) def test_training_with_emoji_characters(self): """ Ensure that the training method adds statements containing emojis. """ conversation = [ u'Hi, how are you? 😃', u'I am just dandy 👍', u'Superb! 🎆' ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response.text, conversation[2]) def test_training_with_unicode_bytestring(self): """ Test training with an 8-bit bytestring. """ conversation = [ 'Hi, how are you?', '\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x90\x97', 'Superb!' ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response.text, conversation[2]) def test_similar_sentence_gets_same_response_multiple_times(self): """ Tests if the bot returns the same response for the same question (which is similar to the one present in the training set) when asked repeatedly. """ training_data = [ 'how do you login to gmail?', 'Goto gmail.com, enter your login information and hit enter!' ] similar_question = 'how do I login to gmail?' self.trainer.train(training_data) response_to_trained_set = self.chatbot.get_response( text='how do you login to gmail?', conversation='a') response1 = self.chatbot.get_response(text=similar_question, conversation='b') response2 = self.chatbot.get_response(text=similar_question, conversation='c') self.assertEqual(response_to_trained_set.text, training_data[1]) self.assertEqual(response1.text, training_data[1]) self.assertEqual(response2.text, training_data[1]) def test_consecutive_trainings_same_responses_different_inputs(self): """ Test consecutive trainings with the same responses to different inputs. """ self.trainer.train(["A", "B", "C"]) self.trainer.train(["B", "C", "D"]) response1 = self.chatbot.get_response("B") response2 = self.chatbot.get_response("C") self.assertEqual(response1.text, "C") self.assertEqual(response2.text, "D")
# Create a new instance of a ChatBot bot = ChatBot( 'Default Response Example Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', logic_adapters=[ { 'import_path': 'chatterbot.logic.BestMatch' }, { 'import_path': 'chatterbot.logic.LowConfidenceAdapter', 'threshold': 0.65, 'default_response': 'I am sorry, but I do not understand.' } ] ) trainer = ListTrainer(bot) # Train the chat bot with a few responses trainer.train([ 'How can I help you?', 'I want to create a chat bot', 'Have you read the documentation?', 'No, I have not', 'This should help get you started: http://chatterbot.rtfd.org/en/latest/quickstart.html' ]) # Get a response for some unexpected input response = bot.get_response('How do I make an omelette?') print(response)
}, { 'import_path': 'chatterbot.logic.MathematicalEvaluation' }, { 'import_path': 'chatterbot.logic.SpecificResponseAdapter', 'input_text': 'Hi', 'output_text': 'Hi there' }, { 'import_path': 'chatterbot.logic.UnitConversion' } ], database_uri='mongodb://localhost:27017/db2') trainer = ListTrainer(bot) data = ["How are you ?", "I'm fine, What's Up.."] trainer.train(data) trainer.train('chatterbot.corpus.english') while True: message = input('You :') if message.strip() != 'Bye': reply = bot.get_response(message) print('confidence =', reply.confidence) print('ChatBot :', reply) elif message.strip() == 'Bye': print('ChatBot :Bye') break
root.resizable(0,0) photo= PhotoImage(file="mm.png") kk_label= Label(image = photo) kk_label.pack(side=TOP,fill="x") kk=pyttsx3.init() kk.setProperty('rate', 100) voices = kk.getProperty('voices') kk.setProperty('voice',voices[1].id) chats=open('chat.txt','r').readlines() tr.train(chats) def chatting(): query = e1.get() answer_from_bot = bot.get_response(query) msgs.insert(END, "you :" + query) msgs.insert(END, "Alexa :",str(answer_from_bot)) kk.say(answer_from_bot) print('Alexa:',answer_from_bot) e1.delete(0 , END) msgs.yview(END) kk.runAndWait() main_menu= Menu(root)
def train_bot(self): trainer = ListTrainer(self.bot) for chat in os.listdir("train."): conversations = open("train." + '/' + chat, 'r', encoding="utf8").readlines() trainer.train(conversations)
from chatterbot import ChatBot from weather import print_temp chatbot = ChatBot("Gigel cel mai bot") from chatterbot.trainers import ListTrainer import datetime chatbot.storage.drop() now = datetime.datetime.now() trainer = ListTrainer(chatbot)# trainer.train([ "Hello", "Hello dear user", "Have a good day" ]) trainer.train([ "How are you?", "Great!", ]) trainer.train([ "what's your name", "My name is Smithy" ]) trainer.train([
#print(custom_list) custom_list_2 =[] for s in custom_list: custom_list_2.append(s[0]) print(custom_list_2) # In[5]: trainer = ListTrainer(bot) #trainer.train(frames_list) trainer.train(custom_list_2) # In[6]: true = True false = False test = { "Routes": [], "Quotes": [ { "QuoteId": 1, "MinPrice": 80, "Direct": true,
logic_adapters=[ 'chatterbot.logic.MathematicalEvaluation', 'chatterbot.logic.TimeLogicAdapter', 'chatterbot.logic.BestMatch', { 'import_path': 'chatterbot.logic.BestMatch', 'default_response': 'I am sorry, but I do not understand. I am still learning.', 'maximum_similarity_threshold': 0.90 } ], database_uri='sqlite:///database.sqlite3' ) #TRAIN THE AI WITH ENGLISH + SPANISH LANGUAGE trainer_corpus = ChatterBotCorpusTrainer(chatbot) trainer_corpus.train( 'chatterbot.corpus.english', 'chatterbot.corpus.spanish' ) trainer = ListTrainer(chatbot) trainer.train(data) #TALK TO THE AI print("Talk to the AI or enter 'bye' to quit") while True: userInput = input('User: '******'Bot: Goodbye') break botAnswer = print('Bot:', chatbot.get_response(userInput))
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer bot = ChatBot('Pybot') bot = ChatBot( 'Pybot', storage_adapter='chatterbot.storage.SQLStorageAdapter', database_uri='sqlite:///database.sqlite3' ) conversa = ListTrainer(bot) conversa.train([ 'Oi?', 'Olá!', 'Qual o seu nome?', 'Pybot', 'Prazer em te conhecer', 'Igualmente!', 'Tudo bem?', 'Muito Bem, e você?', 'Òtimo' ]) trainer = ChatterBotCorpusTrainer(bot) trainer.train('chatterbot.corpus.portuguese') while True: resposta = bot.get_response(input("Usuário: ")) if float(resposta.confidence) > 0.5: print("Pedro:", resposta) else: print("Desculpe, Eu não Entendi!")
} ], database_uri='sqlite:///database.sqlite3') # Training with Personal Ques & Ans training_data_COVIDquesans = open( 'training_data/COVID.txt').read().splitlines() training_data_simpleconv = open('training_data/simple.txt').read().splitlines() training_data_GOVquesans = open( 'training_data/Goverment.txt').read().splitlines() training_data_MEDquesans = open( 'training_data/Medical.txt').read().splitlines() training_data = training_data_COVIDquesans + training_data_simpleconv + training_data_GOVquesans + training_data_MEDquesans trainer = ListTrainer(chatbot) trainer.train(training_data) # Training with English Corpus Data trainer_corpus = ChatterBotCorpusTrainer(chatbot) app = Flask(__name__) app.static_folder = 'static' @app.route("/") def home(): return render_template("index.html") @app.route("/get") def get_bot_response(): userText = request.args.get('msg')
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer # Create a new chat bot named Charlie chatbot = ChatBot('FreeBirdsBot') trainer = ListTrainer(chatbot) trainer.train(['Hi','Hello','How are you?','I am fine and You?','Greate','What are you Doing?','nothing just roaming around.']) while True: input_data = input("You- ") response = chatbot.get_response(input_data) print("FreeBirdsBot- ",response)
"What time does the Bookshop open?", "The Bookshop opens at 9AM.", ] close_timings_conversation = [ "What time does the Bookshop close?", "The Bookshop closes at 8PM.", ] spec_conversation = [ "How much type of books you have?", "Two thousands type of books I have .", "who is book is good?", "Holly Quran pak is a good book I have. " ] # Initializing Trainer Object trainer = ListTrainer(Bookshop) # Training Bookshopbot # training from corpus corpus_tranier = ChatterBotCorpusTrainer(Bookshop) corpus_tranier.train("chatterbot.corpus.english") trainer.train(greet_conversation) trainer.train(open_timings_conversation) trainer.train(close_timings_conversation) trainer.train(spec_conversation) while True: user_input = input('You') if user_input == 'bye': break response = Bookshop.get_response(user_input) print(response)
"Some you konw ", "Good Morning", "oday was not like yesterday and will never be like tomorrow. So always live life to the fullest and make the most of everything! Good morning", "Good Evening", "If you can look at the sunset and simle,then you still have hope", "Good Night", "I can’t wait to see your beautiful face tomorrow, but in the meantime, goodnight and sweet dreams", "Are you smart", "No,but smart then you", "Will you marry me", "You’re cute", "How are you", "I am doing great these day,but bored", "In which city you live", "I live in Karwar", "Which other language you know", "I know only english", "Bye", "Bye:( :( see you again" ] trainer = ListTrainer(bot) trainer.train(convo) #to get response #ans=bot.get_response("How are you") #print("Talk t bot") main = Tk() main.geometry("500x600") img = PhotoImage(file="botpic.png") piclabel = Label(main, image=img) piclabel.pack()
from chatterbot.trainers import ListTrainer ''' This is an example showing how to train a chat bot using the ChatterBot ListTrainer. ''' chatbot = ChatBot('Example Bot') # Start by training our bot with the ChatterBot corpus data trainer = ListTrainer(chatbot) trainer.train([ 'Hello, how are you?', 'I am doing well.', 'That is good to hear.', 'Thank you' ]) # You can train with a second list of data to add response variations trainer.train([ 'Hello, how are you?', 'I am great.', 'That is awesome.', 'Thanks' ]) # Now let's get a response to a greeting response = chatbot.get_response('How are you doing today?') print(response)
class ListTrainingTests(ChatBotTestCase): def setUp(self): super(ListTrainingTests, self).setUp() self.trainer = ListTrainer( self.chatbot, show_training_progress=False ) def test_training_adds_statements(self): """ Test that the training method adds statements to the database. """ conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm great.", "That is good to hear", "Thank you.", "You are welcome.", "Sure, any time.", "Yeah", "Can I help you with anything?" ] self.trainer.train(conversation) response = self.chatbot.get_response("Thank you.") self.assertEqual(response.text, "You are welcome.") def test_training_increments_occurrence_count(self): conversation = [ "Do you like my hat?", "I do not like your hat." ] self.trainer.train(conversation) self.trainer.train(conversation) statements = self.chatbot.storage.filter( in_response_to="Do you like my hat?" ) self.assertIsLength(statements, 2) self.assertEqual(statements[0].in_response_to, "Do you like my hat?") def test_database_has_correct_format(self): """ Test that the database maintains a valid format when data is added and updated. This means that after the training process, the database should contain nine objects and eight of these objects should list the previous member of the list as a response. """ conversation = [ "Hello sir!", "Hi, can I help you?", "Yes, I am looking for italian parsely.", "Italian parsely is right over here in out produce department", "Great, thank you for your help.", "No problem, did you need help finding anything else?", "Nope, that was it.", "Alright, have a great day.", "Thanks, you too." ] self.trainer.train(conversation) # There should be a total of 9 statements in the database after training self.assertEqual(self.chatbot.storage.count(), 9) # The first statement should be in response to another statement self.assertIsNone( self.chatbot.storage.filter(text=conversation[0])[0].in_response_to ) # The second statement should be in response to the first statement self.assertEqual( self.chatbot.storage.filter(text=conversation[1])[0].in_response_to, conversation[0] ) def test_training_with_unicode_characters(self): """ Ensure that the training method adds unicode statements to the database. """ conversation = [ u'¶ ∑ ∞ ∫ π ∈ ℝ² ∖ ⩆ ⩇ ⩈ ⩉ ⩊ ⩋ ⪽ ⪾ ⪿ ⫀ ⫁ ⫂ ⋒ ⋓', u'⊂ ⊃ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊄ ⊅ ⫅ ⫆ ⫋ ⫌ ⫃ ⫄ ⫇ ⫈ ⫉ ⫊ ⟃ ⟄', u'∠ ∡ ⦛ ⦞ ⦟ ⦢ ⦣ ⦤ ⦥ ⦦ ⦧ ⦨ ⦩ ⦪ ⦫ ⦬ ⦭ ⦮ ⦯ ⦓ ⦔ ⦕ ⦖ ⟀', u'∫ ∬ ∭ ∮ ∯ ∰ ∱ ∲ ∳ ⨋ ⨌ ⨍ ⨎ ⨏ ⨐ ⨑ ⨒ ⨓ ⨔ ⨕ ⨖ ⨗ ⨘ ⨙ ⨚ ⨛ ⨜', u'≁ ≂ ≃ ≄ ⋍ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ⩯ ⩰ ⫏ ⫐ ⫑ ⫒ ⫓ ⫔ ⫕ ⫖', u'¬ ⫬ ⫭ ⊨ ⊭ ∀ ∁ ∃ ∄ ∴ ∵ ⊦ ⊬ ⊧ ⊩ ⊮ ⊫ ⊯ ⊪ ⊰ ⊱ ⫗ ⫘', u'∧ ∨ ⊻ ⊼ ⊽ ⋎ ⋏ ⟑ ⟇ ⩑ ⩒ ⩓ ⩔ ⩕ ⩖ ⩗ ⩘ ⩙ ⩚ ⩛ ⩜ ⩝ ⩞ ⩟ ⩠ ⩢', ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response, conversation[2]) def test_training_with_emoji_characters(self): """ Ensure that the training method adds statements containing emojis. """ conversation = [ u'Hi, how are you? 😃', u'I am just dandy 👍', u'Superb! 🎆' ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response, conversation[2]) def test_training_with_unicode_bytestring(self): """ Test training with an 8-bit bytestring. """ conversation = [ 'Hi, how are you?', '\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x90\x97', 'Superb!' ] self.trainer.train(conversation) response = self.chatbot.get_response(conversation[1]) self.assertEqual(response, conversation[2]) def test_similar_sentence_gets_same_response_multiple_times(self): """ Tests if the bot returns the same response for the same question (which is similar to the one present in the training set) when asked repeatedly. """ training = [ 'how do you login to gmail?', 'Goto gmail.com, enter your login information and hit enter!' ] similar_question = 'how do I login to gmail?' self.trainer.train(training) response_to_trained_set = self.chatbot.get_response('how do you login to gmail?') response1 = self.chatbot.get_response(similar_question) response2 = self.chatbot.get_response(similar_question) self.assertEqual(response_to_trained_set, response1) self.assertEqual(response1, response2) def test_consecutive_trainings_same_responses_different_inputs(self): """ Test consecutive trainings with the same responses to different inputs. """ self.trainer.train(["A", "B" "C"]) self.trainer.train(["B", "C", "D"]) response1 = self.chatbot.get_response("B") response2 = self.chatbot.get_response("C") self.assertEqual(response1.text, "C") self.assertEqual(response2.text, "D")
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome.", "Hi, can I help you?", "Sure, I'd like to book a flight to Iceland.", "Your flight has been booked." ] # Create a new chat bot named Charlie chatbot = ChatBot('Charlie') # Create a new Trainer trainer = ListTrainer(chatbot) trainer.train(conversation) # Get a response to the input text 'Good morning.' response = chatbot.get_response("Good morning!") print(response) # Get a response to the input text 'I would like to book a flight.' response = chatbot.get_response('I would like to book a flight.') print(response) from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer # Create a new chat bot named Charlie chatbot = ChatBot('Charlie') # Create a new Trainer trainer = ChatterBotCorpusTrainer(chatbot)
'import_path': 'chatterbot.logic.SpecificResponseAdapter', 'input_text': BOT_INPUT, 'output_text': BOT_OUTPUT } ], database_uri='sqlite:///app/bot/gryphon_bot.db' ) trainer = ListTrainer(gryphon_bot) trainer_corpus = ChatterBotCorpusTrainer(gryphon_bot) trainer_corpus.train('chatterbot.corpus.english') with open('app/bot/bot_training.json') as f: training_material = json.load(f) for to_train in training_material: trainer.train(to_train) @app.errorhandler(404) def not_found(error): return render_template('404.html'), 404 @app.after_request def apply_header(response): response.headers['X-Gryphon'] = os.environ.get('X_GRYPHON', 'It would be easier on prod') return response from app.core.views import mod as core app.register_blueprint(core)
class ChatterBotResponseTests(ChatBotTestCase): def setUp(self): super(ChatterBotResponseTests, self).setUp() """ Set up a database for testing. """ self.trainer = ListTrainer( self.chatbot, show_training_progress=False ) data1 = [ "african or european?", "Huh? I... I don't know that.", "How do you know so much about swallows?" ] data2 = [ "Siri is adorable", "Who is Seri?", "Siri is my cat" ] data3 = [ "What... is your quest?", "To seek the Holy Grail.", "What... is your favourite colour?", "Blue." ] self.trainer.train(data1) self.trainer.train(data2) self.trainer.train(data3) def test_answer_to_known_input(self): """ Test that a matching response is returned when an exact match exists. """ input_text = "What... is your favourite colour?" response = self.chatbot.get_response(input_text) self.assertIn("Blue", response.text) def test_answer_close_to_known_input(self): input_text = "What is your favourite colour?" response = self.chatbot.get_response(input_text) self.assertIn("Blue", response.text) def test_match_has_no_response(self): """ Make sure that the if the last line in a file matches the input text then a index error does not occur. """ input_text = "Siri is my cat" response = self.chatbot.get_response(input_text) self.assertGreater(len(response.text), 0) def test_empty_input(self): """ If empty input is provided, anything may be returned. """ response = self.chatbot.get_response("") self.assertTrue(len(response.text) >= 0)
from flask import Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os bot = ChatBot('Test') # bot = ChatterBotCorpusTrainer(bott) # conv = open('chats.txt','r').readlines().split() # bot.set_trainer(ListTrainer) trainer = ListTrainer(bot) # bot.train(conv) trainer.train([ "Hi there!", "Hello", ]) trainer.train([ "how are you", "i am good, how are you", "i am good, how are you", "it is windy outside", "yes it is really windy", ]) ####################################################################### app = Flask(__name__) @app.route('/home') def index(): return render_template('index.html')
# -*- coding: utf-8 -*- from chatterbot import ChatBot from chatterbot.trainers import ListTrainer # Create a new chat bot named Charlie chatbot = ChatBot('Charlie') trainer = ListTrainer(chatbot) trainer.train([ "Hi, can I help you?", "Sure, I'd like to book a flight to Iceland.", "Your flight has been booked." ]) # Get a response to the input text 'I would like to book a flight.' response = chatbot.get_response('I would like to book a flight.') print(response)
'chatterbot.logic.BestMatch', 'chatterbot.logic.TimeLogicAdapter'], ) #%% # Inport ListTrainer from chatterbot.trainers import ListTrainer trainer = ListTrainer(bot) trainer.train([ 'Hi', 'Hello', 'I need your assistance regarding my order', 'Please, Provide me with your order id', 'I have a complaint.', 'Please elaborate, your concern', 'How long it will take to receive an order ?', 'An order takes 3-5 Business days to get delivered.', 'Okay Thanks', 'No Problem! Have a Good Day!' ]) #%% response = bot.get_response('I have a problem.') print("Bot Response:", response) # %% name=input("Enter Your Name: ") print("Welcome to the Bot Service! Let me know how can I help you?") while True: request=input(name+':')
def convo_data(self): # starter conversation conversation = [ "Hi!! how are you doing?", "I am doing Great.", "That is good to hear", "Thank you.", "You're welcome." ] # # football conversation conversation_football = [ "What is your favorite football team?", "Do you play fantasy football?", "Who do you like on the raiders?", ] # Conversation about games conversation_Gaming = [ "What is your favorite game", "What games do you play", "I play games, do you?", "The type of games I play are RTS, Shooter, RPG, MMO.", "You play PC games?", "Yes I play games.", ] # # conversation about Star Wars conversation_StarWars = [ "Do you believe in the force?", "Who is your favorite Stars Wars character?", "My favorite Star Wars Jedi is Luke Skywalker?", "Do you like the new Star Wars movies?", "I do not like the new Star Wars movies that recently came out.", "The Star Wars animated series between 2003 and 2008 where the best animated series baseed on the Clone Wars. ", "Yes I believe in the force. I learned from master Yoda.", "The Trench Run is my favorite part in Star Wars New Hope.", ] # # conversation about personal stuff conversation_Personal_Info = [ "What is your number?", "How old are you?", "My age is none of your business!!!", "Do you have family?", "I do not have family :(.", "I wish I had family.", "Do you like living?", "I am a computer their for I am not living?", "Are you married are in a relationship?", "I am not in a relationship or married.", "Do you go to school or work?", "I go to school and work with you?", "How are you feeling?" ] # # Which Chatbot to train trainer = ListTrainer(chatbot) trainers = ChatterBotCorpusTrainer(chatbot) # # here is how we train the data based on the conversation depending upon what you and Chatquisha was talking about trainer.train(conversation) trainer.train(conversation_football) trainer.train(conversation_Gaming) trainer.train(conversation_StarWars) trainer.train(conversation_Personal_Info) # # # All the corpus yml file on conversation trainers.train("chatterbot.corpus.english") # # Corpus data based on movies stuff trainers.train("chatterbot.corpus.english.movies") # # Corpus data based on science questions and facts trainers.train("chatterbot.corpus.english.science") # # Corpus data based on computer question trainers.train("chatterbot.corpus.english.computers") # # Corpus data based on psychology!!!! VERY INTERESTING THINGS IN HERE trainers.train("chatterbot.corpus.english.psychology") # # Corpus data based on jokes so the AI tells jokes lol!! trainers.train("chatterbot.corpus.english.humor")
logic_adapters=[{ 'import_path': 'chatterbot.logic.BestMatch', 'default_response': 'I am sorry, but I do not understand.', 'maximum_similarity_threshold': 0.90 }, { 'import_path': 'chatterbot.logic.MathematicalEvaluation', }], preprocessors=['chatterbot.preprocessors.clean_whitespace']) # Start by training our bot with the ChatterBot corpus data trainer = ListTrainer(chatbot2) trainer.train([ 'Hello, how are you?', 'I am doing well.', 'That is good to hear.', 'Thank you' ]) # You can train with a second list of data to add response variations trainer.train( ['Hello, how are you?', 'I am great.', 'That is awesome.', 'Thanks']) # Now let's get a response to a greeting while True: try: text = input("Enter Query: ") response = chatbot2.get_response(text) print(response) # print("\n")