dialoghelper 0.0.18__tar.gz → 0.0.20__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.18
3
+ Version: 0.0.20
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.20"
2
+ from .core import *
@@ -10,6 +10,7 @@ d = { 'settings': { 'branch': 'main',
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
12
  'dialoghelper.core.call_endp': ('core.html#call_endp', 'dialoghelper/core.py'),
13
+ 'dialoghelper.core.curr_dialog': ('core.html#curr_dialog', 'dialoghelper/core.py'),
13
14
  'dialoghelper.core.del_msg': ('core.html#del_msg', 'dialoghelper/core.py'),
14
15
  'dialoghelper.core.find_msg_id': ('core.html#find_msg_id', 'dialoghelper/core.py'),
15
16
  'dialoghelper.core.find_msgs': ('core.html#find_msgs', 'dialoghelper/core.py'),
@@ -1,8 +1,8 @@
1
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
2
2
 
3
3
  # %% auto 0
4
- __all__ = ['Placements', 'empty', 'find_var', 'call_endp', 'find_msgs', 'find_msg_id', 'msg_idx', 'read_msg', 'add_html',
5
- 'del_msg', 'add_msg', 'update_msg', 'load_gist', 'gist_file', 'import_string', 'is_usable_tool',
4
+ __all__ = ['Placements', 'empty', 'find_var', 'call_endp', 'curr_dialog', 'find_msgs', 'find_msg_id', 'msg_idx', 'read_msg',
5
+ 'add_html', 'del_msg', 'add_msg', 'update_msg', 'load_gist', 'gist_file', 'import_string', 'is_usable_tool',
6
6
  'mk_toollist', 'import_gist', 'tool_info', 'asdict']
7
7
 
8
8
  # %% ../nbs/00_core.ipynb
@@ -42,13 +42,20 @@ def call_endp(path, json=False, raiseex=False, **data):
42
42
  if raiseex: res.raise_for_status()
43
43
  return res.json() if json else res.text
44
44
 
45
+ # %% ../nbs/00_core.ipynb
46
+ def curr_dialog(
47
+ with_messages:bool=False # Include messages as well?
48
+ ):
49
+ "Get the current dialog info."
50
+ return call_endp('curr_dialog_', json=True, with_messages=with_messages)
51
+
45
52
  # %% ../nbs/00_core.ipynb
46
53
  def find_msgs(
47
54
  re_pattern:str='', # Optional regex to search for (re.DOTALL+re.MULTILINE is used)
48
55
  msg_type:str=None, # optional limit by message type ('code', 'note', or 'prompt')
49
56
  limit:int=None, # Optionally limit number of returned items
50
57
  include_output:bool=True # Include output in returned dict?
51
- )->list[dict]:
58
+ ):
52
59
  "Find `list[dict]` of messages in current specific dialog that contain the given information. To refer to a message found later, use its `id` field."
53
60
  res = call_endp('find_msgs_', json=True, re_pattern=re_pattern, msg_type=msg_type, limit=limit)['msgs']
54
61
  if not include_output:
@@ -109,24 +116,28 @@ def add_msg(
109
116
  o_collapsed: int | None = 0, # Collapse output?
110
117
  heading_collapsed: int | None = 0, # Collapse heading section?
111
118
  pinned: int | None = 0, # Pin to context?
112
- **kwargs):
119
+ ):
113
120
  "Add/update a message to the queue to show after code execution completes."
114
121
  if placement not in ('at_start','at_end') and not msgid: msgid = find_msg_id()
115
122
  return call_endp(
116
123
  'add_relative_', content=content, placement=placement, msgid=msgid, msg_type=msg_type, output=output,
117
124
  time_run=time_run, is_exported=is_exported, skipped=skipped, pinned=pinned,
118
- i_collapsed=i_collapsed, o_collapsed=o_collapsed, heading_collapsed=heading_collapsed, **kwargs)
125
+ i_collapsed=i_collapsed, o_collapsed=o_collapsed, heading_collapsed=heading_collapsed)
119
126
 
120
127
  # %% ../nbs/00_core.ipynb
121
128
  @delegates(add_msg)
122
129
  def _add_msg_unsafe(
123
130
  content:str, # Content of the message (i.e the message prompt, code, or note text)
131
+ placement:str='add_after', # Can be 'add_after', 'add_before', 'at_start', 'at_end'
132
+ msgid:str=None, # id of message that placement is relative to (if None, uses current message)
124
133
  run:bool=False, # For prompts, send it to the AI; for code, execute it (*DANGEROUS -- be careful of what you run!)
125
134
  **kwargs
126
135
  ):
127
136
  """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).
128
137
  *WARNING*--This can execute arbitrary code, so check carefully what you run!--*WARNING"""
129
- return add_msg(content=content, run=run, **kwargs)
138
+ if placement not in ('at_start','at_end') and not msgid: msgid = find_msg_id()
139
+ return call_endp(
140
+ 'add_relative_', content=content, placement=placement, msgid=msgid, run=run, **kwargs)
130
141
 
131
142
  # %% ../nbs/00_core.ipynb
132
143
  def _umsg(
@@ -224,8 +235,8 @@ def import_gist(
224
235
  def tool_info():
225
236
  cts='''Tools available from `dialoghelper`:
226
237
 
238
+ - &`curr_dialog`: Get the current dialog info.
227
239
  - &`add_html`: Send HTML to the browser to be swapped into the DOM using hx-swap-oob.
228
- - &`find_dialog_id`: Get the current dialog id.
229
240
  - &`find_msg_id`: Get the current message id.
230
241
  - &`find_msgs`: Find messages in current specific dialog that contain the given information.
231
242
  - &`read_msg`: Get the message indexed in the current dialog.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dialoghelper
3
- Version: 0.0.18
3
+ Version: 0.0.20
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.18
4
+ version = 0.0.20
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.18"
2
- from .core import *
File without changes
File without changes
File without changes
File without changes
File without changes