dialoghelper 0.0.28__tar.gz → 0.0.29__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 dialoghelper might be problematic. Click here for more details.

Files changed (22) hide show
  1. {dialoghelper-0.0.28/dialoghelper.egg-info → dialoghelper-0.0.29}/PKG-INFO +1 -1
  2. dialoghelper-0.0.29/dialoghelper/__init__.py +2 -0
  3. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/experimental.py +32 -29
  4. {dialoghelper-0.0.28 → dialoghelper-0.0.29/dialoghelper.egg-info}/PKG-INFO +1 -1
  5. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/settings.ini +1 -1
  6. dialoghelper-0.0.28/dialoghelper/__init__.py +0 -2
  7. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/LICENSE +0 -0
  8. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/MANIFEST.in +0 -0
  9. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/README.md +0 -0
  10. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/_modidx.py +0 -0
  11. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/core.py +0 -0
  12. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/db_dc.py +0 -0
  13. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/screenshot.js +0 -0
  14. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/SOURCES.txt +0 -0
  15. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/dependency_links.txt +0 -0
  16. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/entry_points.txt +0 -0
  17. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/not-zip-safe +0 -0
  18. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/requires.txt +0 -0
  19. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/top_level.txt +0 -0
  20. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/pyproject.toml +0 -0
  21. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/setup.cfg +0 -0
  22. {dialoghelper-0.0.28 → dialoghelper-0.0.29}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dialoghelper
3
- Version: 0.0.28
3
+ Version: 0.0.29
4
4
  Summary: Helper functions for solveit dialogs
5
5
  Home-page: https://github.com/AnswerDotAI/dialoghelper
6
6
  Author: Jeremy Howard
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.29"
2
+ from .core import *
@@ -6,22 +6,22 @@
6
6
  __all__ = ['iife', 'load_screenshot_js', 'start_screen_share', 'stop_screen_share', 'capture_screen']
7
7
 
8
8
  # %% ../nbs/01_experimental.ipynb
9
+ import uuid,json
9
10
  from importlib import resources
10
- import uuid
11
- from fasthtml.common import Div, Script
12
- import json
11
+ from fasthtml.common import Div,Script
13
12
  from claudette import ToolResult
14
13
  from .core import *
15
14
  from httpx import post as xpost
16
15
 
17
16
  # %% ../nbs/01_experimental.ipynb
18
- def _pop_data(data_id, timeout=20, condition=None, fail_msg = "`_pop_data` failed to return a value."):
19
- result = xpost('http://localhost:5001/pop_data_blocking_', data={'data_id': data_id}, timeout=timeout)
20
- if result.status_code == 200 and result.text.strip():
21
- try:
22
- if (data := result.json()) and (not condition or condition(data)): return data
23
- except json.JSONDecodeError as e: print(f"JSON decode error: {e}")
24
- raise RuntimeError(fail_msg)
17
+ def _pop_data(data_id, timeout=20):
18
+ params = {'data_id': data_id, 'timeout':timeout}
19
+ result = xpost('http://localhost:5001/pop_data_blocking_', data=params, timeout=timeout+1)
20
+ if result.status_code==200 and result.text.strip():
21
+ if (data := result.json()): return data
22
+ # except json.JSONDecodeError as e: print(f"JSON decode error: {e}")
23
+ raise RuntimeError("No data received")
24
+ raise RuntimeError(result.status_code)
25
25
 
26
26
  # %% ../nbs/01_experimental.ipynb
27
27
  def iife(code: str) -> str:
@@ -40,13 +40,14 @@ def load_screenshot_js(force=False, timeout=5):
40
40
  "Load screenshot capability and wait for confirmation it's ready."
41
41
  global _js_loaded
42
42
  if _js_loaded and not force: return
43
- print("Loading screenshot.js ...")
43
+ # print("Loading screenshot.js ...")
44
44
  status_id = str(uuid.uuid4())
45
- js_content = (resources.files('dialoghelper') / 'screenshot.js').read_text()
45
+ js_content = (resources.files('dialoghelper')/'screenshot.js').read_text()
46
46
  iife(js_content + f'sendDataToServer("{status_id}", {{"js_status": "ready"}});')
