itam-assistant 0.1.18__py3-none-any.whl → 0.1.19__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
@@ -462,11 +462,11 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
462
462
  info['input']['用户输入/userInput'] = i['ext']['资产名称']
463
463
  info['output']['用户输入/output'] = i['ext']['资产名称']
464
464
  info['exp'] = []
465
- 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')]:
466
466
  if j:
467
467
  info['exp'].append({'label': j, 'score': score_threshold})
468
468
  #判断i['ext']['资产型号']是否为空,为空就不用读取,不为空就读取
469
- if i['ext']['资产型号']:
469
+ if i['ext']['资产名称']:
470
470
  asset_name = i['ext']['资产名称']
471
471
  try:
472
472
  if isinstance(asset_name, str):
@@ -486,7 +486,7 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
486
486
  if "软件申请" in i['ext']['分发技能']:
487
487
  keywprd = software_asset_sku_structure(asset_name)
488
488
  res = json.loads(get_query_vector(keywprd, clientinfo))
489
- if "设备/配件申请" in i['ext']['分发技能']:
489
+ if "设备&配件领用" in i['ext']['分发技能']:
490
490
  #keywprd = equipmentrequest_structure(asset_name, i['ext']['asset_type'])
491
491
  keywprd = {
492
492
  "From": 0,
@@ -851,6 +851,62 @@ def do_waterlevelline_autotest_SoftwareApplyRecommendList(collections, clientinf
851
851
  bbb = a
852
852
  return info_list
853
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
854
910
 
855
911
  def do_waterlevellineres_software(res, info):
856
912
  """
@@ -884,6 +940,39 @@ def do_waterlevellineres_software(res, info):
884
940
  info['rt'] = False
885
941
  return info
886
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
+
887
976
  def do_businessassertionrules(label, epx):
888
977
  """
889
978
  业务断言
itam_assistant/openapi.py CHANGED
@@ -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.18
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
@@ -1,13 +1,13 @@
1
1
  itam_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  itam_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
3
3
  itam_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
4
- itam_assistant/do_ai.py,sha256=fxhZKJs6UMmTkTwRNh-8JS8lcbgxVK5IthI26oXjMPM,49829
4
+ itam_assistant/do_ai.py,sha256=tGjAzhpJwwrHyQi46PUqz_JHNU5_jlJovQhgg9C4NwI,53786
5
5
  itam_assistant/intent_detail.py,sha256=xeQcUa5fDzEWxEV7pudmWMTKFiR_6-zH7hpDC6D7B3I,18378
6
6
  itam_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
7
7
  itam_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
8
- itam_assistant/openapi.py,sha256=xLNLB5Tui_nfDsa95VwASHWa5TMq_oRcFgSOGRaTbyU,50383
8
+ itam_assistant/openapi.py,sha256=l5n5TO3v6VvBfC5KDdUyRb5WtEnKLBZzF1GaCbneqyQ,51839
9
9
  itam_assistant/test.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- itam_assistant-0.1.18.dist-info/METADATA,sha256=_jfLT2PWH1MjoNwhbNDIITUztXHfZ1WwfKdoWJkE6fQ,741
11
- itam_assistant-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- itam_assistant-0.1.18.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
13
- itam_assistant-0.1.18.dist-info/RECORD,,
10
+ itam_assistant-0.1.19.dist-info/METADATA,sha256=FSdyAhBvXS1kNV_ejjHJFdAJOfRq8Qu-wkqkOlfcmzU,730
11
+ itam_assistant-0.1.19.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
12
+ itam_assistant-0.1.19.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
13
+ itam_assistant-0.1.19.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5