itam-assistant 0.1.17__tar.gz → 0.1.19__tar.gz

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.
Files changed (19) hide show
  1. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/PKG-INFO +2 -2
  2. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/do_ai.py +93 -3
  3. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/openapi.py +19 -1
  4. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant.egg-info/PKG-INFO +2 -2
  5. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/setup.py +2 -2
  6. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/README.md +0 -0
  7. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/__init__.py +0 -0
  8. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/ailyapp_client.py +0 -0
  9. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/config.py +0 -0
  10. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/intent_detail.py +0 -0
  11. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/lark_client.py +0 -0
  12. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/logger.py +0 -0
  13. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant/test.py +0 -0
  14. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant.egg-info/SOURCES.txt +0 -0
  15. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant.egg-info/dependency_links.txt +0 -0
  16. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant.egg-info/requires.txt +0 -0
  17. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/itam_assistant.egg-info/top_level.txt +0 -0
  18. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/setup.cfg +0 -0
  19. {itam_assistant-0.1.17 → itam_assistant-0.1.19}/test/test.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itam_assistant
3
- Version: 0.1.17
4
- Summary: 新增功能:检查接口授权是否过期
3
+ Version: 0.1.19
4
+ Summary: 新增-软件搜索
5
5
  Home-page: https://github.com/liujunmeiD/itam_assistant
6
6
  Author: liujunmeiD
7
7
  Author-email: 1105030421@qq.com
@@ -104,6 +104,7 @@ def do_ai_auto(Testk_data, clientinfo):
104
104
  time.sleep(4)
105
105
  num = num + 1
106
106
  time.sleep(4)
107
+ print(f"已处理{num}/{len(Testk_data)}条数据,用户输入为:{aa}")
107
108
  return startAt, num
108
109
  except KeyError as ke:
109
110
  print(f"KeyError 发生: 数据中缺少必要的键,错误详情: {ke}")
@@ -461,11 +462,11 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
461
462
  info['input']['用户输入/userInput'] = i['ext']['资产名称']
462
463
  info['output']['用户输入/output'] = i['ext']['资产名称']
463
464
  info['exp'] = []
464
- for j in [i['ext']['资产型号'], i['ext'].get('资产型号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')]:
465
+ for j in [i['ext'].get('匹配型号'), i['ext'].get('匹配型号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')]:
465
466
  if j:
466
467
  info['exp'].append({'label': j, 'score': score_threshold})
467
468
  #判断i['ext']['资产型号']是否为空,为空就不用读取,不为空就读取
468
- if i['ext']['资产型号']:
469
+ if i['ext']['资产名称']:
469
470
  asset_name = i['ext']['资产名称']
470
471
  try:
471
472
  if isinstance(asset_name, str):
@@ -485,7 +486,7 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
485
486
  if "软件申请" in i['ext']['分发技能']:
486
487
  keywprd = software_asset_sku_structure(asset_name)
487
488
  res = json.loads(get_query_vector(keywprd, clientinfo))
488
- if "设备/配件申请" in i['ext']['分发技能']:
489
+ if "设备&配件领用" in i['ext']['分发技能']:
489
490
  #keywprd = equipmentrequest_structure(asset_name, i['ext']['asset_type'])
