itam-assistant 0.1.11__py3-none-any.whl → 0.1.12__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.
it_assistant/test.py DELETED
@@ -1 +0,0 @@
1
- ["鼠标","显示器双C数据线","Type-C扩展坞","西部数据-WDBEPK0020BBK","鼠标和键盘","鼠标","鼠标","鼠标","笔记本充电器","笔记本充电器","鼠标","And crown-PTH-660/K0-F","mouse and keyboard","hdmi dongle","笔记本支架","蓝牙键盘","mac蓝牙鼠标","鼠标耳机键盘","显示器双C数据线","鼠标","鼠标","鼠标键盘","Adapter","外置硬盘","keyboard","笔记本充电器","鼠标和键盘","Type-C扩展坞","65W笔记本电源","安卓手机数据线","笔记本电源","keyboard","鼠标和键盘","SanDisk-SDSSDE81-4T00-Z25"]
@@ -1,28 +0,0 @@
1
- it_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- it_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
3
- it_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
4
- it_assistant/do_ai.py,sha256=Rs7SdXx_7DA9MQeEC9TQ-lHYZLFykETXf63-ppgrKek,41505
5
- it_assistant/intent_detail.py,sha256=hmEj1KpcuKNvsoBZmn5PnbsBIIx6XGmQBJWdW_ICFmg,16831
6
- it_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
7
- it_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
8
- it_assistant/openapi.py,sha256=-YMx-Feu1dHkQ86EB1-QmQZJHS4dND3sNSnIpBF94w4,37730
9
- it_assistant/test.py,sha256=qGSihMYmtZkz_vifwEOz579f_wPBJAx5_rz1sABUyo4,581
10
- itam_assistant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- itam_assistant/ailyapp_client.py,sha256=w-ihtcmRgOQCgWK0jB8eHGCikjo1tbre3xCiEKhLrUA,6357
12
- itam_assistant/config.py,sha256=L_5grm2ZWwg_S1JTOU6XLhQ5GPeYJaBFBLwzP2JA5Ys,5498
13
- itam_assistant/do_ai.py,sha256=0ICPD3hXJty4cQX-LxBjl6os-2oXJyO0Iej0QuyMkJw,46769
14
- itam_assistant/intent_detail.py,sha256=hmEj1KpcuKNvsoBZmn5PnbsBIIx6XGmQBJWdW_ICFmg,16831
15
- itam_assistant/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
16
- itam_assistant/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
17
- itam_assistant/openapi.py,sha256=-YMx-Feu1dHkQ86EB1-QmQZJHS4dND3sNSnIpBF94w4,37730
18
- itam_assistant/test.py,sha256=qGSihMYmtZkz_vifwEOz579f_wPBJAx5_rz1sABUyo4,581
19
- main/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- main/ailyapp_client.py,sha256=6CVlBkuiIvIzqG0lM38tdGFBNLhVi2_0jQIbHg7fpzw,6515
21
- main/do_ai.py,sha256=rxsTRdd3oBs-gsIssHz3XV-6lIC5Bq4qoyNuyQzjidg,6879
22
- main/intent_detail.py,sha256=Fo76c4BpGya-znCnKH7YAcr_2UJtbi3WPQN-PwtVsXc,18533
23
- main/lark_client.py,sha256=ZVDsdt7ucQvJN1-khC3TR-0IMeYaQXfdWF5DxRrkBH4,6665
24
- main/logger.py,sha256=W3-tbQ4J-QKSrQSpaNBruzoyMuWYrUkrIY0uBZ1o-lw,1583
25
- itam_assistant-0.1.11.dist-info/METADATA,sha256=Jo4YBzkjITrauPn5eAA5CKwqtXBIUbIP2gvSU4vpPWE,775
26
- itam_assistant-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- itam_assistant-0.1.11.dist-info/top_level.txt,sha256=KpZA4H04XBVAB3NLq0AAEOrAGEurwMnWw41AhJVqVFI,15
28
- itam_assistant-0.1.11.dist-info/RECORD,,
main/__init__.py DELETED
File without changes
main/ailyapp_client.py DELETED
@@ -1,132 +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
- class AilyLarkClient:
13
- def __init__(self):
14
- """
15
- 初始化 Client 实例,tenant_access_token 会在 Client 初始化时自动获取
16
- """
17
- self.aily_app_id = "spring_f17d05d924__c"
18
- self.app_id = "cli_a6e3aea1a13c900c"
19
- self.app_secret = "J0fAPt3BL6bv4KUJV0dJMdTUdr0pv3xx"
20
- # 创建 Lark-tenant tenant客户端
21
- self.tlark_client = lark.Client.builder().app_id(self.app_id).app_secret(self.app_secret).build()
22
-
23
- # 创建 Lark-tenant user 客户端
24
- self.ulark_client = lark.Client.builder().enable_set_token(True).log_level(lark.LogLevel.DEBUG).build()
25
-
26
- def get_tenant_access_token(self):
27
- # 构造请求对象
28
- request: InternalTenantAccessTokenRequest = InternalTenantAccessTokenRequest.builder() \
29
- .request_body(InternalTenantAccessTokenRequestBody.builder()
30
- .app_id(self.app_id)
31
- .app_secret(self.app_secret)
32
- .build()) \
33
- .build()
34
-
35
- # 发起请求
36
- response: InternalTenantAccessTokenResponse = self.tlark_client.auth.v3.tenant_access_token.internal(request)
37
-
38
- # 处理失败返回
39
- if not response.success():
40
- lark.logger.error(
41
- 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)}")
42
- return
43
- # 处理业务结果
44
- lark.logger.info(lark.JSON.marshal(response.raw, indent=4))
45
- tenant_access_token = json.loads(response.raw.content).get("tenant_access_token")
46
- if tenant_access_token:
47
- return tenant_access_token
48
- else:
49
- lark.logger.error(
50
- 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)}")
51
- return
52
-
53
- def create_ailysession(self, access_token):
54
- # 创建会话
55
- # 构造请求对象
56
- request: CreateAilySessionRequest = CreateAilySessionRequest.builder() \
57
- .request_body(CreateAilySessionRequestBody.builder()
58
- .channel_context("{}")
59
- .metadata("{}")
60
- .build()) \
61
- .build()
62
-
63
- # 发起请求
64
- option = lark.RequestOption.builder().user_access_token(access_token).build()
65
- response: CreateAilySessionResponse = self.ulark_client.aily.v1.aily_session.create(request, option)
66
-
67
- # 处理失败返回
68
- if not response.success():
69
- lark.logger.error(
70
- 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)}")
71
- return
72
-
73
- # 处理业务结果
74
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
75
- return response.data.session.id
76
-
77
- def create_ailysessionaily_message(self, access_token, session_id, content):
78
- # 发送智能伙伴消息
79
- # 构造请求对象
80
- request: CreateAilySessionAilyMessageRequest = CreateAilySessionAilyMessageRequest.builder() \
81
- .aily_session_id(session_id) \
82
- .request_body(CreateAilySessionAilyMessageRequestBody.builder()
83
- .content(content)
84
- .content_type("MDX")
85
- .idempotent_id("idempotent_id_1")
86
- .build()) \
87
- .build()
88
- # 发起请求
89
- option = lark.RequestOption.builder().user_access_token(access_token).build()
90
- response: CreateAilySessionAilyMessageResponse = self.ulark_client.aily.v1.aily_session_aily_message.create(
91
- request,
92
- option)
93
- # 处理失败返回
94
- if not response.success():
95
- lark.logger.error(
96
- 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)}")
97
- return
98
- # 处理业务结果
99
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
100
- return response.data.message.id
101
-
102
- def create_ailysession_run(self, access_token, aily_session_id):
103
- # 创建运行
104
- # 构造请求对象
105
- request: CreateAilySessionRunRequest = CreateAilySessionRunRequest.builder() \
106
- .aily_session_id(aily_session_id) \
107
- .request_body(CreateAilySessionRunRequestBody.builder()
108
- .app_id(self.aily_app_id)
109
- .build()) \
110
- .build()
111
- # 发起请求
112
- option = lark.RequestOption.builder().user_access_token(
113
- access_token).build()
114
- response: CreateAilySessionRunResponse = self.ulark_client.aily.v1.aily_session_run.create(request, option)
115
- # 处理失败返回
116
- if not response.success():
117
- lark.logger.error(
118
- 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)}")
119
- return
120
-
121
- # 处理业务结果
122
- lark.logger.info(lark.JSON.marshal(response.data, indent=4))
123
-
124
-
125
-
126
- if __name__ == '__main__':
127
- tenant_access_token = AilyLarkClient().get_tenant_access_token()
128
- seseion_id = AilyLarkClient().create_ailysession(tenant_access_token)
129
- print(seseion_id)
130
- message_id = AilyLarkClient().create_ailysessionaily_message(tenant_access_token, seseion_id, "你好")
131
- runs = AilyLarkClient().create_ailysession_run(tenant_access_token, seseion_id)
132
-
main/do_ai.py DELETED
@@ -1,177 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- from itam_assistant1.ailyapp_client import AilyLarkClient
4
- from itam_assistant1.lark_client import LarkdocsClient
5
- from itam_assistant1.intent_detail import *
6
- import datetime
7
-
8
-
9
- # Testsuitelink = "https://bytedance.larkoffice.com/sheets/ZVzfsw4rMhkMF6tjtxmc4BdSnMb"
10
-
11
-
12
-
13
- def do_ai_auto(Testsuitelink):
14
- """
15
- 自动化执行AI测试用例
16
- """
17
- startAt = 0
18
- try:
19
- # 获取租户访问令牌
20
- tenant_access_token = AilyLarkClient().get_tenant_access_token()
21
- if not tenant_access_token:
22
- raise ValueError("未能获取到有效的租户访问令牌")
23
- # 通过文档链接获取spreadsheet_token
24
- spreadsheet_token = Testsuitelink.split("/")[-1]
25
- if not spreadsheet_token:
26
- raise ValueError("未能从文档链接中提取到有效的spreadsheet_token")
27
- # 读取表格用户输入
28
- spreadsheet = LarkdocsClient().get_the_worksheet(spreadsheet_token)
29
- if not spreadsheet:
30
- raise ValueError("未能获取到有效的工作表数据")
31
- for i in spreadsheet.sheets:
32
- column_count = i.grid_properties.column_count
33
- row_count = i.grid_properties.row_count
34
- sheet_id = i.sheet_id
35
- title = i.title
36
- if title == "测试集":
37
- # 构建JSON字符串
38
- json_str = {"ranges": [sheet_id + "!A1:A" + str(row_count)]}
39
- # 获取纯文本内容
40
- test = LarkdocsClient().get_plaintextcontent(json_str, spreadsheet_token, sheet_id)
41
- test = json.loads(test)
42
- userinput = test['data']['value_ranges'][0]['values']
43
- print(f"表头为{userinput[0]}")
44
- for i in range(1, row_count):
45
- if userinput[i][0]:
46
- if startAt == 0:
47
- startAt = int(time.time())
48
- # 创建会话
49
- seseion_id = AilyLarkClient().create_ailysession(tenant_access_token)
50
- if not seseion_id:
51
- raise ValueError("未能成功创建会话")
52
- # 创建消息
53
- message_id = AilyLarkClient().create_ailysessionaily_message(tenant_access_token, seseion_id,
54
- userinput[i][0])
55
- if not message_id:
56
- raise ValueError("未能成功创建消息")
57
- # 创建运行实例
58
- runs = AilyLarkClient().create_ailysession_run(tenant_access_token, seseion_id)
59
- #可不需等待运行实例创建完成
60
- #if not runs:
61
- # raise ValueError("未能成功创建运行实例")
62
- time.sleep(1)
63
- else:
64
- return startAt, i
65
- break
66
- return startAt, row_count
67
- break
68
- except KeyError as ke:
69
- print(f"KeyError 发生: 数据中缺少必要的键,错误详情: {ke}")
70
- return None, None
71
- except json.JSONDecodeError as jde:
72
- print(f"JSON 解析错误: {jde}")
73
- return None, None
74
- except ValueError as ve:
75
- print(f"值错误: {ve}")
76
- return None, None
77
- except Exception as e:
78
- print(f"发生未知错误: {e}")
79
- return None, None
80
-
81
-
82
- def get_conversationlogs1(startAt):
83
- """
84
- 对话ID 技能分发 用户输入
85
- res_data = {
86
- 'intentID': 7485259579248705537,
87
- 'skillLabels': ["GUI 设备/配件申请"],
88
- 'userInput': "我要申请一个鼠标",
89
-
90
- }
91
- """
92
- data = webapiClient().get_intent_detail_list(startAt)
93
-
94
-
95
- def get_conversationlogs(startAt, pageSize=10):
96
- """
97
- 对话ID 技能分发 用户输入
98
- res_data = {
99
- 'intentID': 7485259579248705537,
100
- 'skillLabels': ["GUI 设备/配件申请"],
101
- 'userInput': "我要申请一个鼠标",
102
-
103
- }
104
- """
105
- try:
106
- # 之前提到形参 'pageSize' 未填,这里假设默认值为 10,你可按需修改
107
- data = webapiClient().get_intent_detail_list(startAt, pageSize=10)
108
- return data
109
- except KeyError as ke:
110
- print(f"KeyError 发生: 数据中缺少必要的键,错误详情: {ke}")
111
- return None
112
- except IndexError as ie:
113
- print(f"IndexError 发生: 索引超出范围,错误详情: {ie}")
114
- return None
115
- except Exception as e:
116
- print(f"发生未知错误: {e}")
117
- return None
118
-
119
-
120
- def write_reslut(data, Testsuitelink, title):
121
- """
122
- 写入表格
123
- """
124
- try:
125
- # 解析 spreadsheet_token
126
- spreadsheet_token = Testsuitelink.split("/")[-1]
127
-
128
- # 生成新工作表名称
129
- new_sheet_title = f"{title}{datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S')}"
130
- sheetinfo = {"index": 0, "title": new_sheet_title}
131
-
132
- # 创建新工作表
133
- spreadsheet0 = LarkdocsClient().createsheets(spreadsheet_token, sheetinfo)
134
- sheet_id = spreadsheet0['sheet_id']
135
-
136
- # 准备表头数据
137
- headers = list(data[0].keys())
138
- header_data = [
139
- {
140
- "range": f"{sheet_id}!{chr(ord('A') + col)}1:{chr(ord('A') + col)}1",
141
- "values": [[[{"text": {"text": header}, "type": "text"}]]]
142
- }
143
- for col, header in enumerate(headers)
144
- ]
145
-
146
- # 写入表头
147
- LarkdocsClient().writesheets(spreadsheet_token, sheet_id, {"value_ranges": header_data})
148
-
149
- # 写入数据
150
- for row, row_data in enumerate(data, start=1):
151
- row_values = [
152
- {
153
- "range": f"{sheet_id}!{chr(ord('A') + col)}{row + 1}:{chr(ord('A') + col)}{row + 1}",
154
- "values": [[[{"text": {"text": str(row_data[header])}, "type": "text"}]]]
155
- }
156
- for col, header in enumerate(headers)
157
- ]
158
- LarkdocsClient().writesheets(spreadsheet_token, sheet_id, {"value_ranges": row_values})
159
-
160
- return True
161
- except KeyError as ke:
162
- print(f"KeyError 发生: 数据中缺少必要的键,错误详情: {ke}")
163
- return False
164
- except IndexError as ie:
165
- print(f"IndexError 发生: 索引超出范围,错误详情: {ie}")
166
- return False
167
- except Exception as e:
168
- print(f"发生未知错误: {e}")
169
- return False
170
-
171
-
172
- if __name__ == '__main__':
173
- Testsuitelink = "https://bytedance.larkoffice.com/sheets/ZVzfsw4rMhkMF6tjtxmc4BdSnMb"
174
- startAt, num = do_ai_auto(Testsuitelink)
175
- data = webapiClient().get_intent_detail_list(startAt, num)
176
- data_qqq = webapiClient().get_intent_detail_llm(data)
177
- aaaa = write_reslut(data_qqq, Testsuitelink, "测试")