dialoghelper 0.0.21__tar.gz → 0.0.22__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.
- {dialoghelper-0.0.21/dialoghelper.egg-info → dialoghelper-0.0.22}/PKG-INFO +2 -1
- dialoghelper-0.0.22/dialoghelper/__init__.py +2 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper/_modidx.py +7 -1
- dialoghelper-0.0.22/dialoghelper/experimental.py +68 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22/dialoghelper.egg-info}/PKG-INFO +2 -1
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/SOURCES.txt +1 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/requires.txt +1 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/settings.ini +2 -2
- dialoghelper-0.0.21/dialoghelper/__init__.py +0 -2
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/LICENSE +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/MANIFEST.in +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/README.md +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper/core.py +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper/db_dc.py +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/pyproject.toml +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/setup.cfg +0 -0
- {dialoghelper-0.0.21 → dialoghelper-0.0.22}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dialoghelper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.22
|
|
4
4
|
Summary: Helper functions for solveit dialogs
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/dialoghelper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -22,6 +22,7 @@ Requires-Dist: fastcore>=1.8.5
|
|
|
22
22
|
Requires-Dist: fastlite
|
|
23
23
|
Requires-Dist: ghapi
|
|
24
24
|
Requires-Dist: ipykernel-helper
|
|
25
|
+
Requires-Dist: claudette
|
|
25
26
|
Provides-Extra: dev
|
|
26
27
|
Dynamic: author
|
|
27
28
|
Dynamic: author-email
|
|
@@ -25,4 +25,10 @@ d = { 'settings': { 'branch': 'main',
|
|
|
25
25
|
'dialoghelper.core.read_msg': ('core.html#read_msg', 'dialoghelper/core.py'),
|
|
26
26
|
'dialoghelper.core.tool_info': ('core.html#tool_info', 'dialoghelper/core.py'),
|
|
27
27
|
'dialoghelper.core.update_msg': ('core.html#update_msg', 'dialoghelper/core.py')},
|
|
28
|
-
'dialoghelper.db_dc': {}
|
|
28
|
+
'dialoghelper.db_dc': {},
|
|
29
|
+
'dialoghelper.experimental': { 'dialoghelper.experimental._load_screenshot_js': ( 'experimental.html#_load_screenshot_js',
|
|
30
|
+
'dialoghelper/experimental.py'),
|
|
31
|
+
'dialoghelper.experimental.capture_screen': ( 'experimental.html#capture_screen',
|
|
32
|
+
'dialoghelper/experimental.py'),
|
|
33
|
+
'dialoghelper.experimental.create_iife': ( 'experimental.html#create_iife',
|
|
34
|
+
'dialoghelper/experimental.py')}}}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Experimental `dialoghelper` capabilities."""
|
|
2
|
+
|
|
3
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_experimental.ipynb.
|
|
4
|
+
|
|
5
|
+
# %% auto 0
|
|
6
|
+
__all__ = ['create_iife', 'capture_screen']
|
|
7
|
+
|
|
8
|
+
# %% ../nbs/01_experimental.ipynb
|
|
9
|
+
from importlib import resources
|
|
10
|
+
import uuid
|
|
11
|
+
from fasthtml.common import Div, Script
|
|
12
|
+
from time import sleep
|
|
13
|
+
import base64
|
|
14
|
+
import json
|
|
15
|
+
import time
|
|
16
|
+
from claudette import ToolResult
|
|
17
|
+
from .core import *
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from httpx import get as xget, post as xpost
|
|
20
|
+
|
|
21
|
+
# %% ../nbs/01_experimental.ipynb
|
|
22
|
+
_js_loaded = False
|
|
23
|
+
|
|
24
|
+
def _load_screenshot_js():
|
|
25
|
+
"Load screenshot capability if not already present."
|
|
26
|
+
global _js_loaded
|
|
27
|
+
if _js_loaded:
|
|
28
|
+
print("screenshot.js already loaded")
|
|
29
|
+
return
|
|
30
|
+
js_content = (resources.files('dialoghelper') / 'screenshot.js').read_text()
|
|
31
|
+
add_html(Div(Script(js_content), hx_swap_oob='beforeend:#js-script'))
|
|
32
|
+
print("Added screenshot.js")
|
|
33
|
+
_js_loaded = True
|
|
34
|
+
|
|
35
|
+
# %% ../nbs/01_experimental.ipynb
|
|
36
|
+
def create_iife(code: str) -> str:
|
|
37
|
+
"Wrap javascript code string in an IIFE"
|
|
38
|
+
return f'''
|
|
39
|
+
(async () => {{
|
|
40
|
+
{code}
|
|
41
|
+
}})();
|
|
42
|
+
'''
|
|
43
|
+
|
|
44
|
+
# %% ../nbs/01_experimental.ipynb
|
|
45
|
+
def capture_screen():
|
|
46
|
+
"Capture current desktop returning the screenshot as a ToolImageResult."
|
|
47
|
+
_load_screenshot_js()
|
|
48
|
+
data_id = str(uuid.uuid4()) # Generate random ID for data communication
|
|
49
|
+
screenshot_code = f'captureScreenAndUpload("{data_id}");'
|
|
50
|
+
trigger_script = create_iife(screenshot_code)
|
|
51
|
+
add_html(Div(Script(trigger_script), hx_swap_oob=f'beforeend:#js-script'))
|
|
52
|
+
max_attempts = 50
|
|
53
|
+
for attempt in range(max_attempts):
|
|
54
|
+
result = xpost('http://localhost:5001/pop_data_', data={'data_id': data_id})
|
|
55
|
+
if result.status_code == 200:
|
|
56
|
+
try:
|
|
57
|
+
if not result.text.strip():
|
|
58
|
+
time.sleep(0.5)
|
|
59
|
+
continue
|
|
60
|
+
data = result.json() # data is a dict
|
|
61
|
+
if 'error' in data: return f"Screenshot failed: {data['error']}"
|
|
62
|
+
if 'img_data' in data and 'img_type' in data:
|
|
63
|
+
return ToolResult(data=data['img_data'], result_type=data['img_type'])
|
|
64
|
+
return f"Screenshot data incomplete: {data}"
|
|
65
|
+
except json.JSONDecodeError as e: print(f"JSON decode error: {e}, Raw text: '{result.text}'")
|
|
66
|
+
except Exception as e: print(f"Error processing screenshot data: {e}")
|
|
67
|
+
time.sleep(0.5)
|
|
68
|
+
return "Screenshot capture timed out"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dialoghelper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.22
|
|
4
4
|
Summary: Helper functions for solveit dialogs
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/dialoghelper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -22,6 +22,7 @@ Requires-Dist: fastcore>=1.8.5
|
|
|
22
22
|
Requires-Dist: fastlite
|
|
23
23
|
Requires-Dist: ghapi
|
|
24
24
|
Requires-Dist: ipykernel-helper
|
|
25
|
+
Requires-Dist: claudette
|
|
25
26
|
Provides-Extra: dev
|
|
26
27
|
Dynamic: author
|
|
27
28
|
Dynamic: author-email
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
2
|
repo = dialoghelper
|
|
3
3
|
lib_name = dialoghelper
|
|
4
|
-
version = 0.0.
|
|
4
|
+
version = 0.0.22
|
|
5
5
|
min_python = 3.9
|
|
6
6
|
license = apache2
|
|
7
7
|
black_formatting = False
|
|
8
|
-
requirements = fastcore>=1.8.5 fastlite ghapi ipykernel-helper
|
|
8
|
+
requirements = fastcore>=1.8.5 fastlite ghapi ipykernel-helper claudette
|
|
9
9
|
doc_path = _docs
|
|
10
10
|
lib_path = dialoghelper
|
|
11
11
|
nbs_path = nbs
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|