Skip to content

Commit 52e3b14

Browse files
committed
Use StopResponse
1 parent 420fb12 commit 52e3b14

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

dialoghelper/core.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
22

33
# %% auto #0
4-
__all__ = ['dname_doc', 'md_cls_d', 'dh_settings', 'pyrun', 'Placements', 'mermaid_url', 'msg_insert_line', 'file_insert_line',
4+
__all__ = ['dname_doc', 'md_cls_d', 'dh_settings', 'Placements', 'mermaid_url', 'msg_insert_line', 'file_insert_line',
55
'msg_str_replace', 'file_str_replace', 'msg_strs_replace', 'file_strs_replace', 'msg_replace_lines',
66
'file_replace_lines', 'msg_del_lines', 'file_del_lines', 'msg_pyrun', 'file_pyrun', 'msg_ast_replace',
77
'file_ast_replace', 'add_styles', 'find_dname', 'xposta', 'xgeta', 'call_endp', 'call_endpa', 'curr_dialog',
@@ -37,10 +37,10 @@
3737
from toolslm.xml import *
3838
from fasthtml.common import *
3939
from fasthtml.components import Solveit_input
40-
from lisette.core import ToolResponse
40+
from lisette.core import ToolResponse,FullResponse,StopResponse
4141
from urllib.parse import urlencode
4242
from fastcore.imports import __llmtools__
43-
from safepyrun import RunPython,allow,find_var,create_pyrun_magic
43+
from safepyrun import RunPython,allow,find_var,create_pyrun_magic,load_ipython_extension
4444

4545
# %% ../nbs/00_core.ipynb #e54b45ad
4646
dname_doc = """If `dname` is None, the current dialog is used. If it is an open dialog, it will be updated interactively with real-time updates to the browser. If it is a closed dialog, it will be updated on disk. Dialog names must be paths relative to solveit root (if starting with `/`, e.g. `/myproject/dlg`) or relative to the current dialog's folder (if not starting with `/`), and should *not* include the .ipynb extension. **Use absolute paths when targeting dialogs outside the current dialog's folder tree.**"""
@@ -68,10 +68,13 @@ def add_styles(s:str, cls_map:dict=None):
6868
dh_settings = {'port':5001}
6969
# dh_settings = {'port':6001}
7070

71-
# %% ../nbs/00_core.ipynb #6e5226c1
72-
pyrun = RunPython(sentinel='__dialog_name')
73-
try: create_pyrun_magic(get_ipython(), pyrun=pyrun)
71+
# %% ../nbs/00_core.ipynb #f5cd76ed
72+
try: load_ipython_extension(get_ipython())
7473
except NameError: pass
74+
75+
# pyrun = RunPython(sentinel='__dialog_name')
76+
# try: create_pyrun_magic(get_ipython(), pyrun=pyrun)
77+
# except NameError: pass
7578
__llmtools__.add('pyrun')
7679

7780
# %% ../nbs/00_core.ipynb #65a8b58b
@@ -453,11 +456,12 @@ async def del_msg(
453456
# %% ../nbs/00_core.ipynb #30e90bf9
454457
async def run_and_prompt(
455458
code: str, # Python code to run
456-
prompt: str = ".", # Prompt to add after code execution
459+
prompt: str = "Continue.", # Prompt to add after code execution
457460
) -> str:
458461
"Run `code` and then run `prompt`, returning the resulting message ID."
459462
id = await add_msg(code, msg_type="code", run=True)
460-
return await add_msg(prompt, msg_type="prompt", run=True, id=id)
463+
await add_msg(prompt, msg_type="prompt", run=True, id=id)
464+
return StopResponse('Code has been added and queued for execution. Tool loop is finishing now. Summarize progress so far and planned next steps, and await "Continue." prompt.')
461465

462466
# %% ../nbs/00_core.ipynb #023dcb74
463467
def _umsg(

nbs/00_core.ipynb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
"from toolslm.xml import *\n",
5858
"from fasthtml.common import *\n",
5959
"from fasthtml.components import Solveit_input\n",
60-
"from lisette.core import ToolResponse\n",
60+
"from lisette.core import ToolResponse,FullResponse,StopResponse\n",
6161
"from urllib.parse import urlencode\n",
6262
"from fastcore.imports import __llmtools__\n",
63-
"from safepyrun import RunPython,allow,find_var,create_pyrun_magic"
63+
"from safepyrun import RunPython,allow,find_var,create_pyrun_magic,load_ipython_extension"
6464
]
6565
},
6666
{
@@ -262,14 +262,17 @@
262262
{
263263
"cell_type": "code",
264264
"execution_count": null,
265-
"id": "6e5226c1",
265+
"id": "f5cd76ed",
266266
"metadata": {},
267267
"outputs": [],
268268
"source": [
269269
"#| export\n",
270-
"pyrun = RunPython(sentinel='__dialog_name')\n",
271-
"try: create_pyrun_magic(get_ipython(), pyrun=pyrun)\n",
270+
"try: load_ipython_extension(get_ipython())\n",
272271
"except NameError: pass\n",
272+
"\n",
273+
"# pyrun = RunPython(sentinel='__dialog_name')\n",
274+
"# try: create_pyrun_magic(get_ipython(), pyrun=pyrun)\n",
275+
"# except NameError: pass\n",
273276
"__llmtools__.add('pyrun')"
274277
]
275278
},
@@ -1379,11 +1382,12 @@
13791382
"#| export\n",
13801383
"async def run_and_prompt(\n",
13811384
" code: str, # Python code to run\n",
1382-
" prompt: str = \".\", # Prompt to add after code execution\n",
1385+
" prompt: str = \"Continue.\", # Prompt to add after code execution\n",
13831386
") -> str:\n",
13841387
" \"Run `code` and then run `prompt`, returning the resulting message ID.\"\n",
13851388
" id = await add_msg(code, msg_type=\"code\", run=True)\n",
1386-
" return await add_msg(prompt, msg_type=\"prompt\", run=True, id=id)"
1389+
" await add_msg(prompt, msg_type=\"prompt\", run=True, id=id)\n",
1390+
" return StopResponse('Code has been added and queued for execution. Tool loop is finishing now. Summarize progress so far and planned next steps, and await \"Continue.\" prompt.')"
13871391
]
13881392
},
13891393
{

0 commit comments

Comments
 (0)