itam-assistant 0.1.8__py3-none-any.whl → 0.1.10__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.
itam_assistant/do_ai.py CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import time
3
- from itam_assistant1.ailyapp_client import AilyLarkClient
4
- from itam_assistant1.lark_client import LarkdocsClient
5
- from itam_assistant1.intent_detail import *
6
- from itam_assistant1.openapi import *
3
+ from itam_assistant.ailyapp_client import AilyLarkClient
4
+ from itam_assistant.lark_client import LarkdocsClient
5
+ from itam_assistant.intent_detail import *
6
+ from itam_assistant.openapi import *
7
7
  import datetime
8
8
  import copy
9
9
  import os
@@ -68,7 +68,7 @@ def do_ai_auto(Testk_data, clientinfo):
68
68
  # 可不需等待运行实例创建完成
69
69
  # if not runs:
70
70
  # raise ValueError("未能成功创建运行实例")
71
- time.sleep(5)
71
+ time.sleep(2)
72
72
  else:
73
73
  return startAt, i
74
74
  break
@@ -81,23 +81,26 @@ def do_ai_auto(Testk_data, clientinfo):
81
81
  tenant_access_token = AilyLarkClient(clientinfo).get_tenant_access_token()
82
82
  if not tenant_access_token:
83
83
  raise ValueError("未能获取到有效的租户访问令牌")
84
- aa = i['ext']['input']
84
+ if i['ext'].get('input'):
85
+ aa = i['ext']['input']
86
+ else:
87
+ aa = i['ext']['用户输入']
85
88
  if startAt == 0:
86
89
  startAt = int(time.time())
87
90
  # 创建会话
88
91
  seseion_id = AilyLarkClient(clientinfo).create_ailysession(tenant_access_token)
89
- time.sleep(10)
92
+ time.sleep(3)
90
93
  if not seseion_id:
91
94
  raise ValueError("未能成功创建会话")
92
95
  # 创建消息
93
96
  message_id = AilyLarkClient(clientinfo).create_ailysessionaily_message(tenant_access_token, seseion_id,
94
97
  aa)
95
- time.sleep(5)
98
+ time.sleep(3)
96
99
  if not message_id:
97
100
  raise ValueError("未能成功创建消息")
98
101
  # 创建运行实例
99
102
  runs = AilyLarkClient(clientinfo).create_ailysession_run(tenant_access_token, seseion_id)
100
- time.sleep(5)
103
+ time.sleep(4)
101
104
  num = num + 1
102
105
  return startAt, num
103
106
  except KeyError as ke:
@@ -316,12 +319,13 @@ def do_waterlevellineres_sr(res, info,hardtype):
316
319
  info['label'].append(copy.deepcopy(aaa))
317
320
  # 判断label0和label1是否为空,为空则:label默认2级
318
321
  # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
319
- if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][1]['label'] == info['label'][1][
320
- 'label'] and info['exp'][0]['score'] <= info['label'][0]['score'] and info['exp'][1]['score'] <= \
321
- info['label'][1]['score']:
322
- info['rt'] = True
323
- else:
324
- info['rt'] = False
322
+ # 判断label0和label1是否为空,为空则:label默认2级
323
+ for a in range(len(info['exp'])):
324
+ if info['exp'][a]['label'] == info['label'][a]['label']:
325
+ info['rt'] = True
326
+ else:
327
+ info['rt'] = False
328
+ break
325
329
  else:
326
330
  info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
327
331
  info['rt'] = False
