# coding:utf-8 import grpc from a2s.a2s_client import a2s_execute # from proto import service_pb2, service_pb2_grpc from proto.text2vector_pb2 import Text2VectorReq, Text2VectorResp def start(data: str): # 本次不使用SSL,所以channel是不安全的 result = [] try: # 调用服务端方法 resp = Text2VectorReq(text=data) response=a2s_execute("192.168.3.240:9090","t2v2",timeout=60,bytes_data=resp.SerializeToString()) # 获取结果 req = Text2VectorResp() req.ParseFromString(response) result = list(req.vector) except Exception as e: print(e) return result if __name__ == '__main__': r = start("公共厕所服务") print(len(r)) print(r) # http://172.17.145.164:19805,http://172.17.148.50:19805,http://172.17.4.184:19805