itam-assistant 0.1.2__tar.gz → 0.1.4__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.
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/PKG-INFO +3 -3
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/ailyapp_client.py +2 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/do_ai.py +105 -34
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/intent_detail.py +4 -6
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/openapi.py +2 -2
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/itam_assistant.egg-info/PKG-INFO +3 -3
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/setup.py +3 -3
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/README.md +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/__init__.py +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/config.py +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/lark_client.py +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/logger.py +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/it_assistant/test.py +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/itam_assistant.egg-info/SOURCES.txt +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/itam_assistant.egg-info/dependency_links.txt +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/itam_assistant.egg-info/requires.txt +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/itam_assistant.egg-info/top_level.txt +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/setup.cfg +0 -0
- {itam_assistant-0.1.2 → itam_assistant-0.1.4}/test/test.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itam_assistant
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
5
|
-
Home-page: https://github.com/liujunmeiD/
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: 优化版本
|
|
5
|
+
Home-page: https://github.com/liujunmeiD/itam_assistant
|
|
6
6
|
Author: liujunmeiD
|
|
7
7
|
Author-email: 1105030421@qq.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -9,6 +9,8 @@ from lark_oapi.api.aily.v1 import *
|
|
|
9
9
|
# 以下示例代码默认根据文档示例值填充,如果存在代码问题,请在 API 调试台填上相关必要参数后再复制代码使用
|
|
10
10
|
# 复制该 Demo 后, 需要将 "YOUR_APP_ID", "YOUR_APP_SECRET" 替换为自己应用的 APP_ID, APP_SECRET.
|
|
11
11
|
|
|
12
|
+
pre =['spring_f17d05d924__c']
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
class AilyLarkClient():
|
|
14
16
|
def __init__(self,clientinfo):
|
|
@@ -81,15 +81,18 @@ def do_ai_auto(Testk_data, clientinfo):
|
|
|
81
81
|
startAt = int(time.time())
|
|
82
82
|
# 创建会话
|
|
83
83
|
seseion_id = AilyLarkClient(clientinfo).create_ailysession(tenant_access_token)
|
|
84
|
+
time.sleep(10)
|
|
84
85
|
if not seseion_id:
|
|
85
86
|
raise ValueError("未能成功创建会话")
|
|
86
87
|
# 创建消息
|
|
87
88
|
message_id = AilyLarkClient(clientinfo).create_ailysessionaily_message(tenant_access_token, seseion_id,
|
|
88
89
|
aa)
|
|
90
|
+
time.sleep(5)
|
|
89
91
|
if not message_id:
|
|
90
92
|
raise ValueError("未能成功创建消息")
|
|
91
93
|
# 创建运行实例
|
|
92
94
|
runs = AilyLarkClient(clientinfo).create_ailysession_run(tenant_access_token, seseion_id)
|
|
95
|
+
time.sleep(5)
|
|
93
96
|
num = num + 1
|
|
94
97
|
return startAt, num
|
|
95
98
|
except KeyError as ke:
|
|
@@ -137,22 +140,15 @@ def do_waterlevellineres_list(res, info):
|
|
|
137
140
|
info['rt'] = False
|
|
138
141
|
return info
|
|
139
142
|
|
|
140
|
-
|
|
141
143
|
# 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
|
|
142
144
|
if res["body"]["Results"]:
|
|
145
|
+
info['output']['用户输入/output']='log_id:'+res['log_id']
|
|
143
146
|
# 取["Results"]下前2个结果,若只有1个结果,label1为空
|
|
144
|
-
if len(res["body"]["Results"]) >
|
|
145
|
-
|
|
146
|
-
{'label': res["body"]["Results"][
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
'score': res["body"]["Results"][1]['Score']}]
|
|
150
|
-
|
|
151
|
-
else:
|
|
152
|
-
info['label'] = [
|
|
153
|
-
{'label': res["body"]["Results"][0]['Item']['name_zh'],
|
|
154
|
-
'score': res["body"]["Results"][0]['Score']},
|
|
155
|
-
{'label': '', 'score': 0}]
|
|
147
|
+
if len(res["body"]["Results"]) > 0:
|
|
148
|
+
for j in range(len(res["body"]["Results"])):
|
|
149
|
+
aaa = {'label': res["body"]["Results"][j]['Item']['name_zh']+"&"+res["body"]["Results"][j]['Item']['brand_zh']+"&"+res["body"]["Results"][j]['Item']['model_zh']+"&"+res["body"]["Results"][j]['Item']['specification_zh'],
|
|
150
|
+
'score': res["body"]["Results"][j]['Score']}
|
|
151
|
+
info['label'].append(copy.deepcopy(aaa))
|
|
156
152
|
# 判断label0和label1是否为空,为空则:label默认2级
|
|
157
153
|
# 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
|
|
158
154
|
if info['exp'][0]['label'] == info['label'][0]['label'] and info['exp'][1]['label'] == info['label'][1][
|
|
@@ -168,6 +164,38 @@ def do_waterlevellineres_list(res, info):
|
|
|
168
164
|
|
|
169
165
|
return info
|
|
170
166
|
|
|
167
|
+
def do_waterlevellineres_listv2(res, info):
|
|
168
|
+
"""
|
|
169
|
+
获取结果,并组装水位线info
|
|
170
|
+
"""
|
|
171
|
+
if res == '':
|
|
172
|
+
info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
|
|
173
|
+
info['rt'] = False
|
|
174
|
+
return info
|
|
175
|
+
reslist = res["body"]["Results"]
|
|
176
|
+
info['output']['用户输入/output'] = 'log_id:' + res.get('log_id') or res.get('requestId')
|
|
177
|
+
if reslist:
|
|
178
|
+
#取所有结果并追加到info['label']
|
|
179
|
+
info['label'] = []
|
|
180
|
+
if len(reslist) > 0:
|
|
181
|
+
for j in range(len(reslist)):
|
|
182
|
+
aaa = {'label': reslist[j]['Item']['name_zh'],
|
|
183
|
+
'score': reslist[j]['Score'],
|
|
184
|
+
'info':reslist[j]['Item']['name_zh']+"&"+reslist[j]['Item']['brand_zh']+"&"+reslist[j]['Item']['model_zh']+"&"+reslist[j]['Item']['specification_zh'],}
|
|
185
|
+
info['label'].append(copy.deepcopy(aaa))
|
|
186
|
+
# 判断exp和label是否一致,一致则:rt=True,不一致则:rt=False
|
|
187
|
+
for a in range(len(info['exp'])):
|
|
188
|
+
if info['exp'][a]['label']== info['label'][a]['label']:
|
|
189
|
+
info['rt'] = True
|
|
190
|
+
else:
|
|
191
|
+
info['rt'] = False
|
|
192
|
+
break
|
|
193
|
+
else:
|
|
194
|
+
info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
|
|
195
|
+
info['rt'] = False
|
|
196
|
+
|
|
197
|
+
return info
|
|
198
|
+
|
|
171
199
|
def do_waterlevellineres_listassetspu(res, info,hardtype):
|
|
172
200
|
"""
|
|
173
201
|
获取结果,并组装水位线info
|
|
@@ -179,10 +207,11 @@ def do_waterlevellineres_listassetspu(res, info,hardtype):
|
|
|
179
207
|
if res["data"].get("AiBorrowAndUseResponseList") == None:
|
|
180
208
|
info['label'] = [{'label': '', 'score': 0},{'label': '', 'score': 0.8}]
|
|
181
209
|
info['rt'] = False
|
|
182
|
-
if info['exp'][
|
|
210
|
+
if info['exp']==[]:
|
|
183
211
|
info['rt'] = True
|
|
184
212
|
return info
|
|
185
213
|
reslist=res["data"]["AiBorrowAndUseResponseList"]
|
|
214
|
+
info['output']['用户输入/output']='requestId:'+res['requestId']
|
|
186
215
|
aaa ={}
|
|
187
216
|
# 判断res["body"]["Results"]不为空,空则:label0 label1 为空,label默认2级
|
|
188
217
|
if reslist:
|
|
@@ -198,12 +227,12 @@ def do_waterlevellineres_listassetspu(res, info,hardtype):
|
|
|
198
227
|
'score': reslist[j]['Score']}
|
|
199
228
|
info['label'].append(copy.deepcopy(aaa))
|
|
200
229
|
# 判断label0和label1是否为空,为空则:label默认2级
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
230
|
+
for a in range(len(info['exp'])):
|
|
231
|
+
if info['exp'][a]['label'] == info['label'][a]['label']:
|
|
232
|
+
info['rt'] = True
|
|
233
|
+
else:
|
|
234
|
+
info['rt'] = False
|
|
235
|
+
break
|
|
207
236
|
else:
|
|
208
237
|
info['label'] = info['label'] = [{'label': '', 'score': 0}, {'label': '', 'score': 0}]
|
|
209
238
|
info['rt'] = False
|
|
@@ -401,25 +430,60 @@ def do_waterlevelline_autotest(collections, clientinfo, score_threshold):
|
|
|
401
430
|
for i in collections:
|
|
402
431
|
info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
|
|
403
432
|
info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
|
|
404
|
-
info['exp'] = [
|
|
405
|
-
|
|
406
|
-
|
|
433
|
+
info['exp'] = []
|
|
434
|
+
for j in [i['ext']['BPO标注-AP-资产型号'], i['ext'].get('BPO标注-AP-资产型号1'),i['ext'].get('BPO标注-AP-资产型号2'),i['ext'].get('BPO标注-AP-资产型号3'),i['ext'].get('BPO标注-AP-资产型号4'),i['ext'].get('BPO标注-AP-资产型号5'),i['ext'].get('BPO标注-AP-资产型号6'),i['ext'].get('BPO标注-AP-资产型号7'),i['ext'].get('BPO标注-AP-资产型号8'),i['ext'].get('BPO标注-AP-资产型号9'),i['ext'].get('BPO标注-AP-资产型号10')]:
|
|
435
|
+
if j:
|
|
436
|
+
info['exp'].append({'label': j, 'score': score_threshold})
|
|
437
|
+
#判断i['ext']['BPO标注-AP-资产型号']是否为空,为空就不用读取,不为空就读取
|
|
438
|
+
if i['ext']['BPO标注-AP-资产型号']:
|
|
439
|
+
asset_name = i['ext']['BPO标注-AP-资产名称']
|
|
440
|
+
try:
|
|
441
|
+
if isinstance(asset_name, str):
|
|
442
|
+
asset_name = json.loads(asset_name)
|
|
443
|
+
except json.JSONDecodeError:
|
|
444
|
+
# 若解析失败,说明不是 JSON 格式,保持原样
|
|
445
|
+
pass
|
|
407
446
|
info['artificial'] = info['exp']
|
|
408
447
|
if i['ext']['BPO标注-AP-资产名称']:
|
|
448
|
+
asset_name = i['ext']['BPO标注-AP-资产名称']
|
|
449
|
+
try:
|
|
450
|
+
if isinstance(asset_name, str):
|
|
451
|
+
asset_name = json.loads(asset_name)
|
|
452
|
+
except json.JSONDecodeError:
|
|
453
|
+
# 若解析失败,说明不是 JSON 格式,保持原样
|
|
454
|
+
pass
|
|
409
455
|
if "软件申请" in i['ext']['BPO标注-AP-分发技能']:
|
|
410
|
-
keywprd = software_asset_sku_structure(
|
|
456
|
+
keywprd = software_asset_sku_structure(asset_name)
|
|
411
457
|
res = json.loads(get_query_vector(keywprd, clientinfo))
|
|
412
458
|
if "设备/配件申请" in i['ext']['BPO标注-AP-分发技能']:
|
|
413
|
-
keywprd = equipmentrequest_structure(
|
|
414
|
-
|
|
415
|
-
|
|
459
|
+
#keywprd = equipmentrequest_structure(asset_name, i['ext']['asset_type'])
|
|
460
|
+
keywprd = {
|
|
461
|
+
"From": 0,
|
|
462
|
+
"Size": 10,
|
|
463
|
+
"MinScore": 0.7,
|
|
464
|
+
"AssetModelFieldsWithAnd": [
|
|
465
|
+
{
|
|
466
|
+
"FieldName": "vec_search",
|
|
467
|
+
"FieldType": "knn",
|
|
468
|
+
"QueryValue": [
|
|
469
|
+
asset_name
|
|
470
|
+
]
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
"SPUIDs": None,
|
|
474
|
+
"AssetModelBizTypes": [
|
|
475
|
+
"asset_sku"
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
res = json.loads(get_query_vector(keywprd, clientinfo))
|
|
479
|
+
#res = get_by_AssetModelBizTypes(keywprd,res0)
|
|
416
480
|
if "设备/配件退还" in i['ext']['BPO标注-AP-分发技能']:
|
|
417
|
-
keywprd = equipmentreturn_structure0(
|
|
481
|
+
keywprd = equipmentreturn_structure0(asset_name, i['ext']['asset_type'])
|
|
418
482
|
res0 = json.loads(get_query_vector(keywprd, clientinfo))
|
|
419
483
|
res = get_by_AssetModelBizTypes(keywprd, res0)
|
|
420
484
|
else:
|
|
421
485
|
res = ""
|
|
422
|
-
infoout =
|
|
486
|
+
infoout = do_waterlevellineres_listv2(res, info)
|
|
423
487
|
info_list.append(copy.deepcopy(infoout))
|
|
424
488
|
a = a+1
|
|
425
489
|
print("这是"+str(a))
|
|
@@ -449,9 +513,15 @@ def do_waterlevelline_autotest_aseetspu(collections, clientinfo, score_threshold
|
|
|
449
513
|
for i in collections:
|
|
450
514
|
info['input']['用户输入/userInput'] = i['ext']['BPO标注-AP-资产名称']
|
|
451
515
|
info['output']['用户输入/output'] = i['ext']['BPO标注-AP-资产名称']
|
|
452
|
-
info['exp'] = [
|
|
453
|
-
|
|
454
|
-
|
|
516
|
+
info['exp'] = []
|
|
517
|
+
for j in [i['ext']['BPO标注-AP-资产型号'], i['ext'].get('BPO标注-AP-资产型号1'),
|
|
518
|
+
i['ext'].get('BPO标注-AP-资产型号2'), i['ext'].get('BPO标注-AP-资产型号3'),
|
|
519
|
+
i['ext'].get('BPO标注-AP-资产型号4'), i['ext'].get('BPO标注-AP-资产型号5'),
|
|
520
|
+
i['ext'].get('BPO标注-AP-资产型号6'), i['ext'].get('BPO标注-AP-资产型号7'),
|
|
521
|
+
i['ext'].get('BPO标注-AP-资产型号8'), i['ext'].get('BPO标注-AP-资产型号9'),
|
|
522
|
+
i['ext'].get('BPO标注-AP-资产型号10')]:
|
|
523
|
+
if j:
|
|
524
|
+
info['exp'].append({'label': j, 'score': score_threshold})
|
|
455
525
|
info['artificial'] = info['exp']
|
|
456
526
|
info['label']=[]
|
|
457
527
|
if i['ext']['BPO标注-AP-资产名称']:
|
|
@@ -460,14 +530,15 @@ def do_waterlevelline_autotest_aseetspu(collections, clientinfo, score_threshold
|
|
|
460
530
|
try:
|
|
461
531
|
# 尝试将其解析为 JSON 对象
|
|
462
532
|
if isinstance(asset_name, str):
|
|
463
|
-
|
|
533
|
+
asset_name0 = json.loads(asset_name)
|
|
534
|
+
asset_name = asset_name0['asset_name']
|
|
464
535
|
except json.JSONDecodeError:
|
|
465
536
|
# 若解析失败,说明不是 JSON 格式,保持原样
|
|
466
537
|
pass
|
|
467
538
|
key = asset_name.get('asset_name') if isinstance(asset_name, dict) else asset_name
|
|
468
539
|
if i['ext']['BPO标注-AP-资产类型'] == "设备":
|
|
469
540
|
hardtype = 1
|
|
470
|
-
elif i['ext']['BPO标注-AP-资产类型'] == "配件" :
|
|
541
|
+
elif i['ext']['BPO标注-AP-资产类型'] == "配件" or i['ext']['BPO标注-AP-资产类型'] == '2.0' :
|
|
471
542
|
hardtype = 2
|
|
472
543
|
res = GetBestMatchItemonline(key,hardtype,clientinfo)
|
|
473
544
|
else:
|
|
@@ -51,14 +51,11 @@ class webapiClient():
|
|
|
51
51
|
"endAt": endAt,
|
|
52
52
|
"matchIntentID": "",
|
|
53
53
|
"matchStatus": [],
|
|
54
|
-
"pageSize": pageSize +
|
|
54
|
+
"pageSize": pageSize + 1000
|
|
55
55
|
})
|
|
56
56
|
try:
|
|
57
57
|
self.conn.request("POST","/ai/api/v1/conversational_runtime/namespaces/spring_f17d05d924__c/stats/intent_detail_list",payload, self.headers)
|
|
58
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)
|
|
61
|
-
|
|
62
59
|
# 检查响应状态码
|
|
63
60
|
if res.status != 200:
|
|
64
61
|
raise http.client.HTTPException(f"请求失败,状态码: {res.status}, 原因: {res.reason}")
|
|
@@ -74,8 +71,9 @@ class webapiClient():
|
|
|
74
71
|
raise ValueError("响应数据缺少必要的字段 'data' 或 'intentDetailList'")
|
|
75
72
|
|
|
76
73
|
res_list = []
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
data_ = data['data']['intentDetailList']
|
|
75
|
+
for i in data_:
|
|
76
|
+
if i['channelType'] in ["LARK_OPEN_API"]:
|
|
79
77
|
res_list.append({
|
|
80
78
|
'对话日志/intentID': i['intentID'],
|
|
81
79
|
'用户输入/userInput': i['userInput'],
|
|
@@ -54,10 +54,10 @@ def get_query_vector(para, clientinfo):
|
|
|
54
54
|
'Authorization': clientinfo.get(
|
|
55
55
|
"authorization") or "Basic cm40cmFpdTRwenY1cGlsYTo2bWhvOXV3ZXFrOHZpbDllcXRxMHZ1YmVnc2xjeXBucg==",
|
|
56
56
|
'x-use-ppe': '1',
|
|
57
|
-
'x-tt-env': clientinfo.get("x_tt_env") or "
|
|
57
|
+
'x-tt-env': clientinfo.get("x_tt_env") or "ppe_openapi_vector_v2",
|
|
58
58
|
'Content-Type': 'application/json'
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
time.sleep(2.1)
|
|
61
61
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
62
62
|
return response.text
|
|
63
63
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itam-assistant
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
5
|
-
Home-page: https://github.com/liujunmeiD/
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: 优化版本
|
|
5
|
+
Home-page: https://github.com/liujunmeiD/itam_assistant
|
|
6
6
|
Author: liujunmeiD
|
|
7
7
|
Author-email: 1105030421@qq.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -2,13 +2,13 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="itam_assistant", # 包名称
|
|
5
|
-
version="0.1.
|
|
5
|
+
version="0.1.4", # 版本号
|
|
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
|
-
url="https://github.com/liujunmeiD/
|
|
11
|
+
url="https://github.com/liujunmeiD/itam_assistant",
|
|
12
12
|
packages=find_packages(), # 自动发现所有包
|
|
13
13
|
install_requires=[ # 依赖项
|
|
14
14
|
"requests>=2.25.1",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|