itam-assistant 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,8 @@ from lark_oapi.api.aily.v1 import *
9
9
  # 以下示例代码默认根据文档示例值填充,如果存在代码问题,请在 API 调试台填上相关必要参数后再复制代码使用
10
10
  # 复制该 Demo 后, 需要将 "YOUR_APP_ID", "YOUR_APP_SECRET" 替换为自己应用的 APP_ID, APP_SECRET.
11
11
 
12
+ pre =['spring_f17d05d924__c']
13
+
12
14
 
13
15
  class AilyLarkClient():
14
16
  def __init__(self,clientinfo):
it_assistant/do_ai.py CHANGED
@@ -81,15 +81,18 @@ def do_ai_auto(Testk_data, clientinfo):
81
81
  startAt = int(time.time())
82
82
  # 创建会话
83
83
  seseion_id = AilyLarkClient(clientinfo).create_ailysession(tenant_access_token)
84
+ time.sleep(10)
84
85
  if not seseion_id:
85
86
  raise ValueError("未能成功创建会话")
86
87
  # 创建消息
87
88
  message_id = AilyLarkClient(clientinfo).create_ailysessionaily_message(tenant_access_token, seseion_id,
88
89
  aa)
90
+ time.sleep(5)
89
91
  if not message_id:
90
92
  raise ValueError("未能成功创建消息")
91
93
  # 创建运行实例
92
94
  runs = AilyLarkClient(clientinfo).create_ailysession_run(tenant_access_token, seseion_id)
95
+ time.sleep(5)
93
96
  num = num + 1
94
97
  return startAt, num
95
98
  except KeyError as ke:
@@ -137,22 +140,15 @@ def do_waterlevellineres_list(res, info):
137
140
  info['rt'] = False
138
141
  return info
139
142
 
140
-
141
143
  # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
142
144
  if res["body"]["Results"]:
145
+ info['output']['用户输入/output']='log_id:'+res['log_id']
143
146
  # 取["Results"]下前2个结果,若只有1个结果,label1为空
144
- if len(res["body"]["Results"]) > 1:
145
- info['label'] = [
146
- {'label': res["body"]["Results"][0]['Item']['name_zh'],
147
- 'score': res["body"]["Results"][0]['Score']},
148
- {'label': res["body"]["Results"][1]['Item']['name_zh'],
149
- 'score': res["body"]["Results"][1]['Score']}]
150
-
151
- else:
152
- info['label'] = [
153
- {'label': res["body"]["Results"][0]['Item']['name_zh'],
154
- 'score': res["body"]["Results"][0]['Score']},
155
- {'label': '', 'score': 0}]
147
+ if len(res["body"]["Results"]) > 0:
148
+ for j in range(len(res["body"]["Results"])):
149
+ aaa = {'label': res["body"]["Results"][j]['Item']['name_zh']+"&"+res["body"]["Results"][j]['Item']['brand_zh']+"&"+res["body"]["Results"][j]['Item']['model_zh']+"&"+res["body"]["Results"][j]['Item']['specification_zh'],
150
+ 'score': res["body"]["Results"][j]['Score']}
151
+ info['label'].append(copy.deepcopy(aaa))
156
152
  # 判断label0和label1是否为空,为空则:label默认2级
157
153
  # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
