simplex 1.2.37__tar.gz → 1.2.41__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
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: simplex
3
- Version: 1.2.37
3
+ Version: 1.2.41
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -18,15 +18,6 @@ Requires-Dist: requests
18
18
  Requires-Dist: python-dotenv
19
19
  Requires-Dist: click
20
20
  Requires-Dist: playwright
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: requires-dist
28
- Dynamic: requires-python
29
- Dynamic: summary
30
21
 
31
22
  # Simplex AI Python SDK
32
23
 
@@ -17,7 +17,7 @@ class PostInstallCommand(install):
17
17
 
18
18
  setup(
19
19
  name="simplex",
20
- version="1.2.37",
20
+ version="1.2.41",
21
21
  packages=find_packages(),
22
22
  package_data={
23
23
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -64,7 +64,7 @@ def login(website, proxies):
64
64
 
65
65
  animated_print(f"[SIMPLEX] Creating login session for {website}")
66
66
 
67
- fileName = simplex.create_login_session(website, proxies=proxies)
67
+ fileName = simplex.create_login_session(website)
68
68
 
69
69
  if fileName:
70
70
  animated_print(f"[SIMPLEX] Login session created and saved to {fileName}")
@@ -53,8 +53,6 @@ class Playwright:
53
53
  return
54
54
  else:
55
55
  raise ValueError(f"Failed to click element: {response.json()['error']}")
56
-
57
-
58
56
 
59
57
  class Simplex:
60
58
  def __init__(self, api_key: str):
@@ -82,14 +80,36 @@ class Simplex:
82
80
  else:
83
81
  raise ValueError(f"Failed to close session: {response.json()['error']}")
84
82
 
85
- def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[str] = None):
86
- response = requests.post(
87
- f"{BASE_URL}/create_session",
88
- headers={
89
- 'x-api-key': self.api_key
90
- },
91
- data={'proxies': proxies, 'session_data': session_data}
92
- )
83
+ def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[dict | str] = None):
84
+ if session_data:
85
+ if isinstance(session_data, dict):
86
+ session_data_dict = session_data
87
+ else:
88
+ try:
89
+ # Try to parse as JSON string first
90
+ session_data_dict = json.loads(session_data)
91
+ except json.JSONDecodeError:
92
+ # If parsing fails, treat as file path
93
+ try:
94
+ with open(session_data, 'r') as f:
95
+ session_data_dict = json.load(f)
96
+ except Exception as e:
97
+ raise ValueError(f"Failed to load session data. Input must be valid JSON string, dictionary, or path to JSON file. Error: {str(e)}")
98
+ response = requests.post(
99
+ f"{BASE_URL}/create_session",
100
+ headers={
101
+ 'x-api-key': self.api_key
102
+ },
103
+ data={'proxies': proxies, 'session_data': json.dumps(session_data_dict)}
104
+ )
105
+ else:
106
+ response = requests.post(
107
+ f"{BASE_URL}/create_session",
108
+ headers={
109
+ 'x-api-key': self.api_key
110
+ },
111
+ data={'proxies': proxies}
112
+ )
93
113
  # Check for non-200 status code
94
114
  if response.status_code != 200:
95
115
  raise ValueError(f"Create session request failed with status code {response.status_code}: {response.text}")
@@ -293,12 +313,12 @@ class Simplex:
293
313
  else:
294
314
  data['session_id'] = self.session_id
295
315
 
296
- response = requests.get(
316
+ response = requests.post(
297
317
  f"{BASE_URL}/extract-text",
298
318
  headers={
299
319
  'x-api-key': self.api_key
300
320
  },
301
- params=data
321
+ data=data
302
322
  )
303
323
  if 'succeeded' not in response.json():
304
324
  raise ValueError(f"It looks like the extract_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
@@ -382,7 +402,7 @@ class Simplex:
382
402
  else:
383
403
  raise ValueError(f"Failed to wait: {response.json()['error']}")
384
404
 
385
- def create_login_session(self, url: str, save_directory: Optional[str] = None, proxies: Optional[bool] = True):
405
+ def create_login_session(self, url: str, save_directory: Optional[str] = None):
386
406
  def get_website_name(url: str) -> str:
387
407
  """Extract website name from URL"""
388
408
  from urllib.parse import urlparse
@@ -393,8 +413,7 @@ class Simplex:
393
413
  return netloc.replace(".", "_")
394
414
 
395
415
  with sync_playwright() as p:
396
- browser = p.chromium.launch_persistent_context(
397
- user_data_dir="",
416
+ browser = p.chromium.launch(
398
417
  channel="chrome",
399
418
  headless=False,
400
419
  args=[
@@ -404,16 +423,13 @@ class Simplex:
404
423
  ignore_default_args=['--enable-automation']
405
424
  )
406
425
 
407
- # Close the default about:blank page
408
- if len(browser.pages) > 0:
409
- browser.pages[0].close()
410
-
411
- # Create main page for login
412
- main_page = browser.new_page()
426
+ # Create context and pages
427
+ context = browser.new_context()
428
+ main_page = context.new_page()
413
429
  main_page.goto(url)
414
430
 
415
- # Create control page
416
- control_page = browser.new_page()
431
+ # Create control page in same context
432
+ control_page = context.new_page()
417
433
  control_page.set_content("""
418
434
  <html>
419
435
  <body style="display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f5f5f5;">
@@ -443,7 +459,8 @@ class Simplex:
443
459
  }
444
460
  """)
445
461
 
446
- storage = browser.storage_state()
462
+ # Use context.storage_state() instead of browser.storage_state()
463
+ storage = context.storage_state()
447
464
  if save_directory:
448
465
  filename = os.path.join(save_directory, get_website_name(url) + "_session_data.json")
449
466
  else:
@@ -576,4 +593,4 @@ class Simplex:
576
593
  if response_json['succeeded']:
577
594
  return response_json['exists'], response_json['reasoning']
578
595
  else:
579
- raise ValueError(f"Failed to check if element exists: {response_json['error']}")
596
+ raise ValueError(f"Failed to check if element exists: {response_json['error']}")
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: simplex
3
- Version: 1.2.37
3
+ Version: 1.2.41
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -18,15 +18,6 @@ Requires-Dist: requests
18
18
  Requires-Dist: python-dotenv
19
19
  Requires-Dist: click
20
20
  Requires-Dist: playwright
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: requires-dist
28
- Dynamic: requires-python
29
- Dynamic: summary
30
21
 
31
22
  # Simplex AI Python SDK
32
23
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes