itam-assistant 0.1.7__py3-none-any.whl → 0.1.9__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
@@ -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(2)
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(2)
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(2)
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 技能分发 用户输入
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: itam-assistant
3
- Version: 0.1.7
1
+ Metadata-Version: 2.4
2
+ Name: itam_assistant
3
+ Version: 0.1.9
4
4
  Summary: 优化版本--技能分发的结果展示
5
5
  Home-page: https://github.com/liujunmeiD/itam_assistant
6
6
  Author: liujunmeiD
@@ -10,7 +10,16 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
- Requires-Dist: requests >=2.25.1
14
- Requires-Dist: numpy >=1.20.0
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
15
24
 
16
25
  详见https://bytedance.feishu.cn/docs/doccnSOL0o2qtnElftgd2rir2Dc
@@ -0,0 +1,13 @@
1
+ itam_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ itam_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
3
+ itam_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
4
+ itam_assistant/do_ai.py,sha256=IKOBImjDkwkNsXGxOquL_orrLpVg90vkstEIzzeod6o,42941
5
+ itam_assistant/intent_detail.py,sha256=hmEj1KpcuKNvsoBZmn5PnbsBIIx6XGmQBJWdW_ICFmg,16831
6
+ itam_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
7
+ itam_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
8
+ itam_assistant/openapi.py,sha256=-YMx-Feu1dHkQ86EB1-QmQZJHS4dND3sNSnIpBF94w4,37730
9
+ itam_assistant/test.py,sha256=qGSihMYmtZkz_vifwEOz579f_wPBJAx5_rz1sABUyo4,581
10
+ itam_assistant-0.1.9.dist-info/METADATA,sha256=66dNY6_eiKoUfVljLlpjoMUVKhkouzZnNlM2e64Px-A,751
11
+ itam_assistant-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ itam_assistant-0.1.9.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
13
+ itam_assistant-0.1.9.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
 
