'''chat agent view''' from network import Handler, poll, periodic_poll, Client, get_my_ip import sys from threading import Thread from time import sleep import asyncore #replace host with ip address #192.168.1.105 host, port = get_my_ip(), 8888 client = Client(host, port) thread = Thread(target=asyncore.loop) thread.daemon = True # die when the main thread dies thread.start() client.do_send({'speak': 'agent', 'txt': 'Chat agent has connected'}) client.do_send({'Info': 'Model'}) while 1: mytxt = sys.stdin.readline().rstrip() client.do_send({'speak': 'agent', 'txt': mytxt})
# elif myoptions == '2': # myoptions = 'Question' # elif myoptions == '3': # myoptions ='Other' # else: # myoptions = 'no' # print 'Invalid input, try again' # # #while (myoptions != '1' or myoptions != '2' or myoptions != '3'): # # myoptions = raw_input('What brings you here?(choose a number) 1. Complaint, 2. Question, 3. Other ') # # print myoptions # # # topic = raw_input('What is your topic regarding this prompt?') client = Client(host, port) client.do_send({'Conversation Type': 'Type'}) client.do_send({'Topic': 'Test'}) ######################################### #print 'Connecting you with an agent' thread = Thread(target=asyncore.loop) thread.daemon = True # die when the main thread dies thread.start() while 1: mytxt = sys.stdin.readline().rstrip() #customer console options if mytxt == ':q': print client client.on_close()