47
- data = _pop_data(status_id, timeout, condition=lambda d: d.get('js_status') == 'ready', fail_msg="Failed to load screenshot.js.")
47
+ data = _pop_data(status_id, timeout)
48
+ if (stat:=data.get('js_status'))!='ready': raise RuntimeError(f"Failed to load screenshot.js: {stat}")
48
49
  _js_loaded = True
49
- print("Screenshot.js loaded and ready")
50
+ # print("Screenshot.js loaded and ready")
50
51
 
51
52
  # %% ../nbs/01_experimental.ipynb
52
53
  _screen_share_active = False
@@ -57,23 +58,23 @@ def start_screen_share(timeout=45):
57
58
  load_screenshot_js()
58
59
  status_id = str(uuid.uuid4())
59
60
  iife(f'startPersistentScreenShare("{status_id}");')
60
- print("Requesting screen share permission ...")
61
- data = _pop_data(status_id, timeout, condition=lambda d: d.get('js_status') == 'ready', fail_msg="Screen share failed.")
61
+ # print("Requesting screen share permission ...")
62
+ data = _pop_data(status_id, timeout)
62
63
  js_status = data.get('js_status')
63
- if js_status == 'ready':
64
+ if js_status=='ready':
64
65
  _screen_share_active = True
65
- print("Screen share started successfully.")
66
- elif js_status == 'error': raise RuntimeError(f"Screen share failed: {data.get('error', 'Unknown error')}")
67
- elif js_status == 'connecting': raise RuntimeError("Screen share timed out after {timeout} seconds.")
66
+ # print("Screen share started successfully.")
67
+ elif js_status=='error': raise RuntimeError(f"Screen share failed: {data.get('error', 'Unknown error')}")
68
+ elif js_status=='connecting': raise RuntimeError("Screen share timed out after {timeout} seconds.")
68
69
 
69
70
  # %% ../nbs/01_experimental.ipynb
70
71
  def stop_screen_share():
71
- "Stop persistent screen sharing session."
72
- global _screen_share_active
73
- load_screenshot_js()
74
- iife('stopPersistentScreenShare();')
75
- _screen_share_active = False
76
- print("Screen share stopped.")
72
+ "Stop persistent screen sharing session."
73
+ global _screen_share_active
74
+ load_screenshot_js()
75
+ iife('stopPersistentScreenShare();')
76
+ _screen_share_active = False
77
+ # print("Screen share stopped.")
77
78
 
78
79
  # %% ../nbs/01_experimental.ipynb
79
80
  def capture_screen():
@@ -81,13 +82,15 @@ def capture_screen():
81
82
  global _screen_share_active
82
83
  load_screenshot_js()
83
84
  if not _screen_share_active:
84
- print("🔄 No active screen share, starting one...")
85
+ # print("🔄 No active screen share, starting one...")
85
86
  result = start_screen_share()
86
87
  if not _screen_share_active: raise RuntimeError(f"Failed to start screen share: {result}")
87
88
  data_id = str(uuid.uuid4())
88
89
  screenshot_code = f'captureScreenFromStream("{data_id}");'
89
- print("📸 Capturing from persistent stream...")
90
+ # print("📸 Capturing from persistent stream...")
90
91
  iife(screenshot_code)
91
- data = _pop_data(data_id, timeout=5, condition=lambda d: 'img_data' in d and 'img_type' in d, fail_msg="Screenshot capture failed, failed to retrieve data.")
92
+ data = _pop_data(data_id, timeout=45)
92
93
  if 'error' in data: raise RuntimeError(f"Screenshot failed: {data['error']}")
94
+ if not ('img_data' in data and 'img_type' in data):
95
+ raise RuntimeError("Screenshot capture failed, failed to retrieve data.")
93
96
  return ToolResult(data=data['img_data'], result_type=data['img_type'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dialoghelper
3
- Version: 0.0.28
3
+ Version: 0.0.29
4
4
  Summary: Helper functions for solveit dialogs
5
5
  Home-page: https://github.com/AnswerDotAI/dialoghelper
6
6
  Author: Jeremy Howard
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = dialoghelper
3
3
  lib_name = dialoghelper
4
- version = 0.0.28
4
+ version = 0.0.29
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.28"
2
- from .core import *
File without changes
File without changes
File without changes
File without changes
File without changes