dialoghelper 0.0.2__tar.gz → 0.0.3__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.
- {dialoghelper-0.0.2/dialoghelper.egg-info → dialoghelper-0.0.3}/PKG-INFO +1 -1
- dialoghelper-0.0.3/dialoghelper/__init__.py +2 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper/_modidx.py +2 -1
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper/core.py +23 -9
- {dialoghelper-0.0.2 → dialoghelper-0.0.3/dialoghelper.egg-info}/PKG-INFO +1 -1
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/settings.ini +1 -1
- dialoghelper-0.0.2/dialoghelper/__init__.py +0 -2
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/LICENSE +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/MANIFEST.in +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/README.md +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/SOURCES.txt +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/requires.txt +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/pyproject.toml +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/setup.cfg +0 -0
- {dialoghelper-0.0.2 → dialoghelper-0.0.3}/setup.py +0 -0
|
@@ -5,7 +5,8 @@ d = { 'settings': { 'branch': 'main',
|
|
|
5
5
|
'doc_host': 'https://AnswerDotAI.github.io',
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/dialoghelper',
|
|
7
7
|
'lib_path': 'dialoghelper'},
|
|
8
|
-
'syms': { 'dialoghelper.core': { 'dialoghelper.core.
|
|
8
|
+
'syms': { 'dialoghelper.core': { 'dialoghelper.core.add_html': ('core.html#add_html', 'dialoghelper/core.py'),
|
|
9
|
+
'dialoghelper.core.add_msg': ('core.html#add_msg', 'dialoghelper/core.py'),
|
|
9
10
|
'dialoghelper.core.find_dialog_id': ('core.html#find_dialog_id', 'dialoghelper/core.py'),
|
|
10
11
|
'dialoghelper.core.find_msg_id': ('core.html#find_msg_id', 'dialoghelper/core.py'),
|
|
11
12
|
'dialoghelper.core.find_msgs': ('core.html#find_msgs', 'dialoghelper/core.py'),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['get_db', 'find_var', 'find_dialog_id', 'find_msgs', 'find_msg_id', 'read_msg_ids', 'msg_idx', 'read_msg', 'add_msg',
|
|
5
|
-
'update_msg', 'load_gist', 'gist_file', 'import_string', 'import_gist']
|
|
5
|
+
'update_msg', 'add_html', 'load_gist', 'gist_file', 'import_string', 'import_gist']
|
|
6
6
|
|
|
7
7
|
# %% ../nbs/00_core.ipynb
|
|
8
8
|
import inspect, json, importlib, linecache
|
|
@@ -15,7 +15,8 @@ from fastlite import *
|
|
|
15
15
|
|
|
16
16
|
# %% ../nbs/00_core.ipynb
|
|
17
17
|
def get_db(ns:dict=None):
|
|
18
|
-
|
|
18
|
+
app_path = Path('/app') if Path('/.dockerenv').exists() else Path('.')
|
|
19
|
+
if os.environ.get('IN_SOLVEIT', False): dataparent,nm = app_path, 'data.db'
|
|
19
20
|
else: dataparent,nm = Path('..'),'dev_data.db'
|
|
20
21
|
db = database(dataparent/'data'/nm)
|
|
21
22
|
dcs = [o for o in all_dcs(db) if o.__name__[0]!='_']
|
|
@@ -45,6 +46,7 @@ def find_msgs(
|
|
|
45
46
|
):
|
|
46
47
|
"Find messages in a specific dialog that contain the given pattern."
|
|
47
48
|
did = find_dialog_id()
|
|
49
|
+
db = get_db()
|
|
48
50
|
return db.t.message('did=? AND content LIKE ?', [did, f'%{pattern}%'], limit=limit)
|
|
49
51
|
|
|
50
52
|
# %% ../nbs/00_core.ipynb
|
|
@@ -56,6 +58,7 @@ def find_msg_id():
|
|
|
56
58
|
def read_msg_ids():
|
|
57
59
|
"Get all ids in current dialog."
|
|
58
60
|
did = find_dialog_id()
|
|
61
|
+
db = get_db()
|
|
59
62
|
return [o.sid for o in db.t.message('did=?', [did], select='sid', order_by='id')]
|
|
60
63
|
|
|
61
64
|
# %% ../nbs/00_core.ipynb
|
|
@@ -74,6 +77,7 @@ def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)
|
|
|
74
77
|
idx = idx+n
|
|
75
78
|
if not 0<=idx<len(ids): return None
|
|
76
79
|
else: idx = n
|
|
80
|
+
db = get_db()
|
|
77
81
|
return db.t.message.fetchone('sid=?', [ids[idx]])
|
|
78
82
|
|
|
79
83
|
# %% ../nbs/00_core.ipynb
|
|
@@ -82,19 +86,29 @@ def add_msg(
|
|
|
82
86
|
msg_type: str='note', # message type, can be 'code', 'note', or 'prompt'
|
|
83
87
|
output='', # for prompts/code, initial output
|
|
84
88
|
placement='add_after', # can be 'add_after', 'add_before', 'update', 'at_start', 'at_end'
|
|
85
|
-
msg_id:str=None # id of message that placement is relative to (if None, uses current message)
|
|
89
|
+
msg_id:str=None, # id of message that placement is relative to (if None, uses current message)
|
|
90
|
+
**kw # Additional Message fields such as skipped i/o_collapsed, etc, passed through to the server
|
|
86
91
|
):
|
|
87
92
|
"Add/update a message to the queue to show after code execution completes."
|
|
88
93
|
assert msg_type in ('note', 'code', 'prompt'), "msg_type must be 'code', 'note', or 'prompt'."
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
run_cmd('add_msg', **kwargs)
|
|
94
|
+
# kwargs = {'msg_id':msg_id} if msg_id else {}
|
|
95
|
+
run_cmd('add_msg', content=content, msg_type=msg_type, output=output, placement=placement, msg_id=msg_id, **kw)
|
|
92
96
|
|
|
93
97
|
# %% ../nbs/00_core.ipynb
|
|
94
|
-
def update_msg(msg:dict):
|
|
98
|
+
def update_msg(msg: dict):
|
|
95
99
|
"Update an existing message in the dialog."
|
|
96
|
-
if not isinstance(msg,dict): msg = asdict(msg)
|
|
97
|
-
|
|
100
|
+
if not isinstance(msg, dict): msg = asdict(msg)
|
|
101
|
+
exclude = {'id', 'content', 'msg_type', 'output'} # explicit args
|
|
102
|
+
kw = {k: v for k, v in msg.items() if k not in exclude}
|
|
103
|
+
add_msg(content=msg['content'], msg_type=msg['msg_type'], output=msg['output'],
|
|
104
|
+
placement = 'update', msg_id=msg['id'], **kw)
|
|
105
|
+
|
|
106
|
+
# %% ../nbs/00_core.ipynb
|
|
107
|
+
def add_html(
|
|
108
|
+
html:str, # HTML to add to the DOM
|
|
109
|
+
):
|
|
110
|
+
"Dynamically add HTML to the current web page. Supports HTMX attrs too."
|
|
111
|
+
run_cmd('add_ft', html=html)
|
|
98
112
|
|
|
99
113
|
# %% ../nbs/00_core.ipynb
|
|
100
114
|
def load_gist(gist_id:str):
|
|
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
|