@@ -334,10 +338,10 @@ def do_metricsevaluation_list(collections,data,score_threshold):
334
338
  """
335
339
  info = {
336
340
  "input": {
337
- "用户输入/userInput": "测试数据"
341
+ "用户输入": "测试数据"
338
342
  },
339
343
  "output": {
340
- "用户输入/output": "测试数据"
344
+ "output": "测试数据"
341
345
  },
342
346
  "rt": False,
343
347
  "label": [{"label": "测试"}, {"label": "测试"}],
@@ -351,20 +355,20 @@ def do_metricsevaluation_list(collections,data,score_threshold):
351
355
  cleaned_content = i['content'].replace('\r', '').replace('\n', '').replace('\\', '')
352
356
  cleaned_userInput = j['用户输入/userInput'].replace('\r', '').replace('\n', '').replace('\\', '')
353
357
  if cleaned_content == cleaned_userInput:
354
- info['input']['用户输入/userInput'] = i['ext']['input']
355
- info['output']['用户输入/output'] = "对话id:"+j['对话日志/intentID']+" 对话内容:"+j['用户输入/userInput']
356
- if i['ext']['BPO标注-AP-分发技能'] != '' and i['ext']['BPO标注-AP-分发技能'] in j['分发技能/skill'][0]:
358
+ info['input']['用户输入'] = i['ext'].get('input') or i['ext']['用户输入']
359
+ info['output']['output'] = "对话id:"+j['对话日志/intentID']+" 对话内容:"+j['用户输入/userInput']
360
+ if i['ext']['分发技能'] != '' and i['ext']['分发技能'] in j['分发技能/skill'][0]:
357
361
  info['rt'] = True
358
362
  info['label'] = [{'label': j['分发技能/skill'][0]}]
359
- info['exp'] = [{'label': i['ext']['BPO标注-AP-分发技能']}]
363
+ info['exp'] = [{'label': i['ext']['分发技能']}]
360
364
  info['artificial'] = info['exp']
361
365
  else:
362
366
  info['rt'] = False
363
367
  info['label'] = [{'label': j['分发技能/skill'][0]}]
364
- info['exp'] = [{'label': i['ext']['BPO标注-AP-分发技能']}]
368
+ info['exp'] = [{'label': i['ext']['分发技能']}]
365
369
  info['artificial'] = info['exp']
366
- if i['ext']['BPO标注-AP-分发技能'] not in businessscenario:
367
- businessscenario.append(i['ext']['BPO标注-AP-分发技能'])
370
+ if i['ext']['分发技能'] not in businessscenario:
371
+ businessscenario.append(i['ext']['分发技能'])
368
372
  #将data中的j删除
369
373
  data.remove(j)
370
374
  info_list.append(copy.deepcopy(info))
@@ -725,7 +729,7 @@ def do_waterlevelline_autotest_SoftwareApplyRecommendList(collections, clientinf
725
729
  "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
726
730
  },
727
731
  "output": {
728
- "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
732
+ "实际输出/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
729
733
  },
730
734
  "rt": True,
731
735
  "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
@@ -735,16 +739,24 @@ def do_waterlevelline_autotest_SoftwareApplyRecommendList(collections, clientinf
735
739
  }
736
740
  a =0
737
741
  for i in collections:
738
- info['input']['用户输入/userInput'] = i['ext'].get('BP标注-AP-资产名称') or i['ext'].get('BPO标注-AP-资产名称')
739
- info['output']['用户输入/output'] = i['ext']['BP标注-AP-资产名称']
740
- info['exp'] = [
741
- {'label': i['ext']['BP标注-AP-资产名称'], 'score': score_threshold},
742
- {'label': i['ext'].get('BP标注-AP-资产型号1', ''), 'score': score_threshold}]
742
+ info['input']['用户输入/userInput'] = i['ext'].get('BPO标注-AP-资产名称') or i['ext'].get('BPO标注-AP-资产名称')
743
+ info['output']['实际输出/output'] = i['ext']['BPO标注-AP-资产名称']
744
+ info['exp'] = []
745
+ for j in [i['ext']['BPO标注-AP-资产型号'], i['ext'].get('BPO标注-AP-资产型号1'),
746
+ i['ext'].get('BPO标注-AP-资产型号2'), i['ext'].get('BPO标注-AP-资产型号3'),
747
+ i['ext'].get('BPO标注-AP-资产型号4'), i['ext'].get('BPO标注-AP-资产型号5'),
748
+ i['ext'].get('BPO标注-AP-资产型号6'), i['ext'].get('BPO标注-AP-资产型号7'),
749
+ i['ext'].get('BPO标注-AP-资产型号8'), i['ext'].get('BPO标注-AP-资产型号9'),
750
+ i['ext'].get('BPO标注-AP-资产型号10')]:
751
+ if j:
752
+ info['exp'].append({'label': j, 'score': score_threshold})
753
+ if info['exp'] == '':
754
+ break
743
755
  info['artificial'] = info['exp']
744
756
  info['label']=[]
745
- if i['ext']['BP标注-AP-资产名称']:
746
- if "软件" in i['ext']['BP标注-AP-分发技能']:
747
- asset_name = i['ext']['BP标注-AP-资产名称']
757
+ if i['ext']['BPO标注-AP-资产名称']:
758
+ if "软件" in i['ext']['BPO标注-AP-分发技能']:
759
+ asset_name = i['ext']['BPO标注-AP-资产名称']
748
760
  try:
749
761
  # 尝试将其解析为 JSON 对象
750
762
  if isinstance(asset_name, str):
@@ -780,6 +792,7 @@ def do_waterlevellineres_software(res, info):
780
792
  return info
781
793
  reslist=res["data"]["SoftwareApplyRecommendList"]
782
794
  aaa ={}
795
+ info['output']['实际输出/output'] = 'requestId:'+res.get('requestId')
783
796
  # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
784
797
  if reslist:
785
798
  # 取["Results"]下前2个结果,若只有1个结果,label1为空
@@ -788,15 +801,46 @@ def do_waterlevellineres_software(res, info):
788
801
  aaa = {'label': reslist[j]['Data']['Name']['ValueZh'],
789
802
  'score': reslist[j]['Score']}
790
803
  info['label'].append(copy.deepcopy(aaa))
791
- if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][0]['score'] <= info['label'][0]['score']:
792
- info['rt'] = True
793
- else:
794
- info['rt'] = False
804
+
805
+ info['rt'] = do_businessassertionrules(info['label'],info['exp'])
795
806
  else:
796
807
  info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
797
808
  info['rt'] = False
798
809
  return info
799
810
 
811
+ def do_businessassertionrules(label, epx):
812
+ """
813
+ 业务断言
814
+ :param res:
815
+ :param info:
816
+ :return:
817
+ """
818
+ # 当预期值或实际值列表为空时,直接返回 False
819
+ if not epx or not label:
820
+ return False
821
+
822
+ # 规则1:当预期值为1维时
823
+ if len(epx) == 1:
824
+ return epx[0]['label'] == label[0]['label']
825
+
826
+ # 规则2:当预期值大于等于 实际值时,判断预期值包含实际值
827
+ if len(epx) >= len(label):
828
+ for i in range(len(label)):
829
+ if epx[i]['label'] != label[i]['label']:
830
+ return False
831
+ return True
832
+
833
+ # 规则3:当预期值小于 实际值时,判断实际值包含预期值
834
+ for i in range(len(epx)):
835
+ if epx[i]['label'] != label[i]['label']:
836
+ return False
837
+ return True
838
+
839
+
840
+
841
+
842
+
843
+
800
844
  def get_conversationlogs1(startAt):
801
845
  """
