simplex 1.2.14__tar.gz → 1.2.17__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.

Potentially problematic release.


This version of simplex might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.14
3
+ Version: 1.2.17
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="simplex",
5
- version="1.2.14",
5
+ version="1.2.17",
6
6
  packages=find_packages(),
7
7
  package_data={
8
8
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -62,7 +62,7 @@ def login(website):
62
62
  website = 'https://' + website
63
63
 
64
64
  animated_print(f"[SIMPLEX] Creating login session for {website}")
65
- result = simplex.capture_login_session(website)
65
+ result = simplex.create_login_session(website)
66
66
 
67
67
  if result.get('succeeded'):
68
68
  # Open the login URL in a new browser tab
@@ -20,7 +20,10 @@ class Simplex:
20
20
  data={'session_id': self.session_id}
21
21
  )
22
22
  self.session_id = None
23
- return response.json()
23
+ if response["succeeded"]:
24
+ return
25
+ else:
26
+ raise ValueError(f"Failed to close session: {response['error']}")
24
27
 
25
28
  def create_session(self, show_in_console: bool = True):
26
29
  response = requests.post(
@@ -29,15 +32,16 @@ class Simplex:
29
32
  'x-api-key': self.api_key
30
33
  }
31
34
  )
32
-
33
35
  response_json = response.json()
36
+ if 'session_id' not in response_json:
37
+ raise ValueError(f"It looks like the session wasn't created successfully. Did you set your api_key when creating the Simplex class?")
34
38
  self.session_id = response_json['session_id']
35
39
  livestream_url = response_json['livestream_url']
36
40
 
37
41
  if show_in_console:
38
42
  print(f"Livestream URL: {livestream_url}")
39
43
 
40
- return self.session_id, livestream_url
44
+ return livestream_url
41
45
 
42
46
  def goto(self, url: str, cdp_url: str = None):
43
47
  if not cdp_url and not self.session_id:
@@ -60,7 +64,10 @@ class Simplex:
60
64
  },
61
65
  data=data
62
66
  )
63
- return response.json()
67
+ if response.json()["succeeded"]:
68
+ return
69
+ else:
70
+ raise ValueError(f"Failed to goto url: {response.json()['error']}")
64
71
 
65
72
  def click(self, element_description: str, cdp_url: str = None, use_vision: bool = False):
66
73
  if not cdp_url and not self.session_id:
@@ -83,7 +90,10 @@ class Simplex:
83
90
  },
84
91
  data=data
85
92
  )
86
- return response.json()
93
+ if response.json()["succeeded"]:
94
+ return response.json()["element_clicked"]
95
+ else:
96
+ raise ValueError(f"Failed to click element: {response.json()['error']}")
87
97
 
88
98
  def type(self, text: str, cdp_url: str = None):
89
99
  if not cdp_url and not self.session_id:
@@ -103,7 +113,10 @@ class Simplex:
103
113
  },
104
114
  data=data
105
115
  )
106
- return response.json()
116
+ if response.json()["succeeded"]:
117
+ return
118
+ else:
119
+ raise ValueError(f"Failed to type text: {response.json()['error']}")
107
120
 
108
121
  def press_enter(self, cdp_url: str = None):
109
122
  if not cdp_url and not self.session_id:
@@ -123,7 +136,10 @@ class Simplex:
123
136
  },
124
137
  data=data
125
138
  )
126
- return response.json()
139
+ if response.json()["succeeded"]:
140
+ return
141
+ else:
142
+ raise ValueError(f"Failed to press enter: {response.json()['error']}")
127
143
 
128
144
  def extract_bbox(self, element_description: str, cdp_url: str = None):
129
145
  if not cdp_url and not self.session_id:
@@ -143,8 +159,10 @@ class Simplex:
143
159
  },
144
160
  params=data
145
161
  )
146
-
147
- return response.json()
162
+ if response.json()["succeeded"]:
163
+ return response.json()["bbox"]
164
+ else:
165
+ raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
148
166
 
149
167
  def extract_text(self, element_description: str, cdp_url: str = None, use_vision: bool = False):
150
168
  if not cdp_url and not self.session_id:
@@ -167,7 +185,10 @@ class Simplex:
167
185
  },
168
186
  params=data
169
187
  )