158
154
  if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][1]['label'] == info['label'][1][
@@ -168,6 +164,38 @@ def do_waterlevellineres_list(res, info):
168
164
 
169
165
  return info
170
166
 
167
+ def do_waterlevellineres_listv2(res, info):
168
+ """
169
+ 获取结果,并组装水位线info
170
+ """
171
+ if res == '':
172
+ info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
173
+ info['rt'] = False
174
+ return info
175
+ reslist = res["body"]["Results"]
176
+ info['output']['用户输入/output'] = 'log_id:' + res.get('log_id') or res.get('requestId')
177
+ if reslist:
178
+ #取所有结果并追加到info['label']
179
+ info['label'] = []
180
+ if len(reslist) > 0:
181
+ for j in range(len(reslist)):
182
+ aaa = {'label': reslist[j]['Item']['name_zh'],
183
+ 'score': reslist[j]['Score'],
184
+ 'info':reslist[j]['Item']['name_zh']+"&"+reslist[j]['Item']['brand_zh']+"&"+reslist[j]['Item']['model_zh']+"&"+reslist[j]['Item']['specification_zh'],}
185
+ info['label'].append(copy.deepcopy(aaa))
186
+ # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
187
+ for a in range(len(info['exp'])):
188
+ if info['exp'][a]['label']== info['label'][a]['label']:
189
+ info['rt'] = True
190
+ else:
191
+ info['rt'] = False
192
+ break
193
+ else:
194
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
195
+ info['rt'] = False
196
+
197
+ return info
198
+
171
199
  def do_waterlevellineres_listassetspu(res, info,hardtype):
172
200
  """
173
201
  获取结果,并组装水位线info
@@ -179,10 +207,11 @@ def do_waterlevellineres_listassetspu(res, info,hardtype):
179
207
  if res["data"].get("AiBorrowAndUseResponseList") == None:
180
208
  info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
181
209
  info['rt'] = False
182
- if info['exp'][0]['label']=='':
210
+ if info['exp']==[]:
183
211
  info['rt'] = True
184
212
  return info
185
213
  reslist=res["data"]["AiBorrowAndUseResponseList"]
214
+ info['output']['用户输入/output']='requestId:'+res['requestId']
186
215
  aaa ={}
187
216
  # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
188
217
  if reslist:
@@ -198,12 +227,12 @@ def do_waterlevellineres_listassetspu(res, info,hardtype):
198
227
  'score': reslist[j]['Score']}
199
228
  info['label'].append(copy.deepcopy(aaa))
200
229
  # 判断label0和label1是否为空,为空则:label默认2级
201
- # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
202
-
203
- if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][0]['score'] <= info['label'][0]['score']:
204
- info['rt'] = True
205
- else:
206
- info['rt'] = False
230
+ for a in range(len(info['exp'])):
231
+ if info['exp'][a]['label'] == info['label'][a]['label']:
232
+ info['rt'] = True
233
+ else:
234
+ info['rt'] = False
235
+ break
207
236
  else:
208
237
  info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
209
238
  info['rt'] = False
@@ -401,25 +430,60 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
401
430
  for i in collections:
402
431
  info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
403
432
  info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
404
- info['exp'] = [
405
- {'label': i['ext']['BPO标注-AP-资产型号'], 'score': score_threshold},
406
- {'label': i['ext'].get('BPO标注-AP-资产型号1', ''), 'score': score_threshold}]
433
+ info['exp'] = []
434
+ for j in [i['ext']['BPO标注-AP-资产型号'], i['ext'].get('BPO标注-AP-资产型号1'),i['ext'].get('BPO标注-AP-资产型号2'),i['ext'].get('BPO标注-AP-资产型号3'),i['ext'].get('BPO标注-AP-资产型号4'),i['ext'].get('BPO标注-AP-资产型号5'),i['ext'].get('BPO标注-AP-资产型号6'),i['ext'].get('BPO标注-AP-资产型号7'),i['ext'].get('BPO标注-AP-资产型号8'),i['ext'].get('BPO标注-AP-资产型号9'),i['ext'].get('BPO标注-AP-资产型号10')]:
435
+ if j:
436
+ info['exp'].append({'label': j, 'score': score_threshold})
437
+ #判断i['ext']['BPO标注-AP-资产型号']是否为空,为空就不用读取,不为空就读取
438
+ if i['ext']['BPO标注-AP-资产型号']:
439
+ asset_name = i['ext']['BPO标注-AP-资产名称']
440
+ try:
441
+ if isinstance(asset_name, str):
442
+ asset_name = json.loads(asset_name)
443
+ except json.JSONDecodeError:
444
+ # 若解析失败,说明不是 JSON 格式,保持原样
445
+ pass
407
446
  info['artificial'] = info['exp']
408
447
  if i['ext']['BPO标注-AP-资产名称']:
448
+ asset_name = i['ext']['BPO标注-AP-资产名称']
449
+ try:
450
+ if isinstance(asset_name, str):
451
+ asset_name = json.loads(asset_name)
452
+ except json.JSONDecodeError:
453
+ # 若解析失败,说明不是 JSON 格式,保持原样
454
+ pass
409
455
  if "软件申请" in i['ext']['BPO标注-AP-分发技能']:
410
- keywprd = software_asset_sku_structure(json.loads(i['ext']['BPO标注-AP-资产名称']))
456
+ keywprd = software_asset_sku_structure(asset_name)
411
457
  res = json.loads(get_query_vector(keywprd, clientinfo))
412
458
  if "设备/配件申请" in i['ext']['BPO标注-AP-分发技能']:
413
- keywprd = equipmentrequest_structure(json.loads(i['ext']['BPO标注-AP-资产名称']), i['ext']['asset_type'])
414
- res0 = json.loads(get_query_vector(keywprd, clientinfo))
415
- res = get_by_AssetModelBizTypes(keywprd,res0)
459
+ #keywprd = equipmentrequest_structure(asset_name, i['ext']['asset_type'])
460
+ keywprd = {
461
+ "From": 0,
462
+ "Size": 10,
463
+ "MinScore": 0.7,
464
+ "AssetModelFieldsWithAnd": [
465
+ {
466
+ "FieldName": "vec_search",
467
+ "FieldType": "knn",
468
+ "QueryValue": [
469
+ asset_name
470
+ ]
471
+ }
472
+ ],
473
+ "SPUIDs": None,
474
+ "AssetModelBizTypes": [
475
+ "asset_sku"
476
+ ]
477
+ }
478
+ res = json.loads(get_query_vector(keywprd, clientinfo))
479
+ #res = get_by_AssetModelBizTypes(keywprd,res0)
416
480
  if "设备/配件退还" in i['ext']['BPO标注-AP-分发技能']:
417
- keywprd = equipmentreturn_structure0(json.loads(i['ext']['BPO标注-AP-资产名称']), i['ext']['asset_type'])
481
+ keywprd = equipmentreturn_structure0(asset_name, i['ext']['asset_type'])
418
482
  res0 = json.loads(get_query_vector(keywprd, clientinfo))
419
483
  res = get_by_AssetModelBizTypes(keywprd, res0)
420
484
  else:
421
485
  res = ""
422
- infoout = do_waterlevellineres_list(res, info)
486
+ infoout = do_waterlevellineres_listv2(res, info)
423
487
  info_list.append(copy.deepcopy(infoout))
424
488
  a = a+1
425
489
  print("这是"+str(a))
@@ -449,9 +513,15 @@ def do_waterlevelline_autotest_aseetspu(collections, clientinfo, score_threshold
449
513
  for i in collections:
450
514
  info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
451
515
  info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
452
- info['exp'] = [
453
- {'label': i['ext']['BPO标注-AP-资产型号'], 'score': score_threshold},
454
- {'label': i['ext'].get('BPO标注-AP-资产型号1', ''), 'score': score_threshold}]
516
+ info['exp'] = []
517
+ for j in [i['ext']['BPO标注-AP-资产型号'], i['ext'].get('BPO标注-AP-资产型号1'),
518
+ i['ext'].get('BPO标注-AP-资产型号2'), i['ext'].get('BPO标注-AP-资产型号3'),
519
+ i['ext'].get('BPO标注-AP-资产型号4'), i['ext'].get('BPO标注-AP-资产型号5'),
520
+ i['ext'].get('BPO标注-AP-资产型号6'), i['ext'].get('BPO标注-AP-资产型号7'),
521
+ i['ext'].get('BPO标注-AP-资产型号8'), i['ext'].get('BPO标注-AP-资产型号9'),
522
+ i['ext'].get('BPO标注-AP-资产型号10')]:
523
+ if j:
524
+ info['exp'].append({'label': j, 'score': score_threshold})
455
525
  info['artificial'] = info['exp']
456
526
  info['label']=[]
457
527
  if i['ext']['BPO标注-AP-资产名称']:
@@ -460,14 +530,15 @@ def do_waterlevelline_autotest_aseetspu(collections, clientinfo, score_threshold
460
530
  try:
461
531
  # 尝试将其解析为 JSON 对象
462
532
  if isinstance(asset_name, str):
463
- asset_name = json.loads(asset_name)
533
+ asset_name0 = json.loads(asset_name)
534
+ asset_name = asset_name0['asset_name']
464
535
  except json.JSONDecodeError:
465
536
  # 若解析失败,说明不是 JSON 格式,保持原样
466
537
  pass
467
538
  key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
468
539
  if i['ext']['BPO标注-AP-资产类型'] == "设备":
469
540
  hardtype = 1
470
- elif i['ext']['BPO标注-AP-资产类型'] == "配件" :
541
+ elif i['ext']['BPO标注-AP-资产类型'] == "配件" or i['ext']['BPO标注-AP-资产类型'] == '2.0' :
471
542
  hardtype = 2
472
543
  res = GetBestMatchItemonline(key,hardtype,clientinfo)
473
544
  else:
@@ -51,14 +51,11 @@ class webapiClient():
51
51
  "endAt": endAt,
52
52
  "matchIntentID": "",
53
53
  "matchStatus": [],
54
- "pageSize": pageSize + 10
54
+ "pageSize": pageSize + 1000
55
55
  })
56
56
  try:
57
57
  self.conn.request("POST","/ai/api/v1/conversational_runtime/namespaces/spring_f17d05d924__c/stats/intent_detail_list",payload, self.headers)
58
58
  res = self.conn.getresponse()
59
- #url = "https://apaas.feishu.cn/ai/api/v1/conversational_runtime/namespaces/spring_f17d05d924__c/stats/intent_detail_list"
60
- #response = requests.request("POST", url, headers=self.headers, data=payload)
61
-
62
59
  # 检查响应状态码
63
60
  if res.status != 200:
64
61
  raise http.client.HTTPException(f"请求失败,状态码: {res.status}, 原因: {res.reason}")
@@ -74,8 +71,9 @@ class webapiClient():
74
71
  raise ValueError("响应数据缺少必要的字段 'data' 或 'intentDetailList'")
75
72
 
76
73
  res_list = []
77
- for i in data['data']['intentDetailList']:
78
- if i['channelType'] in ["LARK_OPEN_API", "LARK_BOT", "ANONYMOUS_CUI_SDK", "AILY_CUI_SDK"]:
74
+ data_ = data['data']['intentDetailList']
75
+ for i in data_:
76
+ if i['channelType'] in ["LARK_OPEN_API"]:
79
77
  res_list.append({
80
78
  '对话日志/intentID': i['intentID'],
81
79
  '用户输入/userInput': i['userInput'],
it_assistant/openapi.py CHANGED
@@ -54,10 +54,10 @@ def get_query_vector(para, clientinfo):
54
54
  'Authorization': clientinfo.get(
55
55
  "authorization") or "Basic cm40cmFpdTRwenY1cGlsYTo2bWhvOXV3ZXFrOHZpbDllcXRxMHZ1YmVnc2xjeXBucg==",
56
56
  'x-use-ppe': '1',
57
- 'x-tt-env': clientinfo.get("x_tt_env") or "ppe_cn_env_self_test_feat_cr_a",
57
+ 'x-tt-env': clientinfo.get("x_tt_env") or "ppe_openapi_vector_v2",
58
58
  'Content-Type': 'application/json'
59
59
  }
60
-
60
+ time.sleep(2.1)
61
61
  response = requests.request("POST", url, headers=headers, data=payload)
62
62
  return response.text
63
63
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itam-assistant
3
- Version: 0.1.3
4
- Summary: 新增线上设备型号接口--
3
+ Version: 0.1.4
4
+ Summary: 优化版本
5
5
  Home-page: https://github.com/liujunmeiD/itam_assistant
6
6
  Author: liujunmeiD
7
7
  Author-email: 1105030421@qq.com
@@ -1,11 +1,11 @@
1
1
  it_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- it_assistant/ailyapp_client.py,sha256=_6cLF80a8SrO7LCujfHe4re7xZyt6GBbDlmApgqbK6A,6326
2
+ it_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
3
3
  it_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
4
- it_assistant/do_ai.py,sha256=uW39JBda1F-qDJkqDm7Bnhe4evY6uI6DhunUXxQzsAc,38030
5
- it_assistant/intent_detail.py,sha256=0oDUagekRsFE2RToeYa25T238GBXJkhuUCAkIRvdFd8,17078
4
+ it_assistant/do_ai.py,sha256=tm4UWRxbuiGtlzSuJPzZQf6jbHtQbd2Nhs7_mXGeu8g,41487
5
+ it_assistant/intent_detail.py,sha256=hmEj1KpcuKNvsoBZmn5PnbsBIIx6XGmQBJWdW_ICFmg,16831
6
6
  it_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
7
7
  it_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
8
- it_assistant/openapi.py,sha256=YExIZ7_psr0PES0Ran-3J9mHD4k7KhjgCZwFOYCu-BY,37720
8
+ it_assistant/openapi.py,sha256=-YMx-Feu1dHkQ86EB1-QmQZJHS4dND3sNSnIpBF94w4,37730
9
9
  it_assistant/test.py,sha256=qGSihMYmtZkz_vifwEOz579f_wPBJAx5_rz1sABUyo4,581
10
10
  main/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  main/ailyapp_client.py,sha256=6CVlBkuiIvIzqG0lM38tdGFBNLhVi2_0jQIbHg7fpzw,6515
@@ -13,7 +13,7 @@ main/do_ai.py,sha256=2zmv3kGIeNGRkOYf7LrYZ_7NP7yoXoSOrfu_ZeL6RXU,6870
13
13
  main/intent_detail.py,sha256=Fo76c4BpGya-znCnKH7YAcr_2UJtbi3WPQN-PwtVsXc,18533
14
14
  main/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
15
15
  main/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
16
- itam_assistant-0.1.3.dist-info/METADATA,sha256=-kYBDAPOsZxUQnQ4SyNlWdeL0gKc4t4m-GkEDuvD22c,547
17
- itam_assistant-0.1.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
18
- itam_assistant-0.1.3.dist-info/top_level.txt,sha256=3g528EjzDs06L1brP8ZvVIvWFyS9K5b8gA6eRoRGdt0,13
19
- itam_assistant-0.1.3.dist-info/RECORD,,
16
+ itam_assistant-0.1.4.dist-info/METADATA,sha256=qzfcU2B17mHB1y1_WOYSQsnDmHeE63RLayTt6R1cJ6g,527
17
+ itam_assistant-0.1.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
18
+ itam_assistant-0.1.4.dist-info/top_level.txt,sha256=3g528EjzDs06L1brP8ZvVIvWFyS9K5b8gA6eRoRGdt0,13
19
+ itam_assistant-0.1.4.dist-info/RECORD,,