itam-assistant 0.1.1__py3-none-any.whl → 0.1.3__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.
it_assistant/do_ai.py CHANGED
@@ -67,7 +67,7 @@ def do_ai_auto(Testk_data, clientinfo):
67
67
  # 可不需等待运行实例创建完成
68
68
  # if not runs:
69
69
  # raise ValueError("未能成功创建运行实例")
70
- time.sleep(1)
70
+ time.sleep(5)
71
71
  else:
72
72
  return startAt, i
73
73
  break
@@ -168,6 +168,131 @@ def do_waterlevellineres_list(res, info):
168
168
 
169
169
  return info
170
170
 
171
+ def do_waterlevellineres_listassetspu(res, info,hardtype):
172
+ """
173
+ 获取结果,并组装水位线info
174
+ """
175
+ if res == '':
176
+ info['label'] = [{'label': '', 'score': 0}]
177
+ info['rt'] = False
178
+ return info
179
+ if res["data"].get("AiBorrowAndUseResponseList") == None:
180
+ info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
181
+ info['rt'] = False
182
+ if info['exp'][0]['label']=='':
183
+ info['rt'] = True
184
+ return info
185
+ reslist=res["data"]["AiBorrowAndUseResponseList"]
186
+ aaa ={}
187
+ # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
188
+ if reslist:
189
+ # 取["Results"]下前2个结果,若只有1个结果,label1为空
190
+ if len(reslist) > 0:
191
+ for j in range(len(reslist)):
192
+ if hardtype==2:
193
+ aaa = {'label': reslist[j]['AccessoryModelScope']['AccessoryModelInfo']['Name']['ValueZh'],
194
+ 'score': reslist[j]['Score']}
195
+ info['label'].append(copy.deepcopy(aaa))
196
+ if hardtype == 1:
197
+ aaa = {'label': reslist[j]['AssetModelScope']['SpuNameZh'] or reslist[j]['AssetModelScope']['NameZh']+reslist[j]['AssetModelScope']['ModelZh']+reslist[j]['AssetModelScope']['SpecificationZh'],
198
+ 'score': reslist[j]['Score']}
199
+ info['label'].append(copy.deepcopy(aaa))
200
+ # 判断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
207
+ else:
208
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
209
+ info['rt'] = False
210
+ return info
211
+
212
+ def do_waterlevellineres_listassetspu_pre(res, info,hardtype):
213
+ """
214
+ 获取结果,并组装水位线info
215
+ """
216
+ if res == '':
217
+ info['label'] = [{'label': '', 'score': 0}]
218
+ info['rt'] = False
219
+ return info
220
+ if res.get("body") == None:
221
+ info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
222
+ info['rt'] = False
223
+ if info['exp'][0]['label']=='':
224
+ info['rt'] = True
225
+ return info
226
+ reslist=res["body"]
227
+ aaa ={}
228
+ # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
229
+ if reslist:
230
+ # 取["Results"]下前2个结果,若只有1个结果,label1为空
231
+ if len(reslist) > 0:
232
+ for j in range(len(reslist)):
233
+ if hardtype==2:
234
+ aaa = {'label': reslist[j]['AccessoryModelScope']['AccessoryModelInfo']['Name']['ValueZh'],
235
+ 'score': reslist[j]['Score']}
236
+ info['label'].append(copy.deepcopy(aaa))
237
+ if hardtype == 1:
238
+ aaa = {'label': reslist[j]['Item']['name_zh']+reslist[j]['Item']['brand_zh']+reslist[j]['Item']['model_zh']+reslist[j]['Item']['specification_zh'],
239
+ 'score': reslist[j]['Score']}
240
+ info['label'].append(copy.deepcopy(aaa))
241
+ # 判断label0和label1是否为空,为空则:label默认2级
242
+ # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
243
+ if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][1]['label'] == info['label'][1][
244
+ 'label'] and info['exp'][0]['score'] <= info['label'][0]['score'] and info['exp'][1]['score'] <= \
245
+ info['label'][1]['score']:
246
+ info['rt'] = True
247
+ else:
248
+ info['rt'] = False
249
+ else:
250
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
251
+ info['rt'] = False
252
+ return info
253
+
254
+ def do_waterlevellineres_sr(res, info,hardtype):
255
+ """
256
+ 获取结果,并组装水位线info
257
+ """
258
+ if res == '':
259
+ info['label'] = [{'label': '', 'score': 0}]
260
+ info['rt'] = False
261
+ return info
262
+ if res["data"].get("AiBorrowAndUseResponseList") == None:
263
+ info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
264
+ info['rt'] = False
265
+ if info['exp'][0]['label']=='':
266
+ info['rt'] = True
267
+ return info
268
+ reslist=res["data"]["AssetModels"]
269
+ aaa ={}
270
+ # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
271
+ if reslist:
272
+ # 取["Results"]下前2个结果,若只有1个结果,label1为空
273
+ if len(reslist) > 0:
274
+ for j in range(len(reslist)):
275
+ if hardtype==2:
276
+ aaa = {'label': reslist[j]['AccessoryModelScope']['AccessoryModelInfo']['Name']['ValueZh'],
277
+ 'score': reslist[j]['Score']}
278
+ info['label'].append(copy.deepcopy(aaa))
279
+ if hardtype == 1:
280
+ aaa = {'label': reslist[j]['SpuNameZh'] or reslist[j]['NameZh']+reslist[j]['ModelZh']+reslist[j]['SpecificationZh'],
281
+ 'score': 0.5}
282
+ info['label'].append(copy.deepcopy(aaa))
283
+ # 判断label0和label1是否为空,为空则:label默认2级
284
+ # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
285
+ if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][1]['label'] == info['label'][1][
286
+ 'label'] and info['exp'][0]['score'] <= info['label'][0]['score'] and info['exp'][1]['score'] <= \
287
+ info['label'][1]['score']:
288
+ info['rt'] = True
289
+ else:
290
+ info['rt'] = False
291
+ else:
292
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
293
+ info['rt'] = False
294
+ return info
295
+
171
296
 
