Esempio n. 1
0
def chatBot():
    msg = request.json['message']
    rply = str(chatbot.get_response(msg))
    response = app.response_class(response=json.dumps(rply),
                                  status=200,
                                  mimetype='application/json')
    return response
    def generate_responses(self):
        while True:
            text = self.stt_to_chatbot_queue.get()
            print("Generate Response:", text)
            response = str(chatbot.get_response(text))

            self.chatbot_to_tts_queue.put(response)
Esempio n. 3
0
def get_bot_response():
    userText = request.args.get('msg')
    p = ["The", "current", "time"]
    s = str(chatbot.get_response(userText))
    k = s.split()
    if k[:3] == p:
        return 'I am sorry, but I do not understand. I am still learning.'
    else:
        return s
Esempio n. 4
0
def get_bot_response():
    user_text = request.args.get('msg')
    if ('status' in user_text) or ('Covid status'
                                   in user_text) or ('Coronavirus status'
                                                     in user_text):
        bot = Coronavirus()
        return bot.get_data()
    else:
        return str(chatbot.get_response(user_text))
Esempio n. 5
0
def get_bot_response():
    userText = request.args.get('msg')
    if userText != 'exit':
        trainer_dict.append(userText)
        reply_text = str(chatbot.get_response(userText))
        trainer_dict.append(reply_text)
        return reply_text
    else:
        writeFile()
        return "Goodbye"
        os.exit(0)
Esempio n. 6
0
def get_bot_response():
    #name = input("Enter Your name")
    #print('Welcome to WIWEB', name, 'Let me know how can i help you ?')
    userText = (request.args.get('msg'))
    # while True:
    # userText = input(name + ':')
    #    if userText == 'Bye' or userText == 'bye':
    #       chatbot.get_response(userText)
    #  break

    #userText = (request.args.get('msg'))
    return str(chatbot.get_response(userText))
Esempio n. 7
0
def get_bot_response():
    global flag
    global user_id
    global name
    global street
    global place
    global current_time
    global status
    global phone
    global veg_list

    global myresult
    global connection
    global cur

    check_order_status()

    userText = request.args.get('msg').lower()
    user_input = userText.split()

    for i in range(0, len(user_input)):

        if user_input[i] == 'order':
            return user_details()

        if user_input[i] == 'status':
            flag = 'status'
            return str("Enter order id:")

        if user_input[i] == 'veg':
            return veg_list_category()

        if user_input[i] == 'non' or user_input[i] == 'non-veg' or user_input[
                i] == 'nonveg':
            return non_veg_list_category()

    if flag == '':
        return "Im still learning to communicate"

    if flag == 'details':
        return split_user_details(userText)

    if flag == 'veg':
        return veg_after_ordering(flag, user_input)

    if flag == 'nonveg':
        return veg_after_ordering(flag, user_input)

    if flag == 'status':
        return order_status_by_user(user_input)

    return str(chatbot.get_response(userText))
Esempio n. 8
0
    "I'm doing well, how are you?",
    "I'm bored",
    "Music might be a remedy to that!",
    "I'm really bored",
    "We can talk then",
    "What should we talk about?",
    "What do you wanna talk about?",
    "I want to know about Thyrocare?",
    "Thyrocare Technologies Limited is a chain of diagnostic and preventive care laboratories, based in Navi Mumbai."
    ])
trainer.train([
    "I am feeling down",
    "Why?",
    "I feel lonely",
    "You can talk to me anytime you feel lonely",
    "Thank you.",
    "You're welcome, I'm here to be your friend"
    ])
#for entry in entries:
#    chat=open('converse/'+entry,'r').readlines()
#    trainer.train(chat)
              
while True:
    userInput=input("Me:")
    if userInput.strip()=="Bye" or userInput=="bye":
        print("Bot:Bye!")
        break
    else:
        print(chatbot.get_response(userInput))
        
Esempio n. 9
0
def get_chatbot_response(question: str):
    response = get_response(question)
    return {"response": response}
Esempio n. 10
0
File: app.py Progetto: Amal-124/test
def get_bot_response():
    userText = request.args.get('msg')  #requests from html
    return str(chatbot.get_response(
        userText))  #getting respose if user enters text  and returning answer
Esempio n. 11
0
def get_bot_response():
    if request.method == 'GET':
        userText = request.args.get('msg')
        response = str(chatbot.get_response(userText))
        print(response)
        return response
Esempio n. 12
0
def send(request):
    username = request.session['username']
    path = os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
        'usersofchatbot')
    res = process_request(request)

    #initializing a json file for new user
    if os.path.isfile(path + '/{}.json'.format(username)) == 0:
        with open(path + '/{}.json'.format(username), mode='w') as f:
            f.write(
                json.dumps({
                    "username": username,
                    "Messages": []
                }, indent=2))
        f.close

    if request.method == "POST":
        request.session['last_activity'] = str(datetime.now())
        name = request.session['username']
        message = request.POST['message']

        #using the chatbot to store data in json file
        ints = predict_class(message.lower())
        path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'chatbot')
        intents = json.loads(open(path + '/intents.json').read())

        path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'usersofchatbot')
        with open(path + '/{}.json'.format(username)) as feedsjson:
            feeds = json.load(feedsjson)

        feeds["Messages"].append({
            "Name":
            name,
            "Message":
            message,
            "Type":
            'client',
            "DateTime":
            datetime.now().strftime("%H:%M:%S ") + "         |         " +
            date.today().strftime("%B %d, %Y")
        })
        feeds["Messages"].append({
            "Name": "Chatbot",
            "Message": get_response(ints, intents),
            "Type": 'myside',
            "DateTime": str(datetime.now())
        })

        with open(path + '/{}.json'.format(username), mode='w') as f:
            f.write(json.dumps(feeds, indent=2))

    #reading data for template
    with open(path + '/{}.json'.format(username)) as feedjson:
        feeds = json.load(feedjson)

    if res != 0:
        return render(request, 'client.html', feeds)
    else:
        return redirect('/')
Esempio n. 13
0
def get_bot_response():
    userText = request.args.get('msg')
    return str(cb.get_response(userText))
    """try:
Esempio n. 14
0
def get_bot_response(msg):

    return str(chatbot.get_response(msg))
Esempio n. 15
0
def get_bot_response():
    user_text = request.args.get('msg')
    return str(chatbot.get_response(user_text.lower()))
Esempio n. 16
0
def brain(u_input):
    response = chatbot.get_response(u_input)
    return response
Esempio n. 17
0
def get_bot_response():
    userText = request.args.get('msg')
    return str(chatbot.get_response(userText))
Esempio n. 18
0
def get_bot_response():
    userText = request.args.get('msg')
    input_statement = Statement(userText)
    response = chatbot.get_response(input_statement)
    # generatedResponse = chatbot.generate_response(input_statement)
    return str(response)