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 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,asins,missionid=""):
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
- logging.info(task_id)
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'{self.base_url}/conv/analysis/getid',
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 suggestion')
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
- return response.json()
169
+
170
+ result=response.json()
171
+
172
+ return result['data']['task_id']
162
173
  else:
163
- raise Exception('Failed to start suggestion')
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
- response =requests.get(f"{URL}/task/task_status/{taskId}")
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
- response = await self.get_task_status(task_id)
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
- response =requests.get(f"{URL}/task/task_status/{task_id}")
333
- if response.status_code == 200:
334
- ret= response.json()
335
- """Mock implementation - replace with actual status check"""
336
- return {
337
- "status": ret["status"],
338
- "result": {
339
- "code": 200,
340
- "missionid": ret["result"]["missionid"]
341
- }
342
- }
343
- else:
344
- raise Exception('Failed to request task_status')
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oneliai
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: SDK for ONELI.AI Customer API
5
5
  Author: oneli.ai
6
6
  Requires-Python: >=3.6
@@ -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
@@ -1,4 +1,6 @@
1
1
  import requests
2
+ import jwt
3
+ import datetime
2
4
 
3
5
  # URL="https://apis.oneli.chat"
4
6
  URL="http://localhost:8085"
@@ -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,,