예제 #1
0
def input_process(id):

    while True:
        if states[id]:
            time.sleep(2)
        else:
            in_dict = reply_dict[id]
            in_seq = input_str[id]
            print(time.asctime() + ' 线程' + str(id) + '正在处理消息')
            output = rnn.predict(in_seq)
            data = {"group_id": in_dict['group_id'],
                    "message": "[CQ:at,qq=" + str(in_dict['sender']['user_id']) + "] " + output}
            requests.post(url, data=data)
            states[id] = 1
예제 #2
0
mode = '0'
while True:
    print("-----------------")
    print("模式1:搭建模型")
    print("模式2:训练模型")
    print('模式3:开启Coolq接口')
    print("模式4:进行对话")
    print("-----------------")
    mode = input('输入工作模式:')
    if mode == '1':
        rnn.pre_precess()
        rnn.setup_model()
    elif mode == '2':
        epo = input('输入循环轮数:')
        bat = input('输入batch size:')
        rnn.train_model(bat, epo)
    elif mode == '3':
        t0 = threading.Thread(target=input_process, args=(0,), name='http_receive0')
        t0.start()
        http_receive()
    elif mode == '4':
        print('输入数字0 退出')
        while True:
            str_in = input('你说:')
            if str_in == '0':
                break
            print(rnn.predict(str_in))

    else:
        print('输入有误')