def chat():

    # variables used in response should be held here but can't be quickly changed
    sentence = request.get_data().decode('utf-8')
    answer = chatbot.response(sentence)
    
    #if answer is None:
    #    return 'Did not get an answer.
    return answer
def addchatbot_image():
    global i
    image = Label(window, image=chatbot_image)
    if i < 350:
        image.place(x=15, y=i)
        res = chatbot.response(input_box.get("1.0", END))
        bot_text = Label(window,
                         anchor=W,
                         text=res,
                         wraplength=270,
                         justify=LEFT)
        bot_text.place(x=75, y=i + 21)
    i += 60
示例#3
0
文件: app.py 项目: Sofianel5/chatbot
def response():
    input = request.args.get("q")
    return chatbot.response(input)
示例#4
0
文件: app.py 项目: rojour/chatbot
def get_bot_response():
    userText = request.args.get('msg')
    return str(response(userText))
示例#5
0
shuffle = False
retriever = rr.raw_retriever(saved_checkpoint, tf_responses_file, rnn_dim,
                             raw_responses_file, get_response, encoder,
                             retrieve_batch_size, drop_remainder, shuffle,
                             use_gpu)

#准备bert
bert_config_file = 'bert/pretrained/chinese_L-12_H-768_A-12/bert_config.json'
bert_init_checkpoint = 'bert/ckpts/dnf/o1/model.ckpt-41093'
bert_max_seq_length = 256
bert_vocab_file = 'bert/pretrained/chinese_L-12_H-768_A-12/vocab.txt'
num_labels = 2
bf = BERTfunc.BERTFunction(bert_config_file, bert_init_checkpoint,
                           bert_max_seq_length, bert_vocab_file, num_labels,
                           use_gpu)
judge = chatbot.BERTJudge(bf)

default_num_of_candidates = 100
chatbot = chatbot.BERT_chatbot(retriever, default_num_of_candidates, judge)

whatYouSay = ""

while (True):
    whatYouSay = input("say something:")
    if whatYouSay == "goodbye!":
        break
    elif whatYouSay == "forget it!":
        chatbot.forget()
        continue
    print("A:" + str(chatbot.response(whatYouSay, 100)))