simplex 1.2.64__py3-none-any.whl → 1.2.69__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 simplex might be problematic. Click here for more details.
- simplex/simplex.py +53 -21
- {simplex-1.2.64.dist-info → simplex-1.2.69.dist-info}/METADATA +2 -2
- simplex-1.2.69.dist-info/RECORD +11 -0
- simplex-1.2.64.dist-info/RECORD +0 -11
- {simplex-1.2.64.dist-info → simplex-1.2.69.dist-info}/LICENSE +0 -0
- {simplex-1.2.64.dist-info → simplex-1.2.69.dist-info}/WHEEL +0 -0
- {simplex-1.2.64.dist-info → simplex-1.2.69.dist-info}/entry_points.txt +0 -0
- {simplex-1.2.64.dist-info → simplex-1.2.69.dist-info}/top_level.txt +0 -0
simplex/simplex.py
CHANGED
|
@@ -4,9 +4,7 @@ from typing import Optional, Union
|
|
|
4
4
|
import os
|
|
5
5
|
import json
|
|
6
6
|
import warnings
|
|
7
|
-
|
|
8
|
-
import tempfile
|
|
9
|
-
# Try to import playwright, but don't fail if it's not available (lite version)
|
|
7
|
+
|
|
10
8
|
try:
|
|
11
9
|
from rebrowser_playwright.sync_api import sync_playwright
|
|
12
10
|
PLAYWRIGHT_AVAILABLE = True
|
|
@@ -81,11 +79,9 @@ class Simplex:
|
|
|
81
79
|
self.session_id = None
|
|
82
80
|
atexit.register(self.close_session)
|
|
83
81
|
if PLAYWRIGHT_AVAILABLE:
|
|
84
|
-
self.playwright = Playwright(self)
|
|
85
82
|
self.pw_browser = None
|
|
86
83
|
self.pw = None
|
|
87
84
|
else:
|
|
88
|
-
self.playwright = None
|
|
89
85
|
self.pw_browser = None
|
|
90
86
|
self.pw = None
|
|
91
87
|
|
|
@@ -114,13 +110,12 @@ class Simplex:
|
|
|
114
110
|
self.session_id = None
|
|
115
111
|
if 'succeeded' not in response.json():
|
|
116
112
|
raise ValueError(f"It looks like the close_session action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
117
|
-
if
|
|
113
|
+
if response.json()['succeeded']:
|
|
118
114
|
return
|
|
119
115
|
else:
|
|
120
116
|
raise ValueError(f"Failed to close session: {response.json()['error']}")
|
|
121
117
|
|
|
122
118
|
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, workflow_name: Optional[str] = None, session_data: Optional[dict | str] = None):
|
|
123
|
-
print("CREATING SESSION")
|
|
124
119
|
if self.session_id:
|
|
125
120
|
raise ValueError("A session is already active. Please close the current session before creating a new one.")
|
|
126
121
|
|
|
@@ -201,10 +196,11 @@ class Simplex:
|
|
|
201
196
|
if 'succeeded' not in response.json():
|
|
202
197
|
raise ValueError(f"It looks like the goto action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
203
198
|
|
|
204
|
-
if
|
|
199
|
+
if response.json()['succeeded']:
|
|
205
200
|
return
|
|
206
201
|
else:
|
|
207
202
|
raise ValueError(f"Failed to goto url: {response.json()['error']}")
|
|
203
|
+
|
|
208
204
|
|
|
209
205
|
def click(self, element_description: str, cdp_url: str = None):
|
|
210
206
|
if not element_description or not element_description.strip():
|
|
@@ -232,6 +228,35 @@ class Simplex:
|
|
|
232
228
|
return response.json()["element_clicked"]
|
|
233
229
|
else:
|
|
234
230
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
231
|
+
|
|
232
|
+
def select_dropdown_option(self, element_description: str, cdp_url: str = None):
|
|
233
|
+
if not element_description or not element_description.strip():
|
|
234
|
+
raise ValueError("element_description cannot be empty")
|
|
235
|
+
if not cdp_url and not self.session_id:
|
|
236
|
+
raise ValueError(f"Must call create_session before calling action select_from_dropdown with element_description='{element_description}'")
|
|
237
|
+
|
|
238
|
+
data = {'element_description': element_description}
|
|
239
|
+
|
|
240
|
+
if cdp_url:
|
|
241
|
+
data['cdp_url'] = cdp_url
|
|
242
|
+
else:
|
|
243
|
+
data['session_id'] = self.session_id
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
response = requests.post(
|
|
247
|
+
f"{BASE_URL}/select_dropdown_option",
|
|
248
|
+
headers={
|
|
249
|
+
'x-api-key': self.api_key
|
|
250
|
+
},
|
|
251
|
+
data=data
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if 'succeeded' not in response.json():
|
|
255
|
+
raise ValueError(f"It looks like the select_dropdown_option action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
256
|
+
if response.json()["succeeded"]:
|
|
257
|
+
return response.json()["element_clicked"]
|
|
258
|
+
else:
|
|
259
|
+
raise ValueError(f"Failed to select dropdown option: {response.json()['error']}")
|
|
235
260
|
|
|
236
261
|
|
|
237
262
|
def scroll_to_element(self, element_description: str, cdp_url: str = None):
|
|
@@ -312,7 +337,7 @@ class Simplex:
|
|
|
312
337
|
},
|
|
313
338
|
data=data
|
|
314
339
|
)
|
|
315
|
-
if
|
|
340
|
+
if response.json()['succeeded']:
|
|
316
341
|
return
|
|
317
342
|
else:
|
|
318
343
|
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
@@ -338,7 +363,7 @@ class Simplex:
|
|
|
338
363
|
)
|
|
339
364
|
if 'succeeded' not in response.json():
|
|
340
365
|
raise ValueError(f"It looks like the reload action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
341
|
-
if
|
|
366
|
+
if response.json()['succeeded']:
|
|
342
367
|
return
|
|
343
368
|
else:
|
|
344
369
|
raise ValueError(f"Failed to reload: {response.json()['error']}")
|
|
@@ -363,7 +388,7 @@ class Simplex:
|
|
|
363
388
|
)
|
|
364
389
|
if 'succeeded' not in response.json():
|
|
365
390
|
raise ValueError(f"It looks like the press_enter action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
366
|
-
if
|
|
391
|
+
if response.json()['succeeded']:
|
|
367
392
|
return
|
|
368
393
|
else:
|
|
369
394
|
raise ValueError(f"Failed to press enter: {response.json()['error']}")
|
|
@@ -388,7 +413,7 @@ class Simplex:
|
|
|
388
413
|
)
|
|
389
414
|
if 'succeeded' not in response.json():
|
|
390
415
|
raise ValueError(f"It looks like the press_tab action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
391
|
-
if
|
|
416
|
+
if response.json()['succeeded']:
|
|
392
417
|
return
|
|
393
418
|
else:
|
|
394
419
|
raise ValueError(f"Failed to press tab: {response.json()['error']}")
|
|
@@ -413,7 +438,7 @@ class Simplex:
|
|
|
413
438
|
)
|
|
414
439
|
if 'succeeded' not in response.json():
|
|
415
440
|
raise ValueError(f"It looks like the delete_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
416
|
-
if
|
|
441
|
+
if response.json()['succeeded']:
|
|
417
442
|
return
|
|
418
443
|
else:
|
|
419
444
|
raise ValueError(f"Failed to delete text: {response.json()['error']}")
|
|
@@ -440,7 +465,7 @@ class Simplex:
|
|
|
440
465
|
)
|
|
441
466
|
if 'succeeded' not in response.json():
|
|
442
467
|
raise ValueError(f"It looks like the extract_bbox action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
443
|
-
if
|
|
468
|
+
if response.json()['succeeded']:
|
|
444
469
|
return response.json()["bbox"]
|
|
445
470
|
else:
|
|
446
471
|
raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
|
|
@@ -495,7 +520,7 @@ class Simplex:
|
|
|
495
520
|
)
|
|
496
521
|
if 'succeeded' not in response.json():
|
|
497
522
|
raise ValueError(f"It looks like the extract_image action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
498
|
-
if
|
|
523
|
+
if response.json()['succeeded']:
|
|
499
524
|
return response.json()["image"]
|
|
500
525
|
else:
|
|
501
526
|
raise ValueError(f"Failed to extract image: {response.json()['error']}")
|
|
@@ -520,7 +545,7 @@ class Simplex:
|
|
|
520
545
|
)
|
|
521
546
|
if 'succeeded' not in response.json():
|
|
522
547
|
raise ValueError(f"It looks like the scroll action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
523
|
-
if
|
|
548
|
+
if response.json()['succeeded']:
|
|
524
549
|
return
|
|
525
550
|
else:
|
|
526
551
|
raise ValueError(f"Failed to scroll: {response.json()['error']}")
|
|
@@ -545,7 +570,7 @@ class Simplex:
|
|
|
545
570
|
)
|
|
546
571
|
if 'succeeded' not in response.json():
|
|
547
572
|
raise ValueError(f"It looks like the wait action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
548
|
-
if
|
|
573
|
+
if response.json()['succeeded']:
|
|
549
574
|
return
|
|
550
575
|
else:
|
|
551
576
|
raise ValueError(f"Failed to wait: {response.json()['error']}")
|
|
@@ -601,6 +626,7 @@ class Simplex:
|
|
|
601
626
|
</body>
|
|
602
627
|
</html>
|
|
603
628
|
"""
|
|
629
|
+
import tempfile
|
|
604
630
|
# Write to a temporary file
|
|
605
631
|
with tempfile.NamedTemporaryFile(delete=False, suffix='.html', mode='w') as f:
|
|
606
632
|
f.write(html_content)
|
|
@@ -707,7 +733,7 @@ class Simplex:
|
|
|
707
733
|
)
|
|
708
734
|
if 'succeeded' not in response.json():
|
|
709
735
|
raise ValueError(f"It looks like the restore_login_session action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
710
|
-
if
|
|
736
|
+
if response.json()['succeeded']:
|
|
711
737
|
return
|
|
712
738
|
else:
|
|
713
739
|
raise ValueError(f"Failed to restore login session: {response.json()['error']}")
|
|
@@ -751,7 +777,7 @@ class Simplex:
|
|
|
751
777
|
)
|
|
752
778
|
if 'succeeded' not in response.json():
|
|
753
779
|
raise ValueError(f"It looks like the click_and_upload action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
754
|
-
if
|
|
780
|
+
if response.json()['succeeded']:
|
|
755
781
|
return
|
|
756
782
|
else:
|
|
757
783
|
raise ValueError(f"Failed to click and upload: {response.json()['error']}")
|
|
@@ -775,6 +801,7 @@ class Simplex:
|
|
|
775
801
|
},
|
|
776
802
|
data=data
|
|
777
803
|
)
|
|
804
|
+
|
|
778
805
|
# Get filename from Content-Disposition header
|
|
779
806
|
content_disposition = response.headers.get('Content-Disposition')
|
|
780
807
|
if content_disposition:
|
|
@@ -791,7 +818,11 @@ class Simplex:
|
|
|
791
818
|
except Exception:
|
|
792
819
|
raise ValueError("File failed to be parsed from Content-Disposition header.")
|
|
793
820
|
else:
|
|
794
|
-
|
|
821
|
+
try:
|
|
822
|
+
raise ValueError(response.json()["error"])
|
|
823
|
+
except:
|
|
824
|
+
raise ValueError("No Content-Disposition header found. File was not downloaded.")
|
|
825
|
+
|
|
795
826
|
|
|
796
827
|
# Check if response content is empty
|
|
797
828
|
if len(response.content) == 0:
|
|
@@ -822,7 +853,8 @@ class Simplex:
|
|
|
822
853
|
if 'succeeded' not in response.json():
|
|
823
854
|
raise ValueError(f"It looks like the exists action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
824
855
|
response_json = response.json()
|
|
825
|
-
|
|
856
|
+
|
|
857
|
+
if response_json['succeeded']:
|
|
826
858
|
return response_json['exists'], response_json['reasoning']
|
|
827
859
|
else:
|
|
828
860
|
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: simplex
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.69
|
|
4
4
|
Summary: Official Python SDK for Simplex API
|
|
5
5
|
Home-page: https://simplex.sh
|
|
6
6
|
Author: Simplex Labs, Inc.
|
|
@@ -18,7 +18,7 @@ Requires-Dist: requests
|
|
|
18
18
|
Requires-Dist: python-dotenv
|
|
19
19
|
Requires-Dist: click
|
|
20
20
|
Provides-Extra: playwright
|
|
21
|
-
Requires-Dist: playwright>=1.0.0; extra == "playwright"
|
|
21
|
+
Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
|
|
22
22
|
|
|
23
23
|
# Simplex AI Python SDK
|
|
24
24
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
+
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
+
simplex/simplex.py,sha256=8gm5mmAdpQ4Hnkrk-XciUKeqg2Elah0TYuYT1B0i7vo,33851
|
|
4
|
+
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
+
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
+
simplex-1.2.69.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
+
simplex-1.2.69.dist-info/METADATA,sha256=2Qb_Uf6aNkX1wCWvZYx-UKKl0aZGmzB5TrBf4r3DMDE,834
|
|
8
|
+
simplex-1.2.69.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
9
|
+
simplex-1.2.69.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
+
simplex-1.2.69.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
+
simplex-1.2.69.dist-info/RECORD,,
|
simplex-1.2.64.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
-
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
-
simplex/simplex.py,sha256=Qz64Q1fUhgssSswlyFMa1j6Kqml_Q43Bbxl5izlkIQs,32688
|
|
4
|
-
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
-
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
-
simplex-1.2.64.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
-
simplex-1.2.64.dist-info/METADATA,sha256=DKPy2BYY6neMwiFgOMK9lIc92V1-qK1uCwUAXu-2Spk,824
|
|
8
|
-
simplex-1.2.64.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
9
|
-
simplex-1.2.64.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
-
simplex-1.2.64.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
-
simplex-1.2.64.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|