490
491
  keywprd = {
491
492
  "From": 0,
@@ -850,6 +851,62 @@ def do_waterlevelline_autotest_SoftwareApplyRecommendList(collections, clientinf
850
851
  bbb = a
851
852
  return info_list
852
853
 
854
+ def do_waterlevelline_autotest_SoftwareApplyRecommendList_SearchKey(collections, clientinfo, score_threshold):
855
+ """
856
+ 水位线评测- 返回 符合报告模式的结果
857
+ """
858
+ keywprd= []
859
+ info_list = []
860
+ info = {
861
+ "input": {
862
+ "用户输入/userInput": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
863
+ },
864
+ "output": {
865
+ "实际输出/output": "我要申请软件,名字叫:ai_xzh_all_restricted_software完全受限软件"
866
+ },
867
+ "rt": True,
868
+ "label": [{"label": "GUI 软件申请", "score": 0.6}, {"label": "软件申请", "score": 0.5}],
869
+ "exp": [{"label": "GUI 软件申请", " score": 0.9}, {"label": "软件申请", "score": 0.8
870
+ }],
871
+ "artificial": []
872
+ }
873
+ a =0
874
+ for i in collections:
875
+ info['input']['用户输入/userInput'] = i['ext'].get('资产名称') or i['ext'].get('资产名称')
876
+ info['output']['实际输出/output'] = i['ext']['资产名称']
877
+ info['exp'] = []
878
+ for j in [i['ext']['匹配型号1'], i['ext'].get('匹配型号1'),
879
+ i['ext'].get('匹配型号2'), i['ext'].get('匹配型号2'),
880
+ i['ext'].get('匹配型号3'), i['ext'].get('匹配型号3'),
881
+ i['ext'].get('匹配型号4'), i['ext'].get('匹配型号4'),
882
+ i['ext'].get('匹配型号5'), i['ext'].get('匹配型号5'),
883
+ i['ext'].get('匹配型号6')]:
884
+ if j:
885
+ info['exp'].append({'label': j, 'score': score_threshold})
886
+ if info['exp'] == '':
887
+ break
888
+ info['artificial'] = info['exp']
889
+ info['label']=[]
890
+ if i['ext']['资产名称']:
891
+ if "软件" in i['ext']['分发技能']:
892
+ asset_name = i['ext']['资产名称']
893
+ try:
894
+ # 尝试将其解析为 JSON 对象
895
+ if isinstance(asset_name, str):
896
+ asset_name = json.loads(asset_name)
897
+ except json.JSONDecodeError:
898
+ # 若解析失败,说明不是 JSON 格式,保持原样
899
+ pass
900
+ key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
901
+ res = SoftwareApplyGetBestMatchItem_SearchKey(key,clientinfo)
902
+ else:
903
+ res = ""
904
+ infoout = do_waterlevellineres_software_SearchKey(res, info)
905
+ info_list.append(copy.deepcopy(infoout))
906
+ a = a+1
907
+ print("这是"+str(a))
908
+ bbb = a
909
+ return info_list
853
910
 
854
911
  def do_waterlevellineres_software(res, info):
855
912
  """
@@ -883,6 +940,39 @@ def do_waterlevellineres_software(res, info):
883
940
  info['rt'] = False
884
941
  return info
885
942
 
943
+
944
+ def do_waterlevellineres_software_SearchKey(res, info):
945
+ """
946
+ 获取结果,并组装水位线info
947
+ """
948
+ if res == '':
949
+ info['label'] = [{'label': '', 'score': 0}]
950
+ info['rt'] = False
951
+ return info
952
+ info['output']['实际输出/output'] = 'requestId:' + res.get('requestId')
953
+ if res["data"].get("SoftwareApplyRecommendList") == None:
954
+ info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.3}]
955
+ info['rt'] = False
956
+ if info['exp'][0]['label']=='':
957
+ info['rt'] = True
958
+ return info
959
+ reslist = res["data"]["SoftwareApplyRecommendList"]
960
+ aaa ={}
961
+ # 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
962
+ if reslist:
963
+ # 取["Results"]下前2个结果,若只有1个结果,label1为空
964
+ if len(reslist) > 0:
965
+ for j in range(len(reslist)):
966
+ aaa = {'label': reslist[j]['Data']['Name']['ValueZh'],
967
+ 'score': reslist[j]['Score']/20}
968
+ info['label'].append(copy.deepcopy(aaa))
969
+
970
+ info['rt'] = do_businessassertionrules(info['label'],info['exp'])
971
+ else:
972
+ info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
973
+ info['rt'] = False
974
+ return info
975
+
886
976
  def do_businessassertionrules(label, epx):
887
977
  """
888
978
  业务断言
@@ -680,7 +680,7 @@ def GetBestMatchItemonline_old(SearchKey, HardwareMatchType, clientinfo):
680
680
  payload = json.dumps({
681
681
  "SearchKey": SearchKey,
682
682
  "TopN": 1000,
683
- "AiUseType": 3,
683
+ "AiUseType": 5,
684
684
  "QueryAssetModelScopeRequest":
685
685
  {"FlowTemplateIDs":
686
686
  ["6883468409742298119", "7514160571177913371", "6885245774565739523", "6883468929408437256",
@@ -791,6 +791,24 @@ def SoftwareApplyGetBestMatchItem(key, clientinfo):
791
791
  return json.loads(response.text)
792
792
 
793
793
 
794
+
795
+ def SoftwareApplyGetBestMatchItem_SearchKey(key, clientinfo):
796
+ url = "https://it.bytedance.com/itam-byte/api/itservice/common/GetBestMatchItem"
797
+ payload = json.dumps({"SearchKey":"","TopN":5,"AiUseType":100,"SoftwareApplyRequest":{"Size":30,"Search":key},"psm":"athena"})
798
+ headers = {
799
+ 'authorization': clientinfo.get(
800
+ 'authorization') or 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InYyIiwidHlwIjoiSldUIn0.eyJleHAiOjE3NTEwMDU1MjQsImp0aSI6IktJVVI5ZkdoZ2Q1cyt4NWIiLCJpYXQiOjE3NDk3MDk1MjQsImlzcyI6InRhbm5hIiwic3ViIjoiMzgzMDMxOUBieXRlZGFuY2UucGVvcGxlIiwidGVuYW50X2lkIjoiYnl0ZWRhbmNlLnBlb3BsZSIsInRlbmFudF9uYW1lIjoiIiwicHJvamVjdF9rZXkiOiJjcm1TZmdIVmU1dXhIMHJyIiwidW5pdCI6ImV1X25jIiwiYXV0aF9ieSI6Mn0.wtuTgUI6posLTQ-WJU539NuIYbMCgYqBrCOvdigR09h8zl_VO7tUJ4GSmfjDH8jZjtGSF-nEoDLPbX2z4BZkwtvoh--oa8KP-IIOOk2KQS2lVHz1mE7HWaEdCpml1_DS0PJB42F3B-L0EjRqQki_g3Jjn1kZjMgwFqpFW-TwcpY',
801
+ 'cookie': clientinfo.get(
802
+ 'cookie') or '_tea_utm_cache_1229=undefined; MONITOR_WEB_ID=ce5a3279-6ed5-4ede-9b00-29aa7c1a1311; amuserid=3830319@bytedance.people; msToken=TYcrN_92buBPnrV9MSb8i_0Uvz5lFxoWtnz8PA8MhLaAtrddfSUuR69V8vEJvRwEMDOyOAFL-PY87wN-oA4tKDroSbEvsjPNFn202nmCEcO9rKH9KINPWA==',
803
+ 'Content-Type': 'application/json',
804
+ 'x-use-ppe': '1',
805
+ 'x-tt-env': clientinfo.get("x_tt_env")
806
+ }
807
+
808
+ response = requests.request("POST", url, headers=headers, data=payload)
809
+ time.sleep(5)
810
+
811
+ return json.loads(response.text)
794
812
  if __name__ == '__main__':
795
813
  info = {
796
814
  'input': {'用户输入/userInput': 'Autodesk 3Ds MAX'},
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itam_assistant
3
- Version: 0.1.17
4
- Summary: 新增功能:检查接口授权是否过期
3
+ Version: 0.1.19
4
+ Summary: 新增-软件搜索
5
5
  Home-page: https://github.com/liujunmeiD/itam_assistant
6
6
  Author: liujunmeiD
7
7
  Author-email: 1105030421@qq.com
@@ -2,10 +2,10 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="itam_assistant", # 包名称
5
- version="0.1.17", # 版本号
5
+ version="0.1.19", # 版本号
6
6
  author="liujunmeiD",
7
7
  author_email="1105030421@qq.com",
8
- description="新增功能:检查接口授权是否过期",
8
+ description="新增-软件搜索",
9
9
  long_description=open("README.md").read(),
10
10
  long_description_content_type="text/markdown",
11
11
  url="https://github.com/liujunmeiD/itam_assistant",