33import os
44from typing import Union
55import json
6- from notebook_intelligence .api import ChatCommand , ChatParticipant , ChatRequest , ChatResponse , MarkdownData , ProgressData , Tool , ToolPreInvokeResponse
7- from notebook_intelligence .prompts import Prompts
6+ from lab_notebook_intelligence .api import ChatCommand , ChatParticipant , ChatRequest , ChatResponse , MarkdownData , ProgressData , Tool , ToolPreInvokeResponse
7+ from lab_notebook_intelligence .prompts import Prompts
88import base64
99import logging
10- from notebook_intelligence .built_in_toolsets import built_in_toolsets
10+ from lab_notebook_intelligence .built_in_toolsets import built_in_toolsets
1111
12- from notebook_intelligence .util import extract_llm_generated_code
12+ from lab_notebook_intelligence .util import extract_llm_generated_code
1313
1414log = logging .getLogger (__name__ )
1515
@@ -120,17 +120,17 @@ def pre_invoke(self, request: ChatRequest, tool_args: dict) -> Union[ToolPreInvo
120120 async def handle_tool_call (self , request : ChatRequest , response : ChatResponse , tool_context : dict , tool_args : dict ) -> str :
121121 cell_sources = tool_args .get ('cell_sources' , [])
122122
123- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:create-new-notebook-from-py' , {'code' : '' })
123+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:create-new-notebook-from-py' , {'code' : '' })
124124 file_path = ui_cmd_response ['path' ]
125125
126126 for cell_source in cell_sources :
127127 cell_type = cell_source .get ('cell_type' )
128128 if cell_type == 'markdown' :
129129 source = cell_source .get ('source' , '' )
130- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : source , 'path' : file_path })
130+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : source , 'path' : file_path })
131131 elif cell_type == 'code' :
132132 source = cell_source .get ('source' , '' )
133- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-code-cell-to-notebook' , {'code' : source , 'path' : file_path })
133+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-code-cell-to-notebook' , {'code' : source , 'path' : file_path })
134134
135135 return "Notebook created successfully at {file_path}"
136136
@@ -195,7 +195,7 @@ async def handle_tool_call(self, request: ChatRequest, response: ChatResponse, t
195195 if notebook_file_path .startswith (server_root_dir ):
196196 notebook_file_path = os .path .relpath (notebook_file_path , server_root_dir )
197197 source = tool_args .get ('markdown_cell_source' )
198- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : source , 'path' : notebook_file_path })
198+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : source , 'path' : notebook_file_path })
199199 return f"Added markdown cell to notebook"
200200
201201class AddCodeCellTool (Tool ):
@@ -259,7 +259,7 @@ async def handle_tool_call(self, request: ChatRequest, response: ChatResponse, t
259259 if notebook_file_path .startswith (server_root_dir ):
260260 notebook_file_path = os .path .relpath (notebook_file_path , server_root_dir )
261261 source = tool_args .get ('code_cell_source' )
262- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-code-cell-to-notebook' , {'code' : source , 'path' : notebook_file_path })
262+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-code-cell-to-notebook' , {'code' : source , 'path' : notebook_file_path })
263263 return "Added code cell added to notebook"
264264
265265# Fallback tool to handle tool errors
@@ -304,7 +304,7 @@ def schema(self) -> dict:
304304
305305 async def handle_tool_call (self , request : ChatRequest , response : ChatResponse , tool_context : dict , tool_args : dict ) -> str :
306306 code = tool_args .get ('code_cell_source' )
307- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-code-cell-to-notebook' , {'code' : code , 'path' : tool_context .get ('file_path' )})
307+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-code-cell-to-notebook' , {'code' : code , 'path' : tool_context .get ('file_path' )})
308308 return {"result" : "Code cell added to notebook" }
309309
310310class BaseChatParticipant (ChatParticipant ):
@@ -426,14 +426,14 @@ async def handle_ask_mode_chat_request(self, request: ChatRequest, response: Cha
426426 chat_model = request .host .chat_model
427427 if request .command == 'newNotebook' :
428428 # create a new notebook
429- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:create-new-notebook-from-py' , {'code' : '' })
429+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:create-new-notebook-from-py' , {'code' : '' })
430430 file_path = ui_cmd_response ['path' ]
431431
432432 code = await self .generate_code_cell (request )
433433 markdown = await self .generate_markdown_for_code (request , code )
434434
435- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : markdown , 'path' : file_path })
436- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:add-code-cell-to-notebook' , {'code' : code , 'path' : file_path })
435+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-markdown-cell-to-notebook' , {'markdown' : markdown , 'path' : file_path })
436+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:add-code-cell-to-notebook' , {'code' : code , 'path' : file_path })
437437
438438 response .stream (MarkdownData (f"Notebook '{ file_path } ' created and opened successfully" ))
439439 response .finish ()
@@ -447,13 +447,13 @@ async def handle_ask_mode_chat_request(self, request: ChatRequest, response: Cha
447447 generated = chat_model .completions (messages )
448448 code = generated ['choices' ][0 ]['message' ]['content' ]
449449 code = extract_llm_generated_code (code )
450- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:create-new-file' , {'code' : code })
450+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:create-new-file' , {'code' : code })
451451 file_path = ui_cmd_response ['path' ]
452452 response .stream (MarkdownData (f"File '{ file_path } ' created successfully" ))
453453 response .finish ()
454454 return
455455 elif request .command == 'settings' :
456- ui_cmd_response = await response .run_ui_command ('notebook-intelligence:open-configuration-dialog' )
456+ ui_cmd_response = await response .run_ui_command ('lab- notebook-intelligence:open-configuration-dialog' )
457457 response .stream (MarkdownData (f"Opened the settings dialog" ))
458458 response .finish ()
459459 return
0 commit comments