it_assistant/__init__.py DELETED
File without changes
@@ -1,129 +0,0 @@
1
- import json
2
-
3
- import lark_oapi as lark
4
- from lark_oapi.api.auth.v3 import *
5
- from lark_oapi.api.aily.v1 import *
6
-
7
-
8
- # SDK 使用说明: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
9
- # 以下示例代码默认根据文档示例值填充,如果存在代码问题,请在 API 调试台填上相关必要参数后再复制代码使用
10
- # 复制该 Demo 后, 需要将 "YOUR_APP_ID", "YOUR_APP_SECRET" 替换为自己应用的 APP_ID, APP_SECRET.
11
-
12
- pre =['spring_f17d05d924__c']
13
-
14
-
15
- class AilyLarkClient():
16
- def __init__(self,clientinfo):
17
- """
18
- 初始化 Client 实例,tenant_access_token 会在 Client 初始化时自动获取
19
- """
20
- self.aily_app_id = clientinfo.get("aily_app_id") or "spring_f17d05d924__c"
21
- self.app_id = clientinfo.get("app_id") or "cli_a6e3aea1a13c900c"
22
- self.app_secret = clientinfo.get("app_secret") or "J0fAPt3BL6bv4KUJV0dJMdTUdr0pv3xx"
23
- # 创建 Lark-tenant tenant客户端
24
- self.tlark_client = lark.Client.builder().app_id(self.app_id).app_secret(self.app_secret).build()
25
-
26
- # 创建 Lark-tenant user 客户端
27
- self.ulark_client = lark.Client.builder().enable_set_token(True).log_level(lark.LogLevel.DEBUG).build()
28
-
29
- def get_tenant_access_token(self):
30
- # 构造请求对象
31
- request: InternalTenantAccessTokenRequest = InternalTenantAccessTokenRequest.builder() \
32
- .request_body(InternalTenantAccessTokenRequestBody.builder()
33
- .app_id(self.app_id)
34
- .app_secret(self.app_secret)
35
- .build()) \
36
- .build()
37
-
38
- # 发起请求
39
- response: InternalTenantAccessTokenResponse = self.tlark_client.auth.v3.tenant_access_token.internal(request)
40
-
41
- # 处理失败返回
42
- if not response.success():
43
- lark.logger.error(
44
- f"client.auth.v3.tenant_access_token.internal failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}")
45
- return
46
- # 处理业务结果
47
- lark.logger.info(lark.JSON.marshal(response.raw, indent=4))
48
- tenant_access_token = json.loads(response.raw.content).get("tenant_access_token")
49
- if tenant_access_token:
50
- return tenant_access_token
51
- else:
52
- lark.logger.error(
53
- f"client.auth.v3.tenant_access_token.internal failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}")
54
- return
55
-
56
- def create_ailysession(self, access_token):
57
- # 创建会话
58
- # 构造请求对象
59
- request: CreateAilySessionRequest = CreateAilySessionRequest.builder() \
60
- .request_body(CreateAilySessionRequestBody.builder()
61
- .channel_context("{}")
62
- .metadata("{}")
63
- .build()) \
64
- .build()
65
-
66
- # 发起请求
67
- option = lark.RequestOption.builder().user_access_token(access_token).build()
68
- response: CreateAilySessionResponse = self.ulark_client.aily.v1.aily_session.create(request, option)
69
-
70
- # 处理失败返回
71
- if not response.success():
72
- lark.logger.error(
73
- f"client.aily.v1.aily_session.create failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}")
74
- return
75
-
76
- # 处理业务结果
77
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
78
- return response.data.session.id
79
-
80
- def create_ailysessionaily_message(self, access_token, session_id, content):
81
- # 发送智能伙伴消息
82
- # 构造请求对象
83
- request: CreateAilySessionAilyMessageRequest = CreateAilySessionAilyMessageRequest.builder() \
84
- .aily_session_id(session_id) \
85
- .request_body(CreateAilySessionAilyMessageRequestBody.builder()
86
- .content(content)
87
- .content_type("MDX")
88
- .idempotent_id("idempotent_id_1")
89
- .build()) \
90
- .build()
91
- # 发起请求
92
- option = lark.RequestOption.builder().user_access_token(access_token).build()
93
- response: CreateAilySessionAilyMessageResponse = self.ulark_client.aily.v1.aily_session_aily_message.create(
94
- request,
95
- option)
96
- # 处理失败返回
97
- if not response.success():
98
- lark.logger.error(
99
- f"client.aily.v1.aily_session_aily_message.create failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}")
100
- return
101
- # 处理业务结果
102
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
103
- return response.data.message.id
104
-
105
- def create_ailysession_run(self, access_token, aily_session_id):
106
- # 创建运行
107
- # 构造请求对象
108
- request: CreateAilySessionRunRequest = CreateAilySessionRunRequest.builder() \
109
- .aily_session_id(aily_session_id) \
110
- .request_body(CreateAilySessionRunRequestBody.builder()
111
- .app_id(self.aily_app_id)
112
- .build()) \
113
- .build()
114
- # 发起请求
115
- option = lark.RequestOption.builder().user_access_token(
116
- access_token).build()
117
- response: CreateAilySessionRunResponse = self.ulark_client.aily.v1.aily_session_run.create(request, option)
118
- # 处理失败返回
119
- if not response.success():
120
- lark.logger.error(
121
- f"client.aily.v1.aily_session_run.create failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}")
122
- return
123
-
124
- # 处理业务结果
125
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
126
-
127
-
128
- if __name__ == '__main__':
129
- aily_app_id = AilyLarkClient({}).get_tenant_access_token()
it_assistant/config.py DELETED
@@ -1,51 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #初始化 表单数据
3
-
4
- Clientin = {
5
- "aily_app_id": "spring_f17d05d924__c",
6
- "app_id": "cli_a6e3aea1a13c900c",
7
- "app_secret": "J0fAPt3BL6bv4KUJV0dJMdTUdr0pv3xx",
8
- "cookie": "X-Kunlun-SessionId=L%3A3b34958803f34f43a52c.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2YWwiOnsidGVuYW50X2lkIjozOTAsInVzZXJfaWQiOjE3MjIxNjYwNzMxOTk2NDUsInRlbmFudF9kb21haW5fbmFtZSI6ImFwYWFzIiwic2Vzc2lvbl92ZXJzaW9uIjoidjIwMjAtMDUtMTkiLCJ3c190b2tlbiI6Ilc6OTk3Y2MwNTA3OTRlNGFmYWFkYzEiLCJsb2dpbl90b2tlbiI6IjE3MDE3ZmFlMWJlNjVlMzdzSzBhMzA0ZjY0N2MyZmFjY2QwSjRFYmNmNGVjNzAzZDgwOWYxNDVnNDY0MzY1ZjEyNWI0YmZlZDhhTmMiLCJzb3VyY2VfY2hhbm5lbCI6ImZlaXNodSIsInRlbmFudF9rZXkiOiI3MzY1ODhjOTI2MGYxNzVkIiwiZXh0ZXJuYWxfZG9tYWluX25hbWUiOiJieXRlZGFuY2UiLCJvcmlnaW5hbF90ZW5hbnRfaWQiOjAsIm9yaWdpbmFsX3VzZXJfaWQiOjAsImlkcF9jaGFubmVsIjoiIn0sImV4cCI6MTc1ODk0MTY3MH0.l9yn5zbWFhOEJml5iA69TpFwZ7qgLMzj7L0cj4Ryozc; passport_web_did=7487801556726579201; passport_trace_id=7487801556748156956; QXV0aHpDb250ZXh0=2f506053fdd544e7aa0df84c66a287f9; locale=zh-CN; landing_url=https://accounts.feishu.cn/accounts/page/login?app_id=107&no_trap=1&redirect_uri=https%3A%2F%2Fapaas.feishu.cn%2Fai%2Fspring_f17d05d924__c%2Fmanagement%2Fchat-log; _gcl_au=1.1.1249684330.1743389657; s_v_web_id=verify_m8wh6ssk_JRUTLUkb_AJsu_4Xjm_ANzV_gLPDip941iqw; __tea__ug__uid=7487801495396992562; _ga=GA1.2.1834362348.1743389657; _gid=GA1.2.758422620.1743389658; session=XN0YXJ0-4e7g6c2c-da65-4492-a6f6-6413002bd949-WVuZA; session_list=XN0YXJ0-4e7g6c2c-da65-4492-a6f6-6413002bd949-WVuZA; login_recently=1; _ga_VPYRHN104D=GS1.1.1743389657.1.1.1743389669.48.0.0; msToken=4W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c3ce04c251a5a20d70",
9
- "x-kunlun-token": "17017fae1be65e37sK0a304f647c2faccd0J4Ebcf4ec703d809f145g464365f125b4bfed8aNc",
10
- "x-tt-env": "ppe_cn_env_self_test_feat_cr_a",
11
- "Authorization": "Basic cm40cmFpdTRwenY1cGlsYTo2bWhvOXV3ZXFrOHZpbDllcXRxMHZ1YmVnc2xjeXBucg==",
12
- }
13
-
14
- class SingletonMeta(type):
15
- _instances = {}
16
-
17
- def __call__(cls, *args, **kwargs):
18
- if cls not in cls._instances:
19
- cls._instances[cls] = super().__call__(*args, **kwargs)
20
- return cls._instances[cls]
21
-
22
- class Clientassign(metaclass=SingletonMeta):
23
- """
24
- 定义一个全局变量 Client
25
- 该类为单例类,确保整个应用中只有一个实例
26
- """
27
- def __init__(self, Clientinfox):
28
-
29
- self.aily_app_id = Clientinfox.get("data_set_ailyappid") or Clientin["aily_app_id"]
30
- self.app_id = Clientinfox.get("data_set_appid") or Clientin["app_id"]
31
- self.app_secret = Clientinfox.get("data_set_appsecret") or Clientin["app_secret"]
32
- self.cookie = Clientinfox.get("data_set_cookie") or Clientin["cookie"]
33
- self.x_kunlun_token = Clientinfox.get("data_set_kunluntoken") or Clientin["x-kunlun-token"]
34
- self.x_tt_env = Clientinfox.get("data_set_ppeenv") or Clientin["x-tt-env"]
35
- self.authorization = Clientinfox.get("data_set_auth") or Clientin["Authorization"]
36
-
37
-
38
- if __name__ == '__main__':
39
- Clientinfox = {
40
- "data_set_ailyappid": "123",
41
- "data_set_appid": "456",
42
- "data_set_appsecret": "789",
43
- "data_set_cookie": "012",
44
- "data_set_kunluntoken": "345",
45
- "data_set_ppeenv": "678",
46
- "data_set_auth": "901",
47
- }
48
- b=Clientassign(Clientinfox)
49
-
50
-
51
-