172
297
  def do_metricsevaluation_list(collections,data,score_threshold):
173
298
  """
@@ -181,8 +306,8 @@ def do_metricsevaluation_list(collections,data,score_threshold):
181
306
  "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
182
307
  },
183
308
  "rt": True,
184
- "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
185
- "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8 }],
309
+ "label": [{"label": "测试"}, {"label": "测试"}],
310
+ "exp": [{"label": "测试"}, {"label": "测试" }],
186
311
  "artificial": []
187
312
  }
188
313
  info_list = []
@@ -190,20 +315,31 @@ def do_metricsevaluation_list(collections,data,score_threshold):
190
315
  for i in collections:
191
316
  for j in data:
192
317
  if i['content'] == j['用户输入/userInput']:
318
+ info = {
319
+ "input": {},
320
+ "output": {},
321
+ "rt": False,
322
+ "label": [{"label": "测试"}, {"label": "测试"}],
323
+ "exp": [{"label": "测试",}, {"label": "测试"}],
324
+ "artificial": []
325
+ }
193
326
  info['input']['用户输入/userInput'] = i['ext']['output']
194
- info['output']['用户输入/output'] = j['用户输入/userInput']
327
+ info['output']['用户输入/output'] = "对话id:"+j['对话日志/intentID']+" 对话内容:"+j['用户输入/userInput']
195
328
  if i['ext']['BPO标注-AP-分发技能'] != '' and i['ext']['BPO标注-AP-分发技能'] in j['分发技能/skill'][0]:
196
329
  info['rt'] = True
197
- info['label'] = [{'label': j['分发技能/skill'][0], 'score': score_threshold}]
198
- info['exp'] = [{'label': j['分发技能/skill'][0], 'score': score_threshold}]
330
+ info['label'] = [{'label': j['分发技能/skill'][0]}]
331
+ info['exp'] = [{'label': j['分发技能/skill'][0]}]
199
332
  info['artificial'] = info['exp']
200
333
  else:
201
334
  info['rt'] = False
202
- info['label'] = [{'label': j['分发技能/skill'][0], 'score': score_threshold}]
203
- info['exp'] = [{'label': i['ext']['BPO标注-AP-分发技能'], 'score': score_threshold}]
335
+ info['label'] = [{'label': j['分发技能/skill'][0]}]
336
+ info['exp'] = [{'label': i['ext']['BPO标注-AP-分发技能']}]
204
337
  info['artificial'] = info['exp']
205
338
  if i['ext']['BPO标注-AP-分发技能'] not in businessscenario:
206
339
  businessscenario.append(i['ext']['BPO标注-AP-分发技能'])
340
+ #将data中的j删除
341
+ data.remove(j)
342
+ break
207
343
  info_list.append(copy.deepcopy(info))
208
344
  return info_list,businessscenario
209
345
 
@@ -290,6 +426,305 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
290
426
  bbb = a
291
427
  return info_list
292
428
 
429
+ def do_waterlevelline_autotest_aseetspu(collections, clientinfo, score_threshold):
430
+ """
431
+ 水位线评测- 返回 符合报告模式的结果
432
+ """
433
+ keywprd= []
434
+ info_list = []
435
+ info = {
436
+ "input": {
437
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
438
+ },
439
+ "output": {
440
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
441
+ },
442
+ "rt": True,
443
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
444
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
445
+ }],
446
+ "artificial": []
447
+ }
448
+ a =0
449
+ for i in collections:
450
+ info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
451
+ 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}]
455
+ info['artificial'] = info['exp']
456
+ info['label']=[]
457
+ if i['ext']['BPO标注-AP-资产名称']:
458
+ if "设备" in i['ext']['BPO标注-AP-分发技能'] or "配件" in i['ext']['BPO标注-AP-分发技能']:
459
+ asset_name = i['ext']['BPO标注-AP-资产名称']
460
+ try:
461
+ # 尝试将其解析为 JSON 对象
462
+ if isinstance(asset_name, str):
463
+ asset_name = json.loads(asset_name)
464
+ except json.JSONDecodeError:
465
+ # 若解析失败,说明不是 JSON 格式,保持原样
466
+ pass
467
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
468
+ if i['ext']['BPO标注-AP-资产类型'] == "设备":
469
+ hardtype = 1
470
+ elif i['ext']['BPO标注-AP-资产类型'] == "配件" :
471
+ hardtype = 2
472
+ res = GetBestMatchItemonline(key,hardtype,clientinfo)
473
+ else:
474
+ res = ""
475
+ infoout = do_waterlevellineres_listassetspu(res, info,hardtype)
476
+ info_list.append(copy.deepcopy(infoout))
477
+ a = a+1
478
+ print("这是"+str(a))
479
+ bbb = a
480
+ return info_list
481
+
482
+ def do_waterlevelline_autotest_aseetspu_old(collections, clientinfo, score_threshold):
483
+ """
484
+ 水位线评测- 返回 符合报告模式的结果
485
+ """
486
+ keywprd= []
487
+ info_list = []
488
+ info = {
489
+ "input": {
490
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
491
+ },
492
+ "output": {
493
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
494
+ },
495
+ "rt": True,
496
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
497
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
498
+ }],
499
+ "artificial": []
500
+ }
501
+ a =0
502
+ for i in collections:
503
+ info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
504
+ info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
505
+ info['exp'] = [
506
+ {'label': i['ext']['BPO标注-AP-资产型号'], 'score': score_threshold},
507
+ {'label': i['ext'].get('BPO标注-AP-资产型号1', ''), 'score': score_threshold}]
508
+ info['artificial'] = info['exp']
509
+ info['label']=[]
510
+ if i['ext']['BPO标注-AP-资产名称']:
511
+ if "设备" in i['ext']['BPO标注-AP-分发技能'] or "配件" in i['ext']['BPO标注-AP-分发技能']:
512
+ asset_name = i['ext']['BPO标注-AP-资产名称']
513
+ asset_name = i['ext']['BPO标注-AP-资产类型']
514
+ try:
515
+ # 尝试将其解析为 JSON 对象
516
+ if isinstance(asset_name, str):
517
+ asset_name = json.loads(asset_name)
518
+ except json.JSONDecodeError:
519
+ # 若解析失败,说明不是 JSON 格式,保持原样
520
+ pass
521
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
522
+ if i['ext']['BPO标注-AP-资产型号'] == "设备":
523
+ hardtype = 1
524
+ elif i['ext']['BPO标注-AP-资产型号'] == "配件" :
525
+ hardtype = 2
526
+ res = GetBestMatchItemonline_old(key,hardtype,clientinfo)
527
+ else:
528
+ res = ""
529
+ infoout = do_waterlevellineres_listassetspu(res, info,hardtype)
530
+ info_list.append(copy.deepcopy(infoout))
531
+ a = a+1
532
+ print("这是"+str(a))
533
+ bbb = a
534
+ return info_list
535
+
536
+
537
+ def do_waterlevelline_autotest_aseetspu_pre(collections, clientinfo, score_threshold):
538
+ """
539
+ 水位线评测- 返回 符合报告模式的结果
540
+ """
541
+ keywprd= []
542
+ info_list = []
543
+ info = {
544
+ "input": {
545
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
546
+ },
547
+ "output": {
548
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
549
+ },
550
+ "rt": True,
551
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
552
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
553
+ }],
554
+ "artificial": []
555
+ }
556
+ a =0
557
+ for i in collections:
558
+ info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
559
+ info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
560
+ info['exp'] = [
561
+ {'label': i['ext']['BPO标注-AP-资产型号'], 'score': score_threshold},
562
+ {'label': i['ext'].get('BPO标注-AP-资产型号1', ''), 'score': score_threshold}]
563
+ info['artificial'] = info['exp']
564
+ info['label']=[]
565
+ if i['ext']['BPO标注-AP-资产名称']:
566
+ if "设备" in i['ext']['BPO标注-AP-分发技能'] or "配件" in i['ext']['BPO标注-AP-分发技能']:
567
+ asset_name = i['ext']['BPO标注-AP-资产名称']
568
+ asset_name = i['ext']['BPO标注-AP-资产类型']
569
+ try:
570
+ # 尝试将其解析为 JSON 对象
571
+ if isinstance(asset_name, str):
572
+ asset_name = json.loads(asset_name)
573
+ except json.JSONDecodeError:
574
+ # 若解析失败,说明不是 JSON 格式,保持原样
575
+ pass
576
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
577
+ if i['ext']['BPO标注-AP-资产型号'] == "设备":
578
+ hardtype = 1
579
+ elif i['ext']['BPO标注-AP-资产型号'] == "配件" :
580
+ hardtype = 2
581
+ res = test_hardware_match(key,hardtype,clientinfo)
582
+ else:
583
+ res = ""
584
+ infoout = do_waterlevellineres_listassetspu_pre(res, info,hardtype)
585
+ info_list.append(copy.deepcopy(infoout))
586
+ a = a+1
587
+ print("这是"+str(a))
588
+ bbb = a
589
+ return info_list
590
+
591
+ def do_waterlevelline_autotest_search(collections, clientinfo, score_threshold):
592
+ """
593
+ 水位线评测- 返回 符合报告模式的结果
594
+ """
595
+ keywprd= []
596
+ info_list = []
597
+ info = {
598
+ "input": {
599
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
600
+ },
601
+ "output": {
602
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
603
+ },
604
+ "rt": True,
605
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
606
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
607
+ }],
608
+ "artificial": []
609
+ }
610
+ a =0
611
+ for i in collections:
612
+ info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
613
+ info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
614
+ info['exp'] = [
615
+ {'label': i['ext']['BPO标注-AP-资产型号'], 'score': score_threshold},
616
+ {'label': i['ext'].get('BPO标注-AP-资产型号1', ''), 'score': score_threshold}]
617
+ info['artificial'] = info['exp']
618
+ info['label']=[]
619
+ if i['ext']['BPO标注-AP-资产名称']:
620
+ if "设备" in i['ext']['BPO标注-AP-分发技能'] or "配件" in i['ext']['BPO标注-AP-分发技能']:
621
+ asset_name = i['ext']['BPO标注-AP-资产名称']
622
+ asset_name = i['ext']['BPO标注-AP-资产类型']
623
+ try:
624
+ # 尝试将其解析为 JSON 对象
625
+ if isinstance(asset_name, str):
626
+ asset_name = json.loads(asset_name)
627
+ except json.JSONDecodeError:
628
+ # 若解析失败,说明不是 JSON 格式,保持原样
629
+ pass
630
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
631
+ if i['ext']['BPO标注-AP-资产型号'] == "设备":
632
+ hardtype = 1
633
+ elif i['ext']['BPO标注-AP-资产型号'] == "配件" :
634
+ hardtype = 2
635
+ res = searchListAssetModelScope(key,hardtype,clientinfo)
636
+ else:
637
+ res = ""
638
+ infoout = do_waterlevellineres_sr(res, info,hardtype)
639
+ info_list.append(copy.deepcopy(infoout))
640
+ a = a+1
641
+ print("这是"+str(a))
642
+ bbb = a
643
+ return info_list
644
+
645
+
646
+ def do_waterlevelline_autotest_SoftwareApplyRecommendList(collections, clientinfo, score_threshold):
647
+ """
648
+ 水位线评测- 返回 符合报告模式的结果
649
+ """
650
+ keywprd= []
651
+ info_list = []
652
+ info = {
653
+ "input": {
654
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
655
+ },
656
+ "output": {
657
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
658
+ },
659
+ "rt": True,
660
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
661
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
662
+ }],
663
+ "artificial": []
664
+ }
665
+ a =0
666
+ for i in collections:
667
+ info['input']['用户输入/userInput'] = i['ext'].get('BP标注-AP-资产名称') or i['ext'].get('BPO标注-AP-资产名称')
668
+ info['output']['用户输入/output'] = i['ext']['BP标注-AP-资产名称']
669
+ info['exp'] = [
670
+ {'label': i['ext']['BP标注-AP-资产名称'], 'score': score_threshold},
671
+ {'label': i['ext'].get('BP标注-AP-资产型号1', ''), 'score': score_threshold}]
672
+ info['artificial'] = info['exp']
673
+ info['label']=[]
674
+ if i['ext']['BP标注-AP-资产名称']:
675
+ if "软件" in i['ext']['BP标注-AP-分发技能']:
676
+ asset_name = i['ext']['BP标注-AP-资产名称']
677
+ try:
678
+ # 尝试将其解析为 JSON 对象
679
+ if isinstance(asset_name, str):
680
+ asset_name = json.loads(asset_name)
681
+ except json.JSONDecodeError:
682
+ # 若解析失败,说明不是 JSON 格式,保持原样
683
+ pass
684
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
685
+ res = SoftwareApplyGetBestMatchItem(key,clientinfo)
686
+ else:
687
+ res = ""
688
+ infoout = do_waterlevellineres_software(res, info)
689
+ info_list.append(copy.deepcopy(infoout))
690
+ a = a+1
691
+ print("这是"+str(a))
692
+ bbb = a
693
+ return info_list
694
+
695
+
696
+ def do_waterlevellineres_software(res, info):
697
+ """
698
+ 获取结果,并组装水位线info
699
+ """
700
+ if res == '':
701
+ info['label'] = [{'label': '', 'score': 0}]
702
+ info['rt'] = False
703
+ return info
704
+ if res["data"].get("SoftwareApplyRecommendList") == None:
705
+ info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
706
+ info['rt'] = False
707
+ if info['exp'][0]['label']=='':
708
+ info['rt'] = True
709
+ return info
710
+ reslist=res["data"]["SoftwareApplyRecommendList"]
711
+ aaa ={}
712
+ # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
713
+ if reslist:
714
+ # 取["Results"]下前2个结果,若只有1个结果,label1为空
715
+ if len(reslist) > 0:
716
+ for j in range(len(reslist)):
717
+ aaa = {'label': reslist[j]['Data']['Name']['ValueZh'],
718
+ 'score': reslist[j]['Score']}
719
+ info['label'].append(copy.deepcopy(aaa))
720
+ if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][0]['score'] <= info['label'][0]['score']:
721
+ info['rt'] = True
722
+ else:
723
+ info['rt'] = False
724
+ else:
725
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
726
+ info['rt'] = False
727
+ return info
293
728
 
294
729
  def get_conversationlogs1(startAt):
295
730
  """
