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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dialoghelper
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Helper functions for solveit dialogs
5
5
  Home-page: https://github.com/AnswerDotAI/dialoghelper
6
6
  Author: Jeremy Howard
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.8"
2
+ from .core import *
@@ -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: str, # Text to search for
51
- limit:int=10 # Limit number of returned items
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 a specific dialog that contain the given pattern. To refer to a message found later, use its `sid` field."
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
- return [asdict(o) for o in res]
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
- input_tokens: int | None = 0,
93
- output_tokens: int | None = 0,
94
- time_run: str | None = '',
95
- is_exported: int | None = 0,
96
- skipped: int | None = 0,
97
- did: int | None = None,
98
- i_collapsed: int | None = 0,
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, # content of the message (i.e the message prompt, code, or note text)
108
- msg_type: str='note', # message type, can be 'code', 'note', or 'prompt'
109
- output:str='', # for prompts/code, initial output
110
- placement:str='add_after', # can be 'add_after', 'add_before', 'update', 'at_start', 'at_end'
111
- sid:str=None, # sid of message that placement is relative to (if None, uses current message)
112
- **kwargs # additional Message fields such as skipped i/o_collapsed, etc, passed through to the server
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
- @delegates(add_msg)
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 of message that placement is relative to (if None, uses current message)
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. Use `content` param to update contents. Be sure to pass a `sid` (stable id) not a `mid` (which is used only for sorting, and can change)."
127
- if content: kwargs['content']=content
128
- assert bool(msg)^bool(kwargs), "Provide *either* msg, for kwargs, not both"
129
- if msg and 'sid' in msg: target_id = msg['sid']
130
- elif sid: target_id = sid
131
- else: raise TypeError("update_msg needs either a dict message or `sid=...`")
132
- old = asdict(get_db().t.message[target_id])
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
- return add_msg(placement='update', **kw)
149
+ run_cmd('add_msg', placement='update', sid=sid, **kw)
136
150
 
137
151
  # %% ../nbs/00_core.ipynb
138
152
  def add_html(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dialoghelper
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Helper functions for solveit dialogs
5
5
  Home-page: https://github.com/AnswerDotAI/dialoghelper
6
6
  Author: Jeremy Howard
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = dialoghelper
3
3
  lib_name = dialoghelper
4
- version = 0.0.6
4
+ version = 0.0.8
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.6"
2
- from .core import *
File without changes
File without changes
File without changes
File without changes
File without changes