dialoghelper 0.0.6__tar.gz → 0.0.8__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.6/dialoghelper.egg-info → dialoghelper-0.0.8}/PKG-INFO +1 -1
- dialoghelper-0.0.8/dialoghelper/__init__.py +2 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper/_modidx.py +1 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper/core.py +47 -33
- {dialoghelper-0.0.6 → dialoghelper-0.0.8/dialoghelper.egg-info}/PKG-INFO +1 -1
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/settings.ini +1 -1
- dialoghelper-0.0.6/dialoghelper/__init__.py +0 -2
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/LICENSE +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/MANIFEST.in +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/README.md +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/SOURCES.txt +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/requires.txt +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/pyproject.toml +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/setup.cfg +0 -0
- {dialoghelper-0.0.6 → dialoghelper-0.0.8}/setup.py +0 -0
|
@@ -6,6 +6,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/dialoghelper',
|
|
7
7
|
'lib_path': 'dialoghelper'},
|
|
8
8
|
'syms': { 'dialoghelper.core': { 'dialoghelper.core._msg': ('core.html#_msg', 'dialoghelper/core.py'),
|
|
9
|
+
'dialoghelper.core._umsg': ('core.html#_umsg', 'dialoghelper/core.py'),
|
|
9
10
|
'dialoghelper.core.add_html': ('core.html#add_html', 'dialoghelper/core.py'),
|
|
10
11
|
'dialoghelper.core.add_msg': ('core.html#add_msg', 'dialoghelper/core.py'),
|
|
11
12
|
'dialoghelper.core.find_dialog_id': ('core.html#find_dialog_id', 'dialoghelper/core.py'),
|
|
@@ -47,14 +47,19 @@ def find_dialog_id():
|
|
|
47
47
|
|
|
48
48
|
# %% ../nbs/00_core.ipynb
|
|
49
49
|
def find_msgs(
|
|
50
|
-
pattern:
|
|
51
|
-
|
|
50
|
+
pattern:str='', # Optional text to search for
|
|
51
|
+
msg_type:str=None, # optional limit by message type ('code', 'note', or 'prompt')
|
|
52
|
+
limit:int=None, # Optionally limit number of returned items
|
|
53
|
+
include_output:bool=True # Include output in returned dict?
|
|
52
54
|
):
|
|
53
|
-
"Find messages in
|
|
55
|
+
"Find messages in current specific dialog that contain the given information. To refer to a message found later, use its `sid` field (which is the pk)."
|
|
54
56
|
did = find_dialog_id()
|
|
55
57
|
db = get_db()
|
|
56
58
|
res = db.t.message('did=? AND content LIKE ? ORDER BY mid', [did, f'%{pattern}%'], limit=limit)
|
|
57
|
-
|
|
59
|
+
res = [asdict(o) for o in res if not msg_type or (msg_type==o.msg_type)]
|
|
60
|
+
if not include_output:
|
|
61
|
+
for o in res: o.pop('output', None)
|
|
62
|
+
return res
|
|
58
63
|
|
|
59
64
|
# %% ../nbs/00_core.ipynb
|
|
60
65
|
def find_msg_id():
|
|
@@ -70,7 +75,7 @@ def read_msg_ids():
|
|
|
70
75
|
|
|
71
76
|
# %% ../nbs/00_core.ipynb
|
|
72
77
|
def msg_idx():
|
|
73
|
-
"Get index of current message in dialog."
|
|
78
|
+
"Get relative index of current message in dialog."
|
|
74
79
|
ids = read_msg_ids()
|
|
75
80
|
return ids,ids.index(find_msg_id())
|
|
76
81
|
|
|
@@ -89,27 +94,24 @@ def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)
|
|
|
89
94
|
|
|
90
95
|
# %% ../nbs/00_core.ipynb
|
|
91
96
|
def _msg(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
o_collapsed: int | None = 0,
|
|
100
|
-
header_collapsed: int | None = 0,
|
|
101
|
-
pinned: int | None = 0
|
|
97
|
+
time_run: str | None = '', # When was message executed
|
|
98
|
+
is_exported: int | None = 0, # Export message to a module?
|
|
99
|
+
skipped: int | None = 0, # Hide message from prompt?
|
|
100
|
+
i_collapsed: int | None = 0, # Collapse input?
|
|
101
|
+
o_collapsed: int | None = 0, # Collapse output?
|
|
102
|
+
header_collapsed: int | None = 0, # Collapse heading section?
|
|
103
|
+
pinned: int | None = 0 # Pin to context?
|
|
102
104
|
): ...
|
|
103
105
|
|
|
104
106
|
# %% ../nbs/00_core.ipynb
|
|
105
107
|
@delegates(_msg)
|
|
106
108
|
def add_msg(
|
|
107
|
-
content:str, #
|
|
108
|
-
msg_type: str='note', #
|
|
109
|
-
output:str='', #
|
|
110
|
-
placement:str='add_after', #
|
|
111
|
-
sid:str=None, # sid of message that placement is relative to (if None, uses current message)
|
|
112
|
-
**kwargs
|
|
109
|
+
content:str, # Content of the message (i.e the message prompt, code, or note text)
|
|
110
|
+
msg_type: str='note', # Message type, can be 'code', 'note', or 'prompt'
|
|
111
|
+
output:str='', # For prompts/code, initial output
|
|
112
|
+
placement:str='add_after', # Can be 'add_after', 'add_before', 'update', 'at_start', 'at_end'
|
|
113
|
+
sid:str=None, # sid (stable id -- pk) of message that placement is relative to (if None, uses current message)
|
|
114
|
+
**kwargs
|
|
113
115
|
):
|
|
114
116
|
"Add/update a message to the queue to show after code execution completes. Be sure to pass a `sid` (stable id) not a `mid` (which is used only for sorting, and can change)."
|
|
115
117
|
assert msg_type in ('note', 'code', 'prompt'), "msg_type must be 'code', 'note', or 'prompt'."
|
|
@@ -117,22 +119,34 @@ def add_msg(
|
|
|
117
119
|
run_cmd('add_msg', content=content, msg_type=msg_type, output=output, placement=placement, sid=sid, **kwargs)
|
|
118
120
|
|
|
119
121
|
# %% ../nbs/00_core.ipynb
|
|
120
|
-
|
|
122
|
+
def _umsg(
|
|
123
|
+
content:str|None = None, # Content of the message (i.e the message prompt, code, or note text)
|
|
124
|
+
msg_type: str|None = None, # Message type, can be 'code', 'note', or 'prompt'
|
|
125
|
+
output:str|None = None, # For prompts/code, the output
|
|
126
|
+
time_run: str | None = None, # When was message executed
|
|
127
|
+
is_exported: int | None = None, # Export message to a module?
|
|
128
|
+
skipped: int | None = None, # Hide message from prompt?
|
|
129
|
+
i_collapsed: int | None = None, # Collapse input?
|
|
130
|
+
o_collapsed: int | None = None, # Collapse output?
|
|
131
|
+
header_collapsed: int | None = None, # Collapse heading section?
|
|
132
|
+
pinned: int | None = None # Pin to context?
|
|
133
|
+
): ...
|
|
134
|
+
|
|
135
|
+
# %% ../nbs/00_core.ipynb
|
|
136
|
+
@delegates(_umsg)
|
|
121
137
|
def update_msg(
|
|
122
138
|
msg:Optional[Dict]=None, # Dictionary of field keys/values to update
|
|
123
|
-
sid:str=None, # sid
|
|
124
|
-
content:str=None, # content of the message (i.e the message prompt, code, or note text)
|
|
139
|
+
sid:str=None, # sid (stable id -- pk) of message to update (if None, uses current message)
|
|
125
140
|
**kwargs):
|
|
126
|
-
"Update an existing message. Provide either `msg` OR field key/values to update.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
kw = old | (msg or {}) | kwargs
|
|
141
|
+
"""Update an existing message. Provide either `msg` OR field key/values to update.
|
|
142
|
+
Use `content` param to update contents. Be sure to pass a `sid` (stable id -- the pk) not a `mid`
|
|
143
|
+
(which is used only for sorting, and can change).
|
|
144
|
+
Only include parameters to update--missing ones will be left unchanged."""
|
|
145
|
+
sid = msg.pop('sid', sid)
|
|
146
|
+
kw = (msg or {}) | kwargs
|
|
147
|
+
if not sid: raise TypeError("update_msg needs either a dict message or `sid=...`")
|
|
134
148
|
kw.pop('did', None)
|
|
135
|
-
|
|
149
|
+
run_cmd('add_msg', placement='update', sid=sid, **kw)
|
|
136
150
|
|
|
137
151
|
# %% ../nbs/00_core.ipynb
|
|
138
152
|
def add_html(
|
|
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
|