dialoghelper 0.0.9__py3-none-any.whl → 0.0.11__py3-none-any.whl
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/__init__.py +1 -1
- dialoghelper/_modidx.py +4 -1
- dialoghelper/core.py +32 -2
- dialoghelper/db_dc.py +91 -0
- {dialoghelper-0.0.9.dist-info → dialoghelper-0.0.11.dist-info}/METADATA +1 -1
- dialoghelper-0.0.11.dist-info/RECORD +10 -0
- dialoghelper-0.0.9.dist-info/RECORD +0 -9
- {dialoghelper-0.0.9.dist-info → dialoghelper-0.0.11.dist-info}/WHEEL +0 -0
- {dialoghelper-0.0.9.dist-info → dialoghelper-0.0.11.dist-info}/entry_points.txt +0 -0
- {dialoghelper-0.0.9.dist-info → dialoghelper-0.0.11.dist-info}/licenses/LICENSE +0 -0
- {dialoghelper-0.0.9.dist-info → dialoghelper-0.0.11.dist-info}/top_level.txt +0 -0
dialoghelper/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.11"
|
|
2
2
|
from .core import *
|
dialoghelper/_modidx.py
CHANGED
|
@@ -9,16 +9,19 @@ d = { 'settings': { 'branch': 'main',
|
|
|
9
9
|
'dialoghelper.core._umsg': ('core.html#_umsg', 'dialoghelper/core.py'),
|
|
10
10
|
'dialoghelper.core.add_html': ('core.html#add_html', 'dialoghelper/core.py'),
|
|
11
11
|
'dialoghelper.core.add_msg': ('core.html#add_msg', 'dialoghelper/core.py'),
|
|
12
|
+
'dialoghelper.core.export_dialog': ('core.html#export_dialog', 'dialoghelper/core.py'),
|
|
12
13
|
'dialoghelper.core.find_dialog_id': ('core.html#find_dialog_id', 'dialoghelper/core.py'),
|
|
13
14
|
'dialoghelper.core.find_msg_id': ('core.html#find_msg_id', 'dialoghelper/core.py'),
|
|
14
15
|
'dialoghelper.core.find_msgs': ('core.html#find_msgs', 'dialoghelper/core.py'),
|
|
15
16
|
'dialoghelper.core.find_var': ('core.html#find_var', 'dialoghelper/core.py'),
|
|
16
17
|
'dialoghelper.core.get_db': ('core.html#get_db', 'dialoghelper/core.py'),
|
|
17
18
|
'dialoghelper.core.gist_file': ('core.html#gist_file', 'dialoghelper/core.py'),
|
|
19
|
+
'dialoghelper.core.import_dialog': ('core.html#import_dialog', 'dialoghelper/core.py'),
|
|
18
20
|
'dialoghelper.core.import_gist': ('core.html#import_gist', 'dialoghelper/core.py'),
|
|
19
21
|
'dialoghelper.core.import_string': ('core.html#import_string', 'dialoghelper/core.py'),
|
|
20
22
|
'dialoghelper.core.load_gist': ('core.html#load_gist', 'dialoghelper/core.py'),
|
|
21
23
|
'dialoghelper.core.msg_idx': ('core.html#msg_idx', 'dialoghelper/core.py'),
|
|
22
24
|
'dialoghelper.core.read_msg': ('core.html#read_msg', 'dialoghelper/core.py'),
|
|
23
25
|
'dialoghelper.core.read_msg_ids': ('core.html#read_msg_ids', 'dialoghelper/core.py'),
|
|
24
|
-
'dialoghelper.core.update_msg': ('core.html#update_msg', 'dialoghelper/core.py')}
|
|
26
|
+
'dialoghelper.core.update_msg': ('core.html#update_msg', 'dialoghelper/core.py')},
|
|
27
|
+
'dialoghelper.db_dc': {}}}
|
dialoghelper/core.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
|
-
__all__ = ['get_db', 'find_var', 'find_dialog_id', 'find_msgs', 'find_msg_id', 'read_msg_ids', 'msg_idx',
|
|
5
|
-
'update_msg', 'add_html', 'load_gist', 'gist_file', 'import_string', 'import_gist',
|
|
4
|
+
__all__ = ['Placements', 'get_db', 'find_var', 'find_dialog_id', 'find_msgs', 'find_msg_id', 'read_msg_ids', 'msg_idx',
|
|
5
|
+
'read_msg', 'add_msg', 'update_msg', 'add_html', 'load_gist', 'gist_file', 'import_string', 'import_gist',
|
|
6
|
+
'export_dialog', 'import_dialog', 'asdict']
|
|
6
7
|
|
|
7
8
|
# %% ../nbs/00_core.ipynb
|
|
8
9
|
import inspect, json, importlib, linecache
|
|
9
10
|
from typing import Dict
|
|
10
11
|
from tempfile import TemporaryDirectory
|
|
11
12
|
from ipykernel_helper import *
|
|
13
|
+
from dataclasses import dataclass
|
|
12
14
|
|
|
13
15
|
from fastcore.utils import *
|
|
14
16
|
from fastcore.meta import delegates
|
|
@@ -103,6 +105,8 @@ def _msg(
|
|
|
103
105
|
pinned: int | None = 0 # Pin to context?
|
|
104
106
|
): ...
|
|
105
107
|
|
|
108
|
+
Placements = str_enum('Placements', 'add_after', 'add_before', 'update', 'at_start', 'at_end')
|
|
109
|
+
|
|
106
110
|
# %% ../nbs/00_core.ipynb
|
|
107
111
|
@delegates(_msg)
|
|
108
112
|
def add_msg(
|
|
@@ -197,3 +201,29 @@ def import_gist(
|
|
|
197
201
|
module = import_string(fil['content'], mod_name)
|
|
198
202
|
if add_global: inspect.currentframe().f_back.f_globals[mod_name] = module
|
|
199
203
|
return module
|
|
204
|
+
|
|
205
|
+
# %% ../nbs/00_core.ipynb
|
|
206
|
+
__EXPORT_FIELDS = set('content output input_tokens output_tokens msg_type is_exported skipped pinned i_collapsed o_collapsed header_collapsed'.split())
|
|
207
|
+
|
|
208
|
+
__REQUIRED_FIELDS = set('content output msg_type'.split())
|
|
209
|
+
|
|
210
|
+
# %% ../nbs/00_core.ipynb
|
|
211
|
+
def export_dialog(filename: str, did:int=None):
|
|
212
|
+
"Export dialog messages and optionally attachments to JSON"
|
|
213
|
+
if did is None: did = find_dialog_id()
|
|
214
|
+
db = get_db()
|
|
215
|
+
msgs = db.t.message('did=? and (pinned=0 or pinned is null)', [did], order_by='mid')
|
|
216
|
+
msg_data = [{k:getattr(msg,k) for k in __EXPORT_FIELDS if hasattr(msg, k)}
|
|
217
|
+
for msg in msgs]
|
|
218
|
+
result = {'messages': msg_data, 'dialog_name': db.t.dialog[did].name}
|
|
219
|
+
with open(filename, 'w') as f: json.dump(result, f, indent=2)
|
|
220
|
+
|
|
221
|
+
# %% ../nbs/00_core.ipynb
|
|
222
|
+
def import_dialog(fname, add_header=True):
|
|
223
|
+
"Import dialog messages from JSON file using `add_msg`"
|
|
224
|
+
data = json.loads(Path(fname).read_text())
|
|
225
|
+
for msg in data['messages'][::-1]:
|
|
226
|
+
opts = {k:msg[k] for k in __EXPORT_FIELDS - __REQUIRED_FIELDS if k in msg}
|
|
227
|
+
add_msg(msg.get('content',''), msg.get('msg_type','note'), msg.get('output',''), 'at_end', **opts)
|
|
228
|
+
if add_header: add_msg(f"# Imported Dialog `{fname}`", 'note', placement='at_end')
|
|
229
|
+
return f"Imported {len(data['messages'])} messages"
|
dialoghelper/db_dc.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
__all__ = ["_Meta", "Attachment", "Completion", "Completion_Mode", "Context", "Dialog", "Message", "Secret", "User"]
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
@dataclass
|
|
4
|
+
class _Meta:
|
|
5
|
+
id: int | None = None
|
|
6
|
+
version: int | None = 0
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class Attachment:
|
|
10
|
+
id: str | None = None
|
|
11
|
+
data: bytes | None = None
|
|
12
|
+
content_type: str | None = None
|
|
13
|
+
sid: int | None = None
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Completion:
|
|
17
|
+
req_id: str | None = None
|
|
18
|
+
did: int | None = None
|
|
19
|
+
mid: int | None = None
|
|
20
|
+
mtype: str | None = None
|
|
21
|
+
pfx: str | None = None
|
|
22
|
+
sfx: str | None = None
|
|
23
|
+
ctx: str | None = ''
|
|
24
|
+
mode: str | None = None
|
|
25
|
+
comp: str | None = None
|
|
26
|
+
logprobs: str | None = None
|
|
27
|
+
status: str | None = None
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class Completion_Mode:
|
|
31
|
+
id: int | None = None
|
|
32
|
+
name: str | None = None
|
|
33
|
+
c_acceptichars: int | None = None
|
|
34
|
+
c_scon: int | None = None
|
|
35
|
+
c_triggerc: str | None = None
|
|
36
|
+
c_triggeronaccept: int | None = None
|
|
37
|
+
c_mftp: float | None = None
|
|
38
|
+
c_model: str | None = None
|
|
39
|
+
c_nlines: str | None = None
|
|
40
|
+
c_temp: float | None = None
|
|
41
|
+
p_acceptichars: int | None = None
|
|
42
|
+
p_scon: int | None = None
|
|
43
|
+
p_triggerc: str | None = None
|
|
44
|
+
p_triggeronaccept: int | None = None
|
|
45
|
+
p_mftp: float | None = None
|
|
46
|
+
p_model: str | None = None
|
|
47
|
+
p_nlines: str | None = None
|
|
48
|
+
p_temp: float | None = None
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class Context:
|
|
52
|
+
name: str | None = None
|
|
53
|
+
context: str | None = None
|
|
54
|
+
token_count: int | None = 0
|
|
55
|
+
did: int | None = None
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class Dialog:
|
|
59
|
+
id: int | None = None
|
|
60
|
+
name: str | None = None
|
|
61
|
+
mode: int | None = 2
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class Message:
|
|
65
|
+
sid: str | None = None
|
|
66
|
+
mid: str | None = None
|
|
67
|
+
content: str | None = None
|
|
68
|
+
output: str | None = ''
|
|
69
|
+
input_tokens: int | None = '0'
|
|
70
|
+
output_tokens: int | None = '0'
|
|
71
|
+
msg_type: str | None = 'code'
|
|
72
|
+
time_run: str | None = ''
|
|
73
|
+
is_exported: int | None = '0'
|
|
74
|
+
skipped: int | None = '0'
|
|
75
|
+
did: int | None = None
|
|
76
|
+
i_collapsed: int | None = '0'
|
|
77
|
+
o_collapsed: int | None = '0'
|
|
78
|
+
header_collapsed: int | None = '0'
|
|
79
|
+
pinned: int | None = '0'
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class Secret:
|
|
83
|
+
name: str | None = None
|
|
84
|
+
secret: str | None = None
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class User:
|
|
88
|
+
id: int | None = None
|
|
89
|
+
version: int | None = None
|
|
90
|
+
settings: str | None = None
|
|
91
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dialoghelper/__init__.py,sha256=pot8RlG0U4OhR3W-uFE3FF_SkXBM1i-NXq4JI4v6zdU,43
|
|
2
|
+
dialoghelper/_modidx.py,sha256=fZ9-eTMaLdG-nvxxTe9_qjLwKIGS9_FU7KpFyCiF7DU,2529
|
|
3
|
+
dialoghelper/core.py,sha256=515ndWh4b2vNEm1H6l5DBt4GWcqk3ILVo9zk8cEr3ig,9552
|
|
4
|
+
dialoghelper/db_dc.py,sha256=ieSie_K1HHXACEJVZ0rMkD_uo42GgmMqqKDYrodjhtM,2297
|
|
5
|
+
dialoghelper-0.0.11.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
+
dialoghelper-0.0.11.dist-info/METADATA,sha256=PY8bUCy8IiRCCmkHM_bW0hTtSdsbtZvMnoBxkBTnR0o,2558
|
|
7
|
+
dialoghelper-0.0.11.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
8
|
+
dialoghelper-0.0.11.dist-info/entry_points.txt,sha256=wvDeX-XTS_XVjWiiPQe6yVfmyNwy9eCr36ewp9baFIg,46
|
|
9
|
+
dialoghelper-0.0.11.dist-info/top_level.txt,sha256=VXLlkgltFs_q-XB9imt2G64I_-MPm1RnxlpvUWPuLKM,13
|
|
10
|
+
dialoghelper-0.0.11.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
dialoghelper/__init__.py,sha256=8v08jLbD8mgo8kbkFtp9fIlkDQsiovYgy2xWvMrgXWY,42
|
|
2
|
-
dialoghelper/_modidx.py,sha256=mYMJPTi5PlEZg_LHRYfaqtNWdvPb5i2MTvO5lNfpwtY,2245
|
|
3
|
-
dialoghelper/core.py,sha256=aCcqPiyaEzERXcxH3R40ZZ-fx_BYBCg1_i_kf3Z2KeE,8034
|
|
4
|
-
dialoghelper-0.0.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
-
dialoghelper-0.0.9.dist-info/METADATA,sha256=fEOFgODIDpG47_BAgNQq6QUxj5dj6P9WPZC0wyArLp8,2557
|
|
6
|
-
dialoghelper-0.0.9.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
7
|
-
dialoghelper-0.0.9.dist-info/entry_points.txt,sha256=wvDeX-XTS_XVjWiiPQe6yVfmyNwy9eCr36ewp9baFIg,46
|
|
8
|
-
dialoghelper-0.0.9.dist-info/top_level.txt,sha256=VXLlkgltFs_q-XB9imt2G64I_-MPm1RnxlpvUWPuLKM,13
|
|
9
|
-
dialoghelper-0.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|