@@ -420,71 +855,3 @@ def write_excletolist(data_name):
420
855
 
421
856
 
422
857
 
423
-
424
- if __name__ == '__main__':
425
- clientinfo={
426
- "Authorization": "Basic cm40cmFpdTRwenY1cGlsYTo2bWhvOXV3ZXFrOHZpbDllcXRxMHZ1YmVnc2xjeXBucg==",
427
- "x_tt_env": "ppe_cn_env_self_test_feat_cr_a"
428
- }
429
-
430
-
431
- # 读取 CSV 文件
432
- with open('/Users/bytedance/it_assistant/test.csv', mode='r', encoding='utf-8') as file:
433
- csv_reader = csv.reader(file)
434
- for row in csv_reader:
435
-
436
- print(row)
437
- parm = {
438
- "From": 0,
439
- "Size": 10,
440
- "MinScore": 0.1,
441
- "AssetModelFieldsWithOr": [
442
- {
443
- "FieldName": "vec_name",
444
- "FieldType": "knn",
445
- "QueryValue": row
446
- },
447
- {
448
- "FieldName": "vec_brand",
449
- "FieldType": "knn",
450
- "QueryValue": row
451
- },
452
- {
453
- "FieldName": "vec_specification",
454
- "FieldType": "knn",
455
- "QueryValue": row
456
- },
457
- {
458
- "FieldName": "vec_model_name",
459
- "FieldType": "knn",
460
- "QueryValue": row
461
- }
462
- ],
463
- "AssetModelBizTypes": ["asset_sku"]
464
- }
465
- # 每一行是一个列表
466
-
467
- info={
468
- "score":0.8,
469
- "itams": ""
470
- }
471
- info_list = []
472
-
473
- cccc = get_query_vector(parm,clientinfo)
474
- bbbb = json.loads(cccc)['body']['Results']
475
- bbbb[0]['Score']
476
- #将bbbb[0]['Score']写入test.csv的score0列
477
-
478
-
479
-
480
- for i in bbbb:
481
- info['score']=i['Score']/4
482
- info['itams']=i['Item']['brand_zh']+i['Item']['model_zh']+i['Item']['specification_zh']
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
@@ -11,6 +11,7 @@ itamheaders = {
11
11
  }
12
12
 
13
13
 
14
+
14
15
  class webapiClient():
15
16
  def __init__(self, clientin):
16
17
  """
@@ -53,10 +54,10 @@ class webapiClient():
53
54
  "pageSize": pageSize + 10
54
55
  })
55
56
  try:
56
- self.conn.request("POST",
57
- "/ai/api/v1/conversational_runtime/namespaces/spring_f17d05d924__c/stats/intent_detail_list",
58
- payload, self.headers)
57
+ self.conn.request("POST","/ai/api/v1/conversational_runtime/namespaces/spring_f17d05d924__c/stats/intent_detail_list",payload, self.headers)
59
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)
60
61
 
61
62
  # 检查响应状态码
62
63
  if res.status != 200: