def queryByText(text): stub = get_grpc_stub() message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" message.deviceId = "yourdevice" response = stub.queryByText(message) #print ("resultCd: %d" % (response.resultCd)) if response.resultCd == 200: print ("\n질의한 내용: %s" % (response.uword)) #dssAction = response.action for a in response.action: response = a.mesg parsing_resp = response.replace('<![CDATA[', '') parsing_resp = parsing_resp.replace(']]>', '') print("질의에 대한 답변: " + parsing_resp + '\n') return parsing_resp else: print ("Fail: %d" % (response.resultCd)) return None
def queryByText(text): channel = grpc.secure_channel('{}:{}'.format(HOST, PORT), getCredentials()) stub = gigagenieRPC_pb2_grpc.GigagenieStub(channel) message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" message.deviceId = "yourdevice" response = stub.queryByText(message) print("\n\nresultCd: %d" % (response.resultCd)) if response.resultCd == 200: print("\n\n\n질의한 내용: %s" % (response.uword).encode('utf-8')) #dssAction = response.action for a in response.action: #print (a.mesg) response = (a.mesg).encode('utf-8') #print (a.actType) parsing_resp = response.replace('<![CDATA[', '') parsing_resp = parsing_resp.replace(']]>', '') print("\n\n질의에 대한 답변: " + parsing_resp + '\n\n\n') #return response.url else: print("Fail: %d" % (response.resultCd))
def return_answer(text): channel = grpc.secure_channel('{}:{}'.format(HOST, PORT), UA.getCredentials()) stub = gigagenieRPC_pb2_grpc.GigagenieStub(channel) message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" message.deviceId = "yourdevice" response = stub.queryByText(message) print("\n\nresultCd: %d" % (response.resultCd)) if response.resultCd == 200: print("\n\n\n질의한 내용: %s" % (response.uword)) #dssAction = response.action for a in response.action: response = a.mesg parsing_resp = response.replace('<![CDATA[', '') parsing_resp = parsing_resp.replace(']]>', '') return parsing_resp #return response.url else: print("Fail: %d" % (response.resultCd)) return None
def queryByText(text): channel = grpc.secure_channel('{}:{}'.format(HOST, PORT), getCredentials()) stub = gigagenieRPC_pb2_grpc.GigagenieStub(channel) message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" message.deviceId = "CC-2F-71-AD-99-A4" response = stub.queryByText(message) print('================================') print(response) print('================================') print ("resultCd: %d" % (response.resultCd)) if response.resultCd == 200: print ("uword: %s" % (response.uword)) #dssAction = response.action for a in response.action: print (a.mesg) print (a.actType) #return response.url else: print ("Fail: %d" % (response.resultCd))
def queryByText(text): message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" message.deviceId = "yourdevice" response = query.queryByText(message) print ("\n\nresultCd: {}".format(response.resultCd)) if response.resultCd == 200: print ("\n\n\n질의한 내용: {}".format(response.uword)) answer = response.action[0].mesg parsedAnswer = answer.replace('<![CDATA[', '').replace(']]>', '') print("\n\n질의에 대한 답변: {} \n\n\n".format(parsedAnswer)) else: print ("Fail: {}".format(response.resultCd))
def query_by_text(text): stub = get_grpc_stub() message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = "1234" # 단말기의 관리를 위해 넣어놓는 변수들 message.deviceId = "yourdevice" # 현재는 쓰이지 않으나 추후 사용 예정 response = stub.queryByText(message) print("\n\nresultCd: %d" % (response.resultCd)) if response.resultCd == 200: print("\n\n\n질의한 내용: %s" % (response.uword)) for action in response.action: query_response = action.mesg query_response = query_response.replace('<![CDATA[', '').replace(']]>', '') return query_response else: return None
def queryByText(text, usersession='0000', deviceid='r-pi'): stub = grpc_conn() message = gigagenieRPC_pb2.reqQueryText() message.queryText = text message.userSession = usersession message.deviceId = deviceid response = stub.queryByText(message) mesg = '' if response.resultCd == 200: print("uword: %s" % (response.uword)) for a in response.action: print(a.mesg) print(a.actType) mesg = a.mesg return mesg else: print("Fail: %d" % (response.resultCd)) return None