= get_db(globals())
db = db.t.dialog.fetchone()
dlg dlg
Dialog(id=1, name='test dialog', mode=2)
get_db (ns:dict=None)
find_var (var:str)
Search for var in all frames of the call stack
find_dialog_id ()
*Get the dialog id by searching the call stack for __dialog_id.*
find_msgs (pattern:str, limit:int=10)
Find messages in a specific dialog that contain the given pattern.
Type | Default | Details | |
---|---|---|---|
pattern | str | Text to search for | |
limit | int | 10 | Limit number of returned items |
Message(id='msg-a2', sid='_vZxms608LW0aPR_nvIlgqQ', content='*Hello* to the **world**!', output='', input_tokens=13, output_tokens=0, msg_type='note', time_run='', is_exported=0, skipped=1, did=1, i_collapsed=0, o_collapsed=0, header_collapsed=0, pinned=0)
find_msg_id ()
*Get the message id by searching the call stack for __dialog_id.*
read_msg_ids ()
Get all ids in current dialog.
msg_idx ()
Get index of current message in dialog.
read_msg (n:int=-1, relative:bool=True)
Get the message indexed in the current dialog.
Type | Default | Details | |
---|---|---|---|
n | int | -1 | Message index (if relative, +ve is downwards) |
relative | bool | True | Is n relative to current message (True) or absolute (False)? |
Message(id='msg-a1', sid='_I7jB6TkkVt4_sTuQRmhSVw', content='hello world', output='', input_tokens=3, output_tokens=0, msg_type='note', time_run='', is_exported=0, skipped=0, did=1, i_collapsed=0, o_collapsed=0, header_collapsed=0, pinned=0)
Message(id='msg-a4', sid='_dZzeZrrPs9ALH5Fjzp-1fw', content='How do I create a new instance?', output='', input_tokens=0, output_tokens=0, msg_type='note', time_run='', is_exported=0, skipped=0, did=1, i_collapsed=0, o_collapsed=0, header_collapsed=0, pinned=0)
add_msg (content:str, msg_type:str='note', output='', placement='add_after', msg_id:str=None)
Add/update a message to the queue to show after code execution completes.
Type | Default | Details | |
---|---|---|---|
content | str | message that we are updating or adding before/after | |
msg_type | str | note | message type, can be ‘code’, ‘note’, or ‘prompt’ |
output | str | for prompts/code, initial output | |
placement | str | add_after | can be ‘add_after’, ‘add_before’, ‘update’, ‘at_start’, ‘at_end’ |
msg_id | str | None | id of message that placement is relative to (if None, uses current message) |
update_msg (msg:dict)
Update an existing message in the dialog.
add_html (html:str)
Dynamically add HTML to the current web page. Supports HTMX attrs too.
Type | Details | |
---|---|---|
html | str | HTML to add to the DOM |
load_gist (gist_id:str)
Retrieve a gist
'https://gist.github.com/jph00/e7cfd4ded593e8ef6217e78a0131960c'
gist_file (gist_id:str)
Get the first file from a gist
import_string (code:str, name:str)
Type | Details | |
---|---|---|
code | str | Code to import as a module |
name | str | Name of module to create |
import_gist (gist_id:str, mod_name:str=None, add_global:bool=True)
Import gist directly from string without saving to disk
Type | Default | Details | |
---|---|---|---|
gist_id | str | user/id or just id of gist to import as a module | |
mod_name | str | None | module name to create (taken from gist filename if not passed) |
add_global | bool | True | add module to caller’s globals? |