Skip to content

Commit a59a5ef

Browse files
committed
refactor package for qbraid
1 parent 2d1dac5 commit a59a5ef

33 files changed

+214
-200
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
python -m pip install .[test]
3737
3838
jupyter server extension list
39-
jupyter server extension list 2>&1 | grep -ie "notebook_intelligence.*OK"
39+
jupyter server extension list 2>&1 | grep -ie "lab_notebook_intelligence.*OK"
4040
4141
jupyter labextension list
42-
jupyter labextension list 2>&1 | grep -ie "@notebook-intelligence/notebook-intelligence.*OK"
42+
jupyter labextension list 2>&1 | grep -ie "@qbraid/lab-notebook-intelligence.*OK"
4343
python -m jupyterlab.browser_check
4444
4545
- name: Package the extension
@@ -48,13 +48,13 @@ jobs:
4848
4949
pip install build
5050
python -m build
51-
pip uninstall -y "notebook_intelligence" jupyterlab
51+
pip uninstall -y "lab_notebook_intelligence" jupyterlab
5252
5353
- name: Upload extension packages
5454
uses: actions/upload-artifact@v4
5555
with:
5656
name: extension-artifacts
57-
path: dist/notebook_intelligence*
57+
path: dist/lab_notebook_intelligence*
5858
if-no-files-found: error
5959

6060
test_isolated:
@@ -77,14 +77,14 @@ jobs:
7777
sudo rm -rf $(which node)
7878
sudo rm -rf $(which node)
7979
80-
pip install "jupyterlab>=4.0.0,<5" notebook_intelligence*.whl
80+
pip install "jupyterlab>=4.0.0,<5" lab_notebook_intelligence*.whl
8181
8282
8383
jupyter server extension list
84-
jupyter server extension list 2>&1 | grep -ie "notebook_intelligence.*OK"
84+
jupyter server extension list 2>&1 | grep -ie "lab_notebook_intelligence.*OK"
8585
8686
jupyter labextension list
87-
jupyter labextension list 2>&1 | grep -ie "@notebook-intelligence/notebook-intelligence.*OK"
87+
jupyter labextension list 2>&1 | grep -ie "@qbraid/lab-notebook-intelligence.*OK"
8888
python -m jupyterlab.browser_check --no-browser-test
8989
9090

.github/workflows/upload-s3-production.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
if: matrix.python-version == '3.11'
6464
with:
6565
name: extension
66-
path: dist/quantum_jobs*.whl
66+
path: dist/lab_notebook_intelligence*.whl
6767
if-no-files-found: error
6868

6969
deploy:
@@ -87,5 +87,5 @@ jobs:
8787

8888
- name: Copy wheel file to S3 lab-extensions bucket
8989
run: |
90-
aws s3 rm s3://qbraid-lab-extensions/production/ --recursive --exclude "*" --include "notebook_intelligence*.whl"
91-
aws s3 cp ./ s3://qbraid-lab-extensions/production/ --recursive --exclude "*" --include "notebook_intelligence*.whl"
90+
aws s3 rm s3://qbraid-lab-extensions/production/ --recursive --exclude "*" --include "lab_notebook_intelligence*.whl"
91+
aws s3 cp ./ s3://qbraid-lab-extensions/production/ --recursive --exclude "*" --include "lab_notebook_intelligence*.whl"

.github/workflows/upload-s3-staging.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
if: matrix.python-version == '3.11'
6565
with:
6666
name: extension
67-
path: dist/notebook_intelligence*.whl
67+
path: dist/lab_notebook_intelligence*.whl
6868
if-no-files-found: error
6969

7070
deploy:
@@ -88,5 +88,5 @@ jobs:
8888

8989
- name: Copy wheel file to S3 lab-extensions bucket
9090
run: |
91-
aws s3 rm s3://qbraid-lab-extensions/staging/ --recursive --exclude "*" --include "notebook_intelligence*.whl"
92-
aws s3 cp ./ s3://qbraid-lab-extensions/staging/ --recursive --exclude "*" --include "notebook_intelligence*.whl"
91+
aws s3 rm s3://qbraid-lab-extensions/staging/ --recursive --exclude "*" --include "lab_notebook_intelligence*.whl"
92+
aws s3 cp ./ s3://qbraid-lab-extensions/staging/ --recursive --exclude "*" --include "lab_notebook_intelligence*.whl"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ node_modules/
77
*.egg-info/
88
.ipynb_checkpoints
99
*.tsbuildinfo
10-
notebook_intelligence/labextension
10+
lab_notebook_intelligence/labextension
1111
# Version file is handled by hatchling
12-
notebook_intelligence/_version.py
12+
lab_notebook_intelligence/_version.py
1313

1414
# Created by https://www.gitignore.io/api/python
1515
# Edit at https://www.gitignore.io/?templates=python

