Example #1
0
def evaluate_users_requests(list_users_requests: list,
                            users_dict: dict) -> None:
    for user, request in list_users_requests:
        if user in users_dict:
            # print(f'User Request: {request}\n')
            # evaluate request
            response = chatbot.main(request)
            send_message(user, 'Response', response,
                         users_dict[user]['carrier'])
def add_numbers():
    """Add two numbers server side, ridiculous but well..."""
    #a = request.args.get('a', 0, type=str)#input from html

    a = request.args.get('a')
    print(a)
    result = chatbot.main(a)
    print("Result: ", result)
    #input from html
    returned = a
    #return jsonify(returned);
    return jsonify(''.join(result))
Example #3
0
        elif "I am also good" in query or "I am also fine" in query:
            print("Jarvis:That's great to hear from you")
            speak("That's great to hear from you")

        elif "what language do you speak" in query:
            print("Jarvis:I use to speak Python quite a bit")
            speak("I use to speak Python quite a bit")

        elif "what can you do for me" in query:
            print("Jarvis:I can do works which are behind your expectations.")
            speak("I can do works which are behind your expectations.")

        elif "lets chat" in query or "can we chat" in query or 'can we talk' in query:
            speak("Why not sir.")
            chatbot.main()

        elif "I am sad" in query or "I am tired" in query:
            speak("Oh!, Should I play music to make you happy?")
            jk = takeCommand()
            if 'yes' in jk or 'yeah sure' in jk:
                speak('Ok Sir')
                tk = random.randint(0, 14)
                print(tk)

                music_dir = 'C:\\Users\\Pratibha\\Music'
                song = os.listdir(music_dir)
                print(song)

                os.startfile(os.path.join(music_dir, song[tk]))
            else:
Example #4
0
import random
import tkinter as tk
from chatbot import main, chatbot
root = tk.Tk()
root.title("RNN chatbot")
root.geometry('650x400')
user_input = tk.Entry(root)
user_input.pack()

net, sess, chars, vocab, n, beam_width, relevance, temperature, topn = main()

greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!', 'hey']
question = [
    'How are you?', 'How are you doing?', 'what is your name?',
    'can you help me?'
]
responses = [
    'Okay', "I'm fine", 'My name is Chatbot', 'sure!, I am happy to help you'
]


def cb(event):
    user_text = user_input.get()
    if user_text in greetings:
        bot_text = random.choice(greetings)
    elif user_text in question:
        bot_text = responses[question.index(user_text)]
    else:
        bot_text = chatbot(net, sess, chars, vocab, n, beam_width, relevance,
                           temperature, topn, user_text)
    output.config(text=bot_text + '\n')