dialoghelper 0.0.1__tar.gz → 0.0.2__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.1/dialoghelper.egg-info → dialoghelper-0.0.2}/PKG-INFO +1 -1
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper/core.py +27 -14
- {dialoghelper-0.0.1 → dialoghelper-0.0.2/dialoghelper.egg-info}/PKG-INFO +1 -1
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/settings.ini +14 -22
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/LICENSE +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/MANIFEST.in +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/README.md +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper/__init__.py +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper/_modidx.py +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/SOURCES.txt +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/requires.txt +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/pyproject.toml +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/setup.cfg +0 -0
- {dialoghelper-0.0.1 → dialoghelper-0.0.2}/setup.py +0 -0
|
@@ -14,15 +14,17 @@ from ghapi.all import *
|
|
|
14
14
|
from fastlite import *
|
|
15
15
|
|
|
16
16
|
# %% ../nbs/00_core.ipynb
|
|
17
|
-
def get_db():
|
|
17
|
+
def get_db(ns:dict=None):
|
|
18
18
|
if os.environ.get('IN_SOLVEIT', False): dataparent,nm = Path('/app'),'data.db'
|
|
19
19
|
else: dataparent,nm = Path('..'),'dev_data.db'
|
|
20
20
|
db = database(dataparent/'data'/nm)
|
|
21
|
-
all_dcs(db)
|
|
21
|
+
dcs = [o for o in all_dcs(db) if o.__name__[0]!='_']
|
|
22
|
+
if ns:
|
|
23
|
+
for o in dcs: ns[o.__name__]=o
|
|
22
24
|
return db
|
|
23
25
|
|
|
24
26
|
# %% ../nbs/00_core.ipynb
|
|
25
|
-
def find_var(var:
|
|
27
|
+
def find_var(var:str):
|
|
26
28
|
"Search for var in all frames of the call stack"
|
|
27
29
|
frame = inspect.currentframe()
|
|
28
30
|
while frame:
|
|
@@ -37,7 +39,10 @@ def find_dialog_id():
|
|
|
37
39
|
return find_var('__dialog_id')
|
|
38
40
|
|
|
39
41
|
# %% ../nbs/00_core.ipynb
|
|
40
|
-
def find_msgs(
|
|
42
|
+
def find_msgs(
|
|
43
|
+
pattern: str, # Text to search for
|
|
44
|
+
limit:int=10 # Limit number of returned items
|
|
45
|
+
):
|
|
41
46
|
"Find messages in a specific dialog that contain the given pattern."
|
|
42
47
|
did = find_dialog_id()
|
|
43
48
|
return db.t.message('did=? AND content LIKE ?', [did, f'%{pattern}%'], limit=limit)
|
|
@@ -60,8 +65,8 @@ def msg_idx():
|
|
|
60
65
|
return ids,ids.index(find_msg_id())
|
|
61
66
|
|
|
62
67
|
# %% ../nbs/00_core.ipynb
|
|
63
|
-
def read_msg(n:
|
|
64
|
-
relative=True # Is `n` relative to current message (True) or absolute (False)?
|
|
68
|
+
def read_msg(n:int=-1, # Message index (if relative, +ve is downwards)
|
|
69
|
+
relative:bool=True # Is `n` relative to current message (True) or absolute (False)?
|
|
65
70
|
):
|
|
66
71
|
"Get the message indexed in the current dialog."
|
|
67
72
|
ids,idx = msg_idx()
|
|
@@ -77,7 +82,7 @@ def add_msg(
|
|
|
77
82
|
msg_type: str='note', # message type, can be 'code', 'note', or 'prompt'
|
|
78
83
|
output='', # for prompts/code, initial output
|
|
79
84
|
placement='add_after', # can be 'add_after', 'add_before', 'update', 'at_start', 'at_end'
|
|
80
|
-
msg_id=None
|
|
85
|
+
msg_id:str=None # id of message that placement is relative to (if None, uses current message)
|
|
81
86
|
):
|
|
82
87
|
"Add/update a message to the queue to show after code execution completes."
|
|
83
88
|
assert msg_type in ('note', 'code', 'prompt'), "msg_type must be 'code', 'note', or 'prompt'."
|
|
@@ -86,26 +91,30 @@ def add_msg(
|
|
|
86
91
|
run_cmd('add_msg', **kwargs)
|
|
87
92
|
|
|
88
93
|
# %% ../nbs/00_core.ipynb
|
|
89
|
-
def update_msg(msg):
|
|
94
|
+
def update_msg(msg:dict):
|
|
90
95
|
"Update an existing message in the dialog."
|
|
91
|
-
|
|
96
|
+
if not isinstance(msg,dict): msg = asdict(msg)
|
|
97
|
+
add_msg(content=msg['content'], msg_type=msg['msg_type'], output=msg['output'], placement='update', msg_id=msg['id'])
|
|
92
98
|
|
|
93
99
|
# %% ../nbs/00_core.ipynb
|
|
94
|
-
def load_gist(gist_id):
|
|
95
|
-
"
|
|
100
|
+
def load_gist(gist_id:str):
|
|
101
|
+
"Retrieve a gist"
|
|
96
102
|
api = GhApi()
|
|
97
103
|
if '/' in gist_id: *_,user,gist_id = gist_id.split('/')
|
|
98
104
|
else: user = None
|
|
99
105
|
return api.gists.get(gist_id, user=user)
|
|
100
106
|
|
|
101
107
|
# %% ../nbs/00_core.ipynb
|
|
102
|
-
def gist_file(gist_id):
|
|
108
|
+
def gist_file(gist_id:str):
|
|
103
109
|
"Get the first file from a gist"
|
|
104
110
|
gist = load_gist(gist_id)
|
|
105
111
|
return first(gist.files.values())
|
|
106
112
|
|
|
107
113
|
# %% ../nbs/00_core.ipynb
|
|
108
|
-
def import_string(
|
|
114
|
+
def import_string(
|
|
115
|
+
code:str, # Code to import as a module
|
|
116
|
+
name:str # Name of module to create
|
|
117
|
+
):
|
|
109
118
|
with TemporaryDirectory() as tmpdir:
|
|
110
119
|
path = Path(tmpdir) / f"{name}.py"
|
|
111
120
|
path.write_text(code)
|
|
@@ -118,7 +127,11 @@ def import_string(code, name):
|
|
|
118
127
|
return module
|
|
119
128
|
|
|
120
129
|
# %% ../nbs/00_core.ipynb
|
|
121
|
-
def import_gist(
|
|
130
|
+
def import_gist(
|
|
131
|
+
gist_id:str, # user/id or just id of gist to import as a module
|
|
132
|
+
mod_name:str=None, # module name to create (taken from gist filename if not passed)
|
|
133
|
+
add_global:bool=True # add module to caller's globals?
|
|
134
|
+
):
|
|
122
135
|
"Import gist directly from string without saving to disk"
|
|
123
136
|
fil = gist_file(gist_id)
|
|
124
137
|
mod_name = mod_name or Path(fil['filename']).stem
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
|
-
# All sections below are required unless otherwise specified.
|
|
3
|
-
# See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
|
|
4
|
-
|
|
5
|
-
### Python library ###
|
|
6
2
|
repo = dialoghelper
|
|
7
|
-
lib_name =
|
|
8
|
-
version = 0.0.
|
|
3
|
+
lib_name = dialoghelper
|
|
4
|
+
version = 0.0.2
|
|
9
5
|
min_python = 3.9
|
|
10
6
|
license = apache2
|
|
11
7
|
black_formatting = False
|
|
12
8
|
requirements = fastcore fastlite ghapi ipykernel-helper
|
|
13
|
-
|
|
14
|
-
### nbdev ###
|
|
15
9
|
doc_path = _docs
|
|
16
10
|
lib_path = dialoghelper
|
|
17
11
|
nbs_path = nbs
|
|
@@ -20,28 +14,26 @@ tst_flags = notest
|
|
|
20
14
|
put_version_in_init = True
|
|
21
15
|
update_pyproject = True
|
|
22
16
|
cell_number = False
|
|
23
|
-
|
|
24
|
-
### Docs ###
|
|
25
17
|
branch = main
|
|
26
18
|
custom_sidebar = False
|
|
27
|
-
doc_host = https
|
|
28
|
-
doc_baseurl =
|
|
29
|
-
git_url = https://github.com
|
|
30
|
-
title =
|
|
31
|
-
|
|
32
|
-
### PyPI ###
|
|
19
|
+
doc_host = https://AnswerDotAI.github.io
|
|
20
|
+
doc_baseurl = /dialoghelper
|
|
21
|
+
git_url = https://github.com/AnswerDotAI/dialoghelper
|
|
22
|
+
title = dialoghelper
|
|
33
23
|
audience = Developers
|
|
34
24
|
author = Jeremy Howard
|
|
35
25
|
author_email = github@jhoward.fastmail.fm
|
|
36
|
-
copyright = 2025 onwards,
|
|
26
|
+
copyright = 2025 onwards, Jeremy Howard
|
|
37
27
|
description = Helper functions for solveit dialogs
|
|
38
28
|
keywords = nbdev jupyter notebook python
|
|
39
29
|
language = English
|
|
40
30
|
status = 3
|
|
41
31
|
user = AnswerDotAI
|
|
32
|
+
readme_nb = index.ipynb
|
|
33
|
+
allowed_metadata_keys =
|
|
34
|
+
allowed_cell_metadata_keys =
|
|
35
|
+
jupyter_hooks = False
|
|
36
|
+
clean_ids = True
|
|
37
|
+
clear_all = False
|
|
38
|
+
skip_procs =
|
|
42
39
|
|
|
43
|
-
### Optional ###
|
|
44
|
-
# dev_requirements =
|
|
45
|
-
# console_scripts =
|
|
46
|
-
# conda_user =
|
|
47
|
-
# package_data =
|
|
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
|
|
File without changes
|
|
File without changes
|