oneliai 0.3.0__py3-none-any.whl → 0.4.0__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.
Potentially problematic release.
This version of oneliai might be problematic. Click here for more details.
- oneliai/client.py +44 -24
- {oneliai-0.3.0.dist-info → oneliai-0.4.0.dist-info}/METADATA +1 -1
- oneliai-0.4.0.dist-info/RECORD +8 -0
- {oneliai-0.3.0.dist-info → oneliai-0.4.0.dist-info}/top_level.txt +1 -0
- sdk/client.py +2 -0
- oneliai-0.3.0.dist-info/RECORD +0 -8
- {oneliai-0.3.0.dist-info → oneliai-0.4.0.dist-info}/WHEEL +0 -0
oneliai/client.py
CHANGED
|
@@ -121,21 +121,26 @@ class AIClient:
|
|
|
121
121
|
else:
|
|
122
122
|
raise Exception('Failed to start suggestion')
|
|
123
123
|
|
|
124
|
-
async def competitor_analysis(self,
|
|
124
|
+
async def competitor_analysis(self,missionid="",asins=[]):
|
|
125
125
|
if not missionid: # Check if missionid is empty
|
|
126
126
|
missionid = str(uuid.uuid4()) # Generate a random UUID
|
|
127
|
+
|
|
127
128
|
task_id = await self.get_competitive_data(missionid,asins)
|
|
128
|
-
|
|
129
|
+
|
|
130
|
+
# logging.info(task_id)
|
|
129
131
|
|
|
130
132
|
if task_id:
|
|
133
|
+
|
|
131
134
|
task = await self.check_task_status(task_id)
|
|
135
|
+
|
|
132
136
|
if task['status'] == "SUCCESS":
|
|
133
137
|
ret=await self.analysis_details(missionid)
|
|
134
138
|
return ret
|
|
135
139
|
|
|
140
|
+
|
|
136
141
|
async def analysis_details(self,missionid):
|
|
137
142
|
response = requests.post(
|
|
138
|
-
f'{
|
|
143
|
+
f'{URL}/v1/conv/analysis/getid',
|
|
139
144
|
json={
|
|
140
145
|
'missionid': missionid
|
|
141
146
|
|
|
@@ -145,22 +150,29 @@ class AIClient:
|
|
|
145
150
|
if response.status_code == 200:
|
|
146
151
|
return response.json()
|
|
147
152
|
else:
|
|
148
|
-
raise Exception('Failed to start
|
|
153
|
+
raise Exception('Failed to start analysis')
|
|
149
154
|
|
|
150
155
|
|
|
151
|
-
async def get_competitive_data(self,asins):
|
|
156
|
+
async def get_competitive_data(self,missionid,asins):
|
|
157
|
+
print(2)
|
|
152
158
|
response = requests.post(
|
|
153
159
|
f'{self.base_url}/competitor_analysis',
|
|
154
160
|
json={
|
|
155
|
-
"asins": asins
|
|
161
|
+
"asins": asins,
|
|
162
|
+
"missionid":missionid
|
|
156
163
|
|
|
157
164
|
},
|
|
158
165
|
headers={'Authorization': f'Bearer {self.access_token}'}
|
|
159
166
|
)
|
|
167
|
+
|
|
160
168
|
if response.status_code == 200:
|
|
161
|
-
|
|
169
|
+
|
|
170
|
+
result=response.json()
|
|
171
|
+
|
|
172
|
+
return result['data']['task_id']
|
|
162
173
|
else:
|
|
163
|
-
raise Exception('Failed to
|
|
174
|
+
raise Exception('Failed to request get_competitive_data')
|
|
175
|
+
|
|
164
176
|
|
|
165
177
|
|
|
166
178
|
#获取所有asins
|
|
@@ -184,16 +196,24 @@ class AIClient:
|
|
|
184
196
|
|
|
185
197
|
|
|
186
198
|
async def getTaskStatus(self,taskId):
|
|
187
|
-
|
|
199
|
+
print("232332")
|
|
200
|
+
data=await self.get_token()
|
|
201
|
+
print(data['token'])
|
|
202
|
+
response =requests.get(f"{URL}/v1/task/task_status/{taskId}",
|
|
203
|
+
headers={'Authorization': f"Bearer {data['token']}"})
|
|
204
|
+
print(response.json())
|
|
188
205
|
if response.status_code == 200:
|
|
189
206
|
return response.json()
|
|
190
207
|
else:
|
|
191
208
|
raise Exception('Failed to request task_status')
|
|
192
209
|
|
|
193
210
|
async def check_task_status(self,task_id):
|
|
211
|
+
print(3)
|
|
212
|
+
|
|
194
213
|
while True:
|
|
195
214
|
try:
|
|
196
|
-
|
|
215
|
+
|
|
216
|
+
response = await self.getTaskStatus(task_id)
|
|
197
217
|
logging.info(response)
|
|
198
218
|
status = response.get('status')
|
|
199
219
|
logging.info(f"Task status: {status}")
|
|
@@ -328,20 +348,20 @@ class AIClient:
|
|
|
328
348
|
raise Exception('Failed to request task_status')
|
|
329
349
|
|
|
330
350
|
|
|
331
|
-
async def check_task_status(self,task_id: str) -> dict:
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
351
|
+
# async def check_task_status(self,task_id: str) -> dict:
|
|
352
|
+
# response =requests.get(f"{URL}/task/task_status/{task_id}")
|
|
353
|
+
# if response.status_code == 200:
|
|
354
|
+
# ret= response.json()
|
|
355
|
+
# """Mock implementation - replace with actual status check"""
|
|
356
|
+
# return {
|
|
357
|
+
# "status": ret["status"],
|
|
358
|
+
# "result": {
|
|
359
|
+
# "code": 200,
|
|
360
|
+
# "missionid": ret["result"]["missionid"]
|
|
361
|
+
# }
|
|
362
|
+
# }
|
|
363
|
+
# else:
|
|
364
|
+
# raise Exception('Failed to request task_status')
|
|
345
365
|
|
|
346
366
|
async def get_token(self):
|
|
347
367
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
oneliai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
oneliai/client.py,sha256=Uqybrpr7xWouFjZPXYwOFsqTJfrioz8L9kYGTuqqEIY,14909
|
|
3
|
+
sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
sdk/client.py,sha256=EenoF_sh_EsovxqLCKfcs0_9mMV1LqC3GnysQupgL1g,4296
|
|
5
|
+
oneliai-0.4.0.dist-info/METADATA,sha256=00szTOVCSu2lDKfo51cCJh4Wh4ntFzh6Y6qRkHxCmww,155
|
|
6
|
+
oneliai-0.4.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
7
|
+
oneliai-0.4.0.dist-info/top_level.txt,sha256=7zBSOMx80pMmYiAfyZoqmb8S5_lloaTESpnFRO3KoYk,12
|
|
8
|
+
oneliai-0.4.0.dist-info/RECORD,,
|
sdk/client.py
CHANGED
oneliai-0.3.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
oneliai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
oneliai/client.py,sha256=-sjQayxFFcRd9wueMiaVb7GCkJpSWZqNT-4KpcAyBJ0,14400
|
|
3
|
-
sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
sdk/client.py,sha256=FwUhqzY2DkRTloe_XMyaaaEzg7THaIV6OxPDliMQjq0,4267
|
|
5
|
-
oneliai-0.3.0.dist-info/METADATA,sha256=J1A-JNIohocFBTrPrJJ40W3RpvuqMwHBrfF7DnaXyq0,155
|
|
6
|
-
oneliai-0.3.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
7
|
-
oneliai-0.3.0.dist-info/top_level.txt,sha256=GqjKHlaU6NsCzFm5EOy-2oJoa3YStKZAX8qonkZqB1M,8
|
|
8
|
-
oneliai-0.3.0.dist-info/RECORD,,
|
|
File without changes
|