802
846
  对话ID 技能分发 用户输入
@@ -895,7 +939,7 @@ def write_excletolist(data_name):
895
939
  try:
896
940
  # 查看当前工作目录
897
941
  print(f"当前工作目录: {os.getcwd()}")
898
- # /Users/bytedance/itam_assistant1/itam_assistant1/accessory.csv
942
+ # /Users/bytedance/itam_assistant/itam_assistant/accessory.csv
899
943
  # 构建文件路径
900
944
  file_path = f'data/{data_name}.csv'
901
945
  Candidates = []
@@ -926,3 +970,91 @@ def write_excletolist(data_name):
926
970
 
927
971
 
928
972
 
973
+ def do_waterlevelline_autotest_fix(collections, clientinfo, score_threshold):
974
+ """
975
+ 水位线评测- 返回 符合报告模式的结果
976
+ """
977
+ keywprd= []
978
+ info_list = []
979
+ info = {
980
+ "input": {
981
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
982
+ },
983
+ "output": {
984
+ "用户输入/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
985
+ },
986
+ "rt": True,
987
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
988
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
989
+ }],
990
+ "artificial": []
991
+ }
992
+ a =0
993
+ for i in collections:
994
+ info['input']['用户输入/userInput'] = i['ext']['资产名称']
995
+ info['output']['用户输入/output'] = i['ext']['资产名称']
996
+ info['exp'] = []
997
+ for j in [i['ext']['匹配型号1'], i['ext'].get('匹配型号2'),i['ext'].get('匹配型号3'),i['ext'].get('匹配型号4'),i['ext'].get('匹配型号5'),i['ext'].get('匹配型号6'),i['ext'].get('匹配型号7'),i['ext'].get('匹配型号8'),i['ext'].get('匹配型号9'),i['ext'].get('匹配型号10')]:
998
+ if j:
999
+ info['exp'].append({'label': j, 'score': score_threshold})
1000
+ #判断i['ext']['BPO标注-AP-资产型号']是否为空,为空就不用读取,不为空就读取
1001
+ if i['ext']['资产名称']:
1002
+ asset_name = i['ext']['资产名称']
1003
+ try:
1004
+ if isinstance(asset_name, str):
1005
+ asset_name = json.loads(asset_name)
1006
+ except json.JSONDecodeError:
1007
+ # 若解析失败,说明不是 JSON 格式,保持原样
1008
+ pass
1009
+ info['artificial'] = info['exp']
1010
+ if i['ext']['资产名称']:
1011
+ asset_name = i['ext']['资产名称']
1012
+ try:
1013
+ if isinstance(asset_name, str):
1014
+ asset_name = json.loads(asset_name)
1015
+ except json.JSONDecodeError:
1016
+ # 若解析失败,说明不是 JSON 格式,保持原样
1017
+ pass
1018
+ if "设备领用" in i['ext']['评测集标签']:
1019
+ keywprd = GetBestMatchItemandres_new(asset_name, i['ext']['资产类型'], clientinfo)
1020
+
1021
+ else:
1022
+ res = ""
1023
+ infoout = do_waterlevellineres_listv3(keywprd, info)
1024
+ info_list.append(copy.deepcopy(infoout))
1025
+ a = a+1
1026
+ print("这是"+str(a))
1027
+ bbb = a
1028
+ return info_list
1029
+
1030
+
1031
+ def do_waterlevellineres_listv3(res, info):
1032
+ """
1033
+ 获取结果,并组装水位线info
1034
+ """
1035
+ if res == '':
1036
+ info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
1037
+ info['rt'] = False
1038
+ return info
1039
+ reslist = res['res']
1040
+ info['output']['用户输入/output'] = 'log_id:' + res.get('log')
1041
+ if reslist:
1042
+ #取所有结果并追加到info['label']
1043
+ info['label'] = []
1044
+ if len(reslist) > 0:
1045
+ for j in range(len(reslist)):
1046
+ aaa = {'label': reslist[j]['Name'],
1047
+ 'score': reslist[j]['Score']}
1048
+ info['label'].append(copy.deepcopy(aaa))
1049
+ # 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
1050
+ for a in range(len(info['exp'])):
1051
+ if info['exp'][a]['label']== info['label'][a]['label']:
1052
+ info['rt'] = True
1053
+ else:
1054
+ info['rt'] = False
1055
+ break
1056
+ else:
1057
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
1058
+ info['rt'] = False
1059
+
1060
+ return info
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: itam_assistant
3
+ Version: 0.1.10
4
+ Summary: 优化版本--技能分发的结果展示-新增时间控制
5
+ Home-page: https://github.com/liujunmeiD/itam_assistant
6
+ Author: liujunmeiD
7
+ Author-email: 1105030421@qq.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.1
14
+ Requires-Dist: numpy>=1.20.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ 详见https://bytedance.feishu.cn/docs/doccnSOL0o2qtnElftgd2rir2Dc
@@ -10,7 +10,7 @@ it_assistant/test.py,sha256=qGSihMYmtZkz_vifwEOz579f_wPBJAx5_rz1sABUyo4,581
10
10
  itam_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  itam_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
