Skip to content

Commit 11022a8

Browse files
committed
fixes #17
1 parent 3f508f2 commit 11022a8

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

dialoghelper/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def find_msgs(
5757
msg_type:str=None, # optional limit by message type ('code', 'note', or 'prompt')
5858
limit:int=None, # Optionally limit number of returned items
5959
include_output:bool=True # Include output in returned dict?
60-
):
61-
"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)."
60+
)->list[dict]:
61+
"Find `list[dict]` of 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)."
6262
did = find_dialog_id()
6363
db = get_db()
6464
res = db.t.message('did=? AND content LIKE ? ORDER BY mid', [did, f'%{pattern}%'], limit=limit)
@@ -73,7 +73,7 @@ def find_msg_id():
7373
return find_var('__msg_id')
7474

7575
# %% ../nbs/00_core.ipynb
76-
def read_msg_ids():
76+
def read_msg_ids()->list[str]:
7777
"Get all ids in current dialog."
7878
did = find_dialog_id()
7979
db = get_db()
@@ -89,7 +89,7 @@ def msg_idx():
8989
def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)
9090
relative:bool=True # Is `n` relative to current message (True) or absolute (False)?
9191
):
92-
"Get the message indexed in the current dialog."
92+
"Get the `Message` object indexed in the current dialog."
9393
ids,idx = msg_idx()
9494
if relative:
9595
idx = idx+n
@@ -144,7 +144,7 @@ def _add_msg_unsafe(
144144
):
145145
"""Add/update a message to the queue to show after code execution completes, and optionally run it. Be sure to pass a `sid` (stable id) not a `mid` (which is used only for sorting, and can change).
146146
*WARNING*--This can execute arbitrary code, so check carefully what you run!--*WARNING"""
147-
add_msg(content=content, run=run, **kwargs)
147+
return add_msg(content=content, run=run, **kwargs)
148148

149149
# %% ../nbs/00_core.ipynb
150150
def _umsg(

nbs/00_core.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@
197197
" msg_type:str=None, # optional limit by message type ('code', 'note', or 'prompt')\n",
198198
" limit:int=None, # Optionally limit number of returned items\n",
199199
" include_output:bool=True # Include output in returned dict?\n",
200-
"):\n",
201-
" \"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).\"\n",
200+
")->list[dict]:\n",
201+
" \"Find `list[dict]` of 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).\"\n",
202202
" did = find_dialog_id()\n",
203203
" db = get_db()\n",
204204
" res = db.t.message('did=? AND content LIKE ? ORDER BY mid', [did, f'%{pattern}%'], limit=limit)\n",
@@ -297,7 +297,7 @@
297297
"outputs": [],
298298
"source": [
299299
"#| export\n",
300-
"def read_msg_ids():\n",
300+
"def read_msg_ids()->list[str]:\n",
301301
" \"Get all ids in current dialog.\"\n",
302302
" did = find_dialog_id()\n",
303303
" db = get_db()\n",
@@ -348,7 +348,7 @@
348348
"def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)\n",
349349
" relative:bool=True # Is `n` relative to current message (True) or absolute (False)?\n",
350350
" ):\n",
351-
" \"Get the message indexed in the current dialog.\"\n",
351+
" \"Get the `Message` object indexed in the current dialog.\"\n",
352352
" ids,idx = msg_idx()\n",
353353
" if relative:\n",
354354
" idx = idx+n\n",
@@ -462,7 +462,7 @@
462462
"):\n",
463463
" \"\"\"Add/update a message to the queue to show after code execution completes, and optionally run it. Be sure to pass a `sid` (stable id) not a `mid` (which is used only for sorting, and can change).\n",
464464
" *WARNING*--This can execute arbitrary code, so check carefully what you run!--*WARNING\"\"\"\n",
465-
" add_msg(content=content, run=run, **kwargs)"
465+
" return add_msg(content=content, run=run, **kwargs)"
466466
]
467467
},
468468
{

0 commit comments

Comments
 (0)