def nlu(each): url = "https://nlu.sit.aimidea.cn:22012/nlu/v1" data = {"currentUtterance": "这款空调有什么特色", "sourceDevice": "空调", "multiDialog": "false", "slotMiss": "false", "suites": ["default"], "deviceId": "3141482994683870", "userGroup": "meiju", "userGroupCredential": "b82063f4-d39b-4940-91c3-5b67d741b4d3"} data["currentUtterance"] = each result = Request().requests(url, data, 'post') result = result.json() classifier = result['classifier'] if classifier != "publicDomain": print(each + ":"+classifier) with open(result_path, 'a', encoding='utf8') as f: f.write(each+":"+str(result)+'\n') # f.close() else: print(each + ":"+classifier)
def nlu(utterance): url = "https://nlu.sit.aimidea.cn:22012/nlu/v1" # data=dict() data = { "currentUtterance": "请马上关机", "sourceDevice": "空调", "multiDialog": "true", "slotMiss": "true", "suite": ["default"], "deviceId": "4311026980750221", "userGroup": "meiju", "userGroupCredential": "b82063f4-d39b-4940-91c3-5b67d741b4d3", "customDeviceNames": "", "customRoomNames": "" } data["currentUtterance"] = utterance result = Request().requests(url, data, 'post') nlu_result = result.json() return nlu_result
def OnlyInterface(**data): url = data['url'] type = data['type'] header = data['header'] testdata = data['参数'] check = data['校验'] if isinstance(testdata, dict): pass else: try: testdata = eval(testdata) except Exception as e: Logger().error(e) testdata = {} up_data = data['继承参数'] if up_data == '': up_data = {} else: try: up_data = eval(up_data) except Exception as e: Logger().error(e) up_data = {} parameter = data['调用参数'] downdata = data['下传参数'] if header == '': header = {} else: try: header = eval(header) except Exception as e: Logger().error(e) header = {} if parameter == '': testdata = testdata else: try: parameter = eval(parameter) except Exception as e: Logger().error(e) # parameter = '' else: for each in parameter: testdata[each] = up_data[each] respone = Request().requests(url, testdata, type, headers=header) respone = respone.json() try: if check != '': check = eval(check) for each in check.keys(): assert respone[each] == check[each], "接口【%s】响应校验失败" % url else: Logger().info("跳过接口响应校验,测试继续") except Exception as e: Logger().error(e) else: if downdata != '': try: downdata = eval(downdata) except Exception as e: # downdata={} Logger().error(e) else: for key in downdata.keys(): down_value = downdata[key].split("=>") s = respone for i in range(0, len(down_value)): s = s[down_value[i]] i += 1 downdata[key] = s up_data.update(downdata) result0 = [respone, up_data] return result0