12
12
  itam_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
13
- itam_assistant/do_ai.py,sha256=esVBjVZb_D_lxWng3X9nUj8s_qSYKaCorlhhfPn8I68,41603
13
+ itam_assistant/do_ai.py,sha256=zrJ8a4ZiZC1aBYBBto0yXncROMM7yYY34jTVdis_5MU,46739
14
14
  itam_assistant/intent_detail.py,sha256=hmEj1KpcuKNvsoBZmn5PnbsBIIx6XGmQBJWdW_ICFmg,16831
15
15
  itam_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
16
16
  itam_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
@@ -22,7 +22,7 @@ main/do_ai.py,sha256=rxsTRdd3oBs-gsIssHz3XV-6lIC5Bq4qoyNuyQzjidg,6879
22
22
  main/intent_detail.py,sha256=Fo76c4BpGya-znCnKH7YAcr_2UJtbi3WPQN-PwtVsXc,18533
23
23
  main/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
24
24
  main/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
25
- itam_assistant-0.1.8.dist-info/METADATA,sha256=b-0yfthQ4e7IQ6a6iFDpQh9LkZV029snjIlO1VFgeII,556
26
- itam_assistant-0.1.8.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
- itam_assistant-0.1.8.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
28
- itam_assistant-0.1.8.dist-info/RECORD,,
25
+ itam_assistant-0.1.10.dist-info/METADATA,sha256=FDUQr4eOtmJ5KI6SZJVRCmjlRIqVZIyB2SFd5ZZLCko,771
26
+ itam_assistant-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ itam_assistant-0.1.10.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
28
+ itam_assistant-0.1.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: itam-assistant
3
- Version: 0.1.8
4
- Summary: 优化版本--技能分发的结果展示
5
- Home-page: https://github.com/liujunmeiD/itam_assistant
6
- Author: liujunmeiD
7
- Author-email: 1105030421@qq.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- Requires-Dist: requests >=2.25.1
14
- Requires-Dist: numpy >=1.20.0
15
-
16
- 详见https://bytedance.feishu.cn/docs/doccnSOL0o2qtnElftgd2rir2Dc