install.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"packageManager": "python",
3-
"packageName": "notebook_intelligence",
4-
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package notebook_intelligence"
3+
"packageName": "lab_notebook_intelligence",
4+
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package lab_notebook_intelligence"
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ServerApp": {
33
"jpserver_extensions": {
4-
"notebook_intelligence": true
4+
"lab_notebook_intelligence": true
55
}
66
}
77
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# in editable mode with pip. It is highly recommended to install
88
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
99
import warnings
10-
warnings.warn("Importing 'notebook_intelligence' outside a proper installation.")
10+
warnings.warn("Importing 'lab_notebook_intelligence' outside a proper installation.")
1111
__version__ = "dev"
1212

1313
import logging
@@ -19,12 +19,12 @@
1919
def _jupyter_labextension_paths():
2020
return [{
2121
"src": "labextension",
22-
"dest": "@notebook-intelligence/notebook-intelligence"
22+
"dest": "@qbraid/lab-notebook-intelligence"
2323
}]
2424

2525

2626
def _jupyter_server_extension_points():
2727
return [{
28-
"module": "notebook_intelligence",
28+
"module": "lab_notebook_intelligence",
2929
"app": NotebookIntelligence
3030
}]

notebook_intelligence/ai_service_manager.py renamed to lab_notebook_intelligence/ai_service_manager.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
import sys
77
from typing import Dict
88
import logging
9-
from notebook_intelligence import github_copilot
10-
from notebook_intelligence.api import ButtonData, ChatModel, EmbeddingModel, InlineCompletionModel, LLMProvider, ChatParticipant, ChatRequest, ChatResponse, CompletionContext, ContextRequest, Host, CompletionContextProvider, MCPServer, MarkdownData, NotebookIntelligenceExtension, TelemetryEvent, TelemetryListener, Tool, Toolset
11-
from notebook_intelligence.base_chat_participant import BaseChatParticipant
12-
from notebook_intelligence.config import NBIConfig
13-
from notebook_intelligence.github_copilot_chat_participant import GithubCopilotChatParticipant
14-
from notebook_intelligence.llm_providers.github_copilot_llm_provider import GitHubCopilotLLMProvider
15-
from notebook_intelligence.llm_providers.litellm_compatible_llm_provider import LiteLLMCompatibleLLMProvider
16-
from notebook_intelligence.llm_providers.ollama_llm_provider import OllamaLLMProvider
17-
from notebook_intelligence.llm_providers.openai_compatible_llm_provider import OpenAICompatibleLLMProvider
18-
from notebook_intelligence.mcp_manager import MCPManager
9+
from lab_notebook_intelligence import github_copilot
10+
from lab_notebook_intelligence.api import ButtonData, ChatModel, EmbeddingModel, InlineCompletionModel, LLMProvider, ChatParticipant, ChatRequest, ChatResponse, CompletionContext, ContextRequest, Host, CompletionContextProvider, MCPServer, MarkdownData, NotebookIntelligenceExtension, TelemetryEvent, TelemetryListener, Tool, Toolset
11+
from lab_notebook_intelligence.base_chat_participant import BaseChatParticipant
12+
from lab_notebook_intelligence.config import NBIConfig
13+
from lab_notebook_intelligence.github_copilot_chat_participant import GithubCopilotChatParticipant
14+
from lab_notebook_intelligence.llm_providers.github_copilot_llm_provider import GitHubCopilotLLMProvider
15+
from lab_notebook_intelligence.llm_providers.litellm_compatible_llm_provider import LiteLLMCompatibleLLMProvider
16+
from lab_notebook_intelligence.llm_providers.ollama_llm_provider import OllamaLLMProvider
17+
from lab_notebook_intelligence.llm_providers.openai_compatible_llm_provider import OpenAICompatibleLLMProvider
18+
from lab_notebook_intelligence.mcp_manager import MCPManager
1919

2020
log = logging.getLogger(__name__)
2121

@@ -288,7 +288,7 @@ def get_chat_participant(self, prompt: str) -> ChatParticipant:
288288
async def handle_chat_request(self, request: ChatRequest, response: ChatResponse, options: dict = {}) -> None:
289289
if self.chat_model is None:
290290
response.stream(MarkdownData("Chat model is not set!"))
291-
response.stream(ButtonData("Configure", "notebook-intelligence:open-configuration-dialog"))
291+
response.stream(ButtonData("Configure", "lab-notebook-intelligence:open-configuration-dialog"))
292292
response.finish()
293293
return
294294
request.host = self
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) Mehmet Bektas <[email protected]>
22

33
import asyncio
4-
import json
54
from typing import Any, Callable, Dict, Union
65
from dataclasses import asdict, dataclass
76
from enum import Enum
@@ -10,7 +9,7 @@
109
import logging
1110
from mcp.server.fastmcp.tools import Tool as MCPToolClass
1211

13-
from notebook_intelligence.config import NBIConfig
12+
from lab_notebook_intelligence.config import NBIConfig
1413

1514
log = logging.getLogger(__name__)
1615

notebook_intelligence/base_chat_participant.py renamed to lab_notebook_intelligence/base_chat_participant.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import os
44
from typing import Union
55
import 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
88
import base64
99
import 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

1414
log = 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

201201
class 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

310310
class 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

Comments
 (0)