170
- return response.json()
188
+ if response.json()["succeeded"]:
189
+ return response.json()["text"]
190
+ else:
191
+ raise ValueError(f"Failed to extract text: {response.json()['error']}")
171
192
 
172
193
  def extract_image(self, element_description: str, cdp_url: str = None):
173
194
  if not cdp_url and not self.session_id:
@@ -187,7 +208,10 @@ class Simplex:
187
208
  },
188
209
  params=data
189
210
  )
190
- return response.json()
211
+ if response.json()["succeeded"]:
212
+ return response.json()["image"]
213
+ else:
214
+ raise ValueError(f"Failed to extract image: {response.json()['error']}")
191
215
 
192
216
  def scroll(self, pixels: float, cdp_url: str = None):
193
217
  if not cdp_url and not self.session_id:
@@ -207,7 +231,10 @@ class Simplex:
207
231
  },
208
232
  data=data
209
233
  )
210
- return response.json()
234
+ if response.json()["succeeded"]:
235
+ return
236
+ else:
237
+ raise ValueError(f"Failed to scroll: {response.json()['error']}")
211
238
 
212
239
  def wait(self, milliseconds: int, cdp_url: str = None):
213
240
  if not cdp_url and not self.session_id:
@@ -227,17 +254,23 @@ class Simplex:
227
254
  },
228
255
  data=data
229
256
  )
230
- return response.json()
257
+ if response.json()["succeeded"]:
258
+ return
259
+ else:
260
+ raise ValueError(f"Failed to wait: {response.json()['error']}")
231
261
 
232
- def capture_login_session(self, url: str):
262
+ def create_login_session(self, url: str):
233
263
  response = requests.post(
234
- f"{BASE_URL}/capture_login_session",
264
+ f"{BASE_URL}/create_login_session",
235
265
  headers={
236
266
  'x-api-key': self.api_key
237
267
  },
238
268
  data={'url': url}
239
269
  )
240
- return response.json()
270
+ if response.json()["succeeded"]:
271
+ return response.json()["login_session_url"]
272
+ else:
273
+ raise ValueError(f"Failed to create login session: {response.json()['error']}")
241
274
 
242
275
  def restore_login_session(self, session_data_filepath: str, cdp_url: str = None):
243
276
  filename = session_data_filepath
@@ -261,14 +294,17 @@ class Simplex:
261
294
  },
262
295
  data=data
263
296
  )
264
- return response.json()
297
+ if response.json()["succeeded"]:
298
+ return
299
+ else:
300
+ raise ValueError(f"Failed to restore login session: {response.json()['error']}")
265
301
 
266
302
  def click_and_upload(self, element_description: str, file_path: str):
267
303
  if not self.session_id:
268
304
  raise ValueError(f"Must call create_session before calling action click_and_upload with element_description='{element_description}'")
269
305
 
270
306
  files = {
271
- 'zip_file': open(file_path, 'rb')
307
+ 'file': open(file_path, 'rb')
272
308
  }
273
309
 
274
310
  data = {
@@ -285,7 +321,10 @@ class Simplex:
285
321
  files=files,
286
322
  data=data
287
323
  )
288
- return response.json()
324
+ if response.json()["succeeded"]:
325
+ return
326
+ else:
327
+ raise ValueError(f"Failed to click and upload: {response.json()['error']}")
289
328
 
290
329
  def click_and_download(self, element_description: str):
291
330
  if not self.session_id:
@@ -304,8 +343,10 @@ class Simplex:
304
343
  },
305
344
  data=data
306
345
  )
307
-
308
- return response.json()
346
+ if response.json()["succeeded"]:
347
+ return response.json()["b64"], response.json()["filename"]
348
+ else:
349
+ raise ValueError(f"Failed to click and download: {response.json()['error']}")
309
350
 
310
351
  def exists(self, element_description: str, cdp_url: str = None):
311
352
  if not cdp_url and not self.session_id:
@@ -325,4 +366,8 @@ class Simplex:
325
366
  },
326
367
  data=data
327
368
  )
328
- return response.json()
369
+ response_json = response.json()
370
+ if response_json['succeeded']:
371
+ return response_json['reasoning']
372
+ else:
373
+ raise ValueError(f"Failed to check if element exists: {response_json['error']}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.14
3
+ Version: 1.2.17
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
File without changes
File without changes
File without changes
File without changes
File without changes