dialoghelper 0.0.14__py3-none-any.whl → 0.0.16__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 dialoghelper might be problematic. Click here for more details.
- dialoghelper/__init__.py +1 -1
- dialoghelper/_modidx.py +1 -0
- dialoghelper/core.py +27 -9
- {dialoghelper-0.0.14.dist-info → dialoghelper-0.0.16.dist-info}/METADATA +2 -2
- dialoghelper-0.0.16.dist-info/RECORD +10 -0
- dialoghelper-0.0.14.dist-info/RECORD +0 -10
- {dialoghelper-0.0.14.dist-info → dialoghelper-0.0.16.dist-info}/WHEEL +0 -0
- {dialoghelper-0.0.14.dist-info → dialoghelper-0.0.16.dist-info}/entry_points.txt +0 -0
- {dialoghelper-0.0.14.dist-info → dialoghelper-0.0.16.dist-info}/licenses/LICENSE +0 -0
- {dialoghelper-0.0.14.dist-info → dialoghelper-0.0.16.dist-info}/top_level.txt +0 -0
dialoghelper/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.16"
|
|
2
2
|
from .core import *
|
dialoghelper/_modidx.py
CHANGED
|
@@ -8,6 +8,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
8
8
|
'syms': { 'dialoghelper.core': { 'dialoghelper.core._add_msg_unsafe': ('core.html#_add_msg_unsafe', 'dialoghelper/core.py'),
|
|
9
9
|
'dialoghelper.core._msg': ('core.html#_msg', 'dialoghelper/core.py'),
|
|
10
10
|
'dialoghelper.core._umsg': ('core.html#_umsg', 'dialoghelper/core.py'),
|
|
11
|
+
'dialoghelper.core.add_html': ('core.html#add_html', 'dialoghelper/core.py'),
|
|
11
12
|
'dialoghelper.core.add_msg': ('core.html#add_msg', 'dialoghelper/core.py'),
|
|
12
13
|
'dialoghelper.core.del_msg': ('core.html#del_msg', 'dialoghelper/core.py'),
|
|
13
14
|
'dialoghelper.core.export_dialog': ('core.html#export_dialog', 'dialoghelper/core.py'),
|
dialoghelper/core.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['Placements', 'empty', 'get_db', 'find_var', 'find_dialog_id', 'find_msgs', 'find_msg_id', 'read_msg_ids', 'msg_idx',
|
|
5
|
-
'read_msg', 'del_msg', 'add_msg', 'update_msg', 'load_gist', 'gist_file', 'import_string',
|
|
6
|
-
'mk_toollist', 'import_gist', 'export_dialog', 'import_dialog', 'tool_info', 'asdict']
|
|
5
|
+
'read_msg', 'add_html', 'del_msg', 'add_msg', 'update_msg', 'load_gist', 'gist_file', 'import_string',
|
|
6
|
+
'is_usable_tool', 'mk_toollist', 'import_gist', 'export_dialog', 'import_dialog', 'tool_info', 'asdict']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/00_core.ipynb
|
|
9
9
|
import json, importlib, linecache
|
|
@@ -11,6 +11,7 @@ from typing import Dict
|
|
|
11
11
|
from tempfile import TemporaryDirectory
|
|
12
12
|
from ipykernel_helper import *
|
|
13
13
|
from dataclasses import dataclass
|
|
14
|
+
from fastcore.xml import to_xml
|
|
14
15
|
|
|
15
16
|
from fastcore.utils import *
|
|
16
17
|
from fastcore.meta import delegates
|
|
@@ -98,6 +99,14 @@ def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)
|
|
|
98
99
|
db = get_db()
|
|
99
100
|
return db.t.message.selectone('sid=?', [ids[idx]])
|
|
100
101
|
|
|
102
|
+
# %% ../nbs/00_core.ipynb
|
|
103
|
+
def add_html(
|
|
104
|
+
content:str, # The HTML to send to the client (generally should include hx-swap-oob)
|
|
105
|
+
):
|
|
106
|
+
"Send HTML to the browser to be swapped into the DOM"
|
|
107
|
+
res = to_xml(content)
|
|
108
|
+
xpost('http://localhost:5001/add_html_', data=dict(content=res))
|
|
109
|
+
|
|
101
110
|
# %% ../nbs/00_core.ipynb
|
|
102
111
|
def del_msg(
|
|
103
112
|
sid:str=None, # sid (stable id -- pk) of message that placement is relative to (if None, uses current message)
|
|
@@ -107,6 +116,8 @@ def del_msg(
|
|
|
107
116
|
|
|
108
117
|
# %% ../nbs/00_core.ipynb
|
|
109
118
|
def _msg(
|
|
119
|
+
msg_type: str='note', # Message type, can be 'code', 'note', or 'prompt'
|
|
120
|
+
output:str='', # For prompts/code, initial output
|
|
110
121
|
time_run: str | None = '', # When was message executed
|
|
111
122
|
is_exported: int | None = 0, # Export message to a module?
|
|
112
123
|
skipped: int | None = 0, # Hide message from prompt?
|
|
@@ -122,17 +133,23 @@ Placements = str_enum('Placements', 'add_after', 'add_before', 'update', 'at_sta
|
|
|
122
133
|
@delegates(_msg)
|
|
123
134
|
def add_msg(
|
|
124
135
|
content:str, # Content of the message (i.e the message prompt, code, or note text)
|
|
125
|
-
msg_type: str='note', # Message type, can be 'code', 'note', or 'prompt'
|
|
126
|
-
output:str='', # For prompts/code, initial output
|
|
127
136
|
placement:str='add_after', # Can be 'add_after', 'add_before', 'update', 'at_start', 'at_end'
|
|
128
137
|
sid:str=None, # sid (stable id -- pk) of message that placement is relative to (if None, uses current message)
|
|
129
138
|
**kwargs
|
|
130
139
|
):
|
|
131
|
-
"Add/update a message to the queue to show after code execution completes.
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
"""Add/update a message to the queue to show after code execution completes.
|
|
141
|
+
Be sure to pass a `sid` (stable id) not a `mid` (which is used only for sorting, and can change).
|
|
142
|
+
Sets msg_type to 'note' by default if not update placement."""
|
|
143
|
+
if 'msg_type' not in kwargs and placement!='update': kwargs['msg_type']='note'
|
|
144
|
+
mt = kwargs.get('msg_type',None)
|
|
145
|
+
ot = kwargs.get('output',None)
|
|
146
|
+
if mt and mt not in ('note', 'code', 'prompt'): return "msg_type must be 'code', 'note', or 'prompt'."
|
|
147
|
+
if mt=='note' and ot: return "note messages cannot have an output."
|
|
148
|
+
if mt=='code':
|
|
149
|
+
try: json.loads(ot or '[]')
|
|
150
|
+
except: return "Code output must be valid json"
|
|
134
151
|
if not sid: sid = find_msg_id()
|
|
135
|
-
data = dict(content=content,
|
|
152
|
+
data = dict(content=content, placement=placement, sid=sid, **kwargs)
|
|
136
153
|
return xpost('http://localhost:5001/add_relative_', data=data).text
|
|
137
154
|
|
|
138
155
|
# %% ../nbs/00_core.ipynb
|
|
@@ -174,7 +191,7 @@ def update_msg(
|
|
|
174
191
|
sid = kw.pop('sid', sid)
|
|
175
192
|
if not sid: raise TypeError("update_msg needs either a dict message or `sid=...`")
|
|
176
193
|
kw.pop('did', None)
|
|
177
|
-
add_msg(content, placement='update', sid=sid, **kw)
|
|
194
|
+
return add_msg(content, placement='update', sid=sid, **kw)
|
|
178
195
|
|
|
179
196
|
# %% ../nbs/00_core.ipynb
|
|
180
197
|
def load_gist(gist_id:str):
|
|
@@ -272,6 +289,7 @@ def import_dialog(fname, add_header=True):
|
|
|
272
289
|
def tool_info():
|
|
273
290
|
cts='''Tools available from `dialoghelper`:
|
|
274
291
|
|
|
292
|
+
- &`add_html`: Send HTML to the browser to be swapped into the DOM using hx-swap-oob.
|
|
275
293
|
- &`find_dialog_id`: Get the current dialog id.
|
|
276
294
|
- &`find_msg_id`: Get the current message id.
|
|
277
295
|
- &`find_msgs`: Find messages in current specific dialog that contain the given information.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dialoghelper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.16
|
|
4
4
|
Summary: Helper functions for solveit dialogs
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/dialoghelper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -18,7 +18,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
18
18
|
Requires-Python: >=3.9
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
|
-
Requires-Dist: fastcore
|
|
21
|
+
Requires-Dist: fastcore>=1.8.5
|
|
22
22
|
Requires-Dist: fastlite
|
|
23
23
|
Requires-Dist: ghapi
|
|
24
24
|
Requires-Dist: ipykernel-helper
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dialoghelper/__init__.py,sha256=EQiWUFoxrXghvJr_OC_Aq6XIWVNNQBYYPEmM1kQG0w8,43
|
|
2
|
+
dialoghelper/_modidx.py,sha256=il4I8H0rrleInprpaXaQ3Lyy4_C1ipPVQvaZ8WopN7I,3126
|
|
3
|
+
dialoghelper/core.py,sha256=2RhFkbnxUkMep4Imf_Qe3zEDxmd3QJk2uc0PZgmddzQ,12978
|
|
4
|
+
dialoghelper/db_dc.py,sha256=ieSie_K1HHXACEJVZ0rMkD_uo42GgmMqqKDYrodjhtM,2297
|
|
5
|
+
dialoghelper-0.0.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
+
dialoghelper-0.0.16.dist-info/METADATA,sha256=L2Uiv1P4Z5fSDltxetRrzvzThTuet-y9QKC4t2_Oh4E,2565
|
|
7
|
+
dialoghelper-0.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
dialoghelper-0.0.16.dist-info/entry_points.txt,sha256=wvDeX-XTS_XVjWiiPQe6yVfmyNwy9eCr36ewp9baFIg,46
|
|
9
|
+
dialoghelper-0.0.16.dist-info/top_level.txt,sha256=VXLlkgltFs_q-XB9imt2G64I_-MPm1RnxlpvUWPuLKM,13
|
|
10
|
+
dialoghelper-0.0.16.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
dialoghelper/__init__.py,sha256=z-0Rh9e-quhc6YCgBCQPxO9WBChy0UBbaCcAmIPEqfE,43
|
|
2
|
-
dialoghelper/_modidx.py,sha256=BmhVoIv53snN6JQm_EzJp-bu793QuY7EZg2hKaq5_7E,3013
|
|
3
|
-
dialoghelper/core.py,sha256=suW06DOaGDxVH5cgxbue1Yj9HOJjj1m_fA0zSSR-Ecg,12260
|
|
4
|
-
dialoghelper/db_dc.py,sha256=ieSie_K1HHXACEJVZ0rMkD_uo42GgmMqqKDYrodjhtM,2297
|
|
5
|
-
dialoghelper-0.0.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
-
dialoghelper-0.0.14.dist-info/METADATA,sha256=EMdtA7E4bTfJiNRxabpas8Z1RX0GkyGhJw5fMyaT9tA,2558
|
|
7
|
-
dialoghelper-0.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
dialoghelper-0.0.14.dist-info/entry_points.txt,sha256=wvDeX-XTS_XVjWiiPQe6yVfmyNwy9eCr36ewp9baFIg,46
|
|
9
|
-
dialoghelper-0.0.14.dist-info/top_level.txt,sha256=VXLlkgltFs_q-XB9imt2G64I_-MPm1RnxlpvUWPuLKM,13
|
|
10
|
-
dialoghelper-0.0.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|