notebook-intelligence 2.0.0__tar.gz → 2.2.0__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.
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/PKG-INFO +1 -1
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/_version.py +1 -1
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/ai_service_manager.py +4 -1
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/api.py +41 -4
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/base_chat_participant.py +13 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/extension.py +6 -2
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/github_copilot.py +59 -8
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/package.json +2 -2
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/package.json.orig +1 -1
- notebook_intelligence-2.2.0/notebook_intelligence/labextension/static/144.ea73716e650ab32a5118.js +1 -0
- notebook_intelligence-2.2.0/notebook_intelligence/labextension/static/728.2f7d112a9c63a34d9d0f.js +1 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/editor.worker.js +1 -1
- notebook_intelligence-2.0.0/notebook_intelligence/labextension/static/remoteEntry.b74af6ffebdf89f8260e.js → notebook_intelligence-2.2.0/notebook_intelligence/labextension/static/remoteEntry.83c8fe1714ab92a47234.js +1 -1
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/mcp_manager.py +5 -6
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/package.json +1 -1
- notebook_intelligence-2.0.0/notebook_intelligence/labextension/static/144.a6cea595a297f34e5c97.js +0 -1
- notebook_intelligence-2.0.0/notebook_intelligence/labextension/static/728.854cf1bcc3651b9e8c96.js +0 -1
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/.copier-answers.yml +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/.gitignore +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/.prettierignore +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/.yarnrc.yml +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/CHANGELOG.md +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/CONTRIBUTING.md +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/LICENSE +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/README.md +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/RELEASE.md +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/install.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/jupyter-config/server-config/notebook_intelligence.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/__init__.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/built_in_toolsets.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/config.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/github_copilot_chat_participant.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/schemas/@notebook-intelligence/notebook-intelligence/plugin.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/172.5e09e00fc564d61e8782.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/196.db3f5562c0372c6e07f6.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/1b55f12eca93ba6743e7.ttf +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/326.4de77f44c9c6c2bbad47.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/327.fe6b84491254fcaf64bf.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/671.1797d409270b24758991.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/694.d0b052d80c0397c7f1ea.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/977.7e3d66ffc344a0af7a4e.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/be02dcbf2787b0b29ec8.module.wasm +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/e589c9ba04e3e5a90081.module.wasm +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/editor.worker.js.LICENSE.txt +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/style.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/labextension/static/third-party-licenses.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/llm_providers/github_copilot_llm_provider.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/llm_providers/litellm_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/llm_providers/ollama_llm_provider.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/llm_providers/openai_compatible_llm_provider.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/prompts.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/util.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/pyproject.toml +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/schema/plugin.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/setup.py +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/tsconfig.json +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/webpack.config.js +0 -0
- {notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/yarn.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: notebook_intelligence
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: AI coding assistant for JupyterLab
|
|
5
5
|
Project-URL: Homepage, https://github.com/notebook-intelligence/notebook-intelligence
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/notebook-intelligence/notebook-intelligence/issues
|
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
from typing import Dict
|
|
8
8
|
import logging
|
|
9
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, MarkdownData, NotebookIntelligenceExtension, TelemetryEvent, TelemetryListener, Tool, Toolset
|
|
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
11
|
from notebook_intelligence.base_chat_participant import BaseChatParticipant
|
|
12
12
|
from notebook_intelligence.config import NBIConfig
|
|
13
13
|
from notebook_intelligence.github_copilot_chat_participant import GithubCopilotChatParticipant
|
|
@@ -326,6 +326,9 @@ class AIServiceManager(Host):
|
|
|
326
326
|
def get_mcp_servers(self):
|
|
327
327
|
return self._mcp_manager.get_mcp_servers()
|
|
328
328
|
|
|
329
|
+
def get_mcp_server(self, server_name: str) -> MCPServer:
|
|
330
|
+
return self._mcp_manager.get_mcp_server(server_name)
|
|
331
|
+
|
|
329
332
|
def get_mcp_server_tool(self, server_name: str, tool_name: str) -> Tool:
|
|
330
333
|
mcp_server = self._mcp_manager.get_mcp_server(server_name)
|
|
331
334
|
if mcp_server is not None:
|
|
@@ -324,7 +324,7 @@ class Toolset:
|
|
|
324
324
|
self.tools.remove(tool)
|
|
325
325
|
|
|
326
326
|
class SimpleTool(Tool):
|
|
327
|
-
def __init__(self, tool_function: Callable, name: str, description: str, schema: dict, title: str = None, auto_approve: bool = False):
|
|
327
|
+
def __init__(self, tool_function: Callable, name: str, description: str, schema: dict, title: str = None, auto_approve: bool = False, has_var_args: bool = False):
|
|
328
328
|
super().__init__()
|
|
329
329
|
self._tool_function = tool_function
|
|
330
330
|
self._name = name
|
|
@@ -332,6 +332,7 @@ class SimpleTool(Tool):
|
|
|
332
332
|
self._schema = schema
|
|
333
333
|
self._title = title
|
|
334
334
|
self._auto_approve = auto_approve
|
|
335
|
+
self._has_var_args = has_var_args
|
|
335
336
|
|
|
336
337
|
@property
|
|
337
338
|
def name(self) -> str:
|
|
@@ -363,9 +364,30 @@ class SimpleTool(Tool):
|
|
|
363
364
|
|
|
364
365
|
async def handle_tool_call(self, request: ChatRequest, response: ChatResponse, tool_context: dict, tool_args: dict) -> str:
|
|
365
366
|
fn_args = tool_args.copy()
|
|
366
|
-
|
|
367
|
+
if self._has_var_args:
|
|
368
|
+
fn_args.update({"request": request, "response": response})
|
|
367
369
|
return await self._tool_function(**fn_args)
|
|
368
370
|
|
|
371
|
+
class MCPServer:
|
|
372
|
+
@property
|
|
373
|
+
def name(self) -> str:
|
|
374
|
+
return NotImplemented
|
|
375
|
+
|
|
376
|
+
async def connect(self):
|
|
377
|
+
return NotImplemented
|
|
378
|
+
|
|
379
|
+
async def disconnect(self):
|
|
380
|
+
return NotImplemented
|
|
381
|
+
|
|
382
|
+
def get_tools(self) -> list[Tool]:
|
|
383
|
+
return NotImplemented
|
|
384
|
+
|
|
385
|
+
def get_tool(self, tool_name: str) -> Tool:
|
|
386
|
+
return NotImplemented
|
|
387
|
+
|
|
388
|
+
async def call_tool(self, tool_name: str, tool_args: dict):
|
|
389
|
+
return NotImplemented
|
|
390
|
+
|
|
369
391
|
def auto_approve(tool: SimpleTool):
|
|
370
392
|
"""
|
|
371
393
|
Decorator to set auto_approve to True for a tool.
|
|
@@ -375,18 +397,24 @@ def auto_approve(tool: SimpleTool):
|
|
|
375
397
|
|
|
376
398
|
def tool(tool_function: Callable) -> SimpleTool:
|
|
377
399
|
mcp_tool = MCPToolClass.from_function(tool_function)
|
|
400
|
+
has_var_args = False
|
|
401
|
+
if "args" in mcp_tool.parameters["properties"]:
|
|
402
|
+
has_var_args = True
|
|
403
|
+
del mcp_tool.parameters["properties"]["args"]
|
|
404
|
+
if "args" in mcp_tool.parameters["required"]:
|
|
405
|
+
mcp_tool.parameters["required"].remove("args")
|
|
378
406
|
|
|
379
407
|
schema = {
|
|
380
408
|
"type": "function",
|
|
381
409
|
"function": {
|
|
382
410
|
"name": mcp_tool.name,
|
|
383
411
|
"description": mcp_tool.description,
|
|
384
|
-
"strict":
|
|
412
|
+
"strict": False,
|
|
385
413
|
"parameters": mcp_tool.parameters
|
|
386
414
|
},
|
|
387
415
|
}
|
|
388
416
|
|
|
389
|
-
return SimpleTool(tool_function, mcp_tool.name, mcp_tool.description, schema, mcp_tool.name, auto_approve)
|
|
417
|
+
return SimpleTool(tool_function, mcp_tool.name, mcp_tool.description, schema, mcp_tool.name, auto_approve, has_var_args)
|
|
390
418
|
|
|
391
419
|
class ChatMode:
|
|
392
420
|
def __init__(self, id: str, name: str, instructions: str = None):
|
|
@@ -451,6 +479,9 @@ class ChatParticipant:
|
|
|
451
479
|
|
|
452
480
|
async def _tool_call_loop(tool_call_rounds: list):
|
|
453
481
|
try:
|
|
482
|
+
if request.cancel_token.is_cancel_requested:
|
|
483
|
+
return
|
|
484
|
+
|
|
454
485
|
tool_response = request.host.chat_model.completions(messages, openai_tools, cancel_token=request.cancel_token, options=options)
|
|
455
486
|
# after first call, set tool_choice to auto
|
|
456
487
|
options['tool_choice'] = 'auto'
|
|
@@ -468,6 +499,9 @@ class ChatParticipant:
|
|
|
468
499
|
|
|
469
500
|
# handle first tool calls
|
|
470
501
|
while len(tool_call_rounds) > 0:
|
|
502
|
+
if request.cancel_token.is_cancel_requested:
|
|
503
|
+
return
|
|
504
|
+
|
|
471
505
|
tool_call = tool_call_rounds[0]
|
|
472
506
|
if "id" not in tool_call:
|
|
473
507
|
tool_call['id'] = uuid.uuid4().hex
|
|
@@ -729,6 +763,9 @@ class Host:
|
|
|
729
763
|
def embedding_model(self) -> EmbeddingModel:
|
|
730
764
|
raise NotImplemented
|
|
731
765
|
|
|
766
|
+
def get_mcp_server(self, server_name: str) -> MCPServer:
|
|
767
|
+
return NotImplemented
|
|
768
|
+
|
|
732
769
|
def get_mcp_server_tool(self, server_name: str, tool_name: str) -> Tool:
|
|
733
770
|
return NotImplemented
|
|
734
771
|
|
|
@@ -407,8 +407,21 @@ class BaseChatParticipant(ChatParticipant):
|
|
|
407
407
|
|
|
408
408
|
options = options.copy()
|
|
409
409
|
options["system_prompt"] = system_prompt
|
|
410
|
+
|
|
411
|
+
mcp_servers_used = []
|
|
412
|
+
for server_name in request.tool_selection.mcp_server_tools.keys():
|
|
413
|
+
mcp_server = request.host.get_mcp_server(server_name)
|
|
414
|
+
if mcp_server not in mcp_servers_used:
|
|
415
|
+
mcp_servers_used.append(mcp_server)
|
|
416
|
+
|
|
417
|
+
for mcp_server in mcp_servers_used:
|
|
418
|
+
await mcp_server.connect()
|
|
419
|
+
|
|
410
420
|
await self.handle_chat_request_with_tools(request, response, options)
|
|
411
421
|
|
|
422
|
+
for mcp_server in mcp_servers_used:
|
|
423
|
+
await mcp_server.disconnect()
|
|
424
|
+
|
|
412
425
|
async def handle_ask_mode_chat_request(self, request: ChatRequest, response: ChatResponse, options: dict = {}) -> None:
|
|
413
426
|
chat_model = request.host.chat_model
|
|
414
427
|
if request.command == 'newNotebook':
|
{notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/extension.py
RENAMED
|
@@ -34,8 +34,10 @@ class GetCapabilitiesHandler(APIHandler):
|
|
|
34
34
|
nbi_config = ai_service_manager.nbi_config
|
|
35
35
|
llm_providers = ai_service_manager.llm_providers.values()
|
|
36
36
|
mcp_servers = ai_service_manager.get_mcp_servers()
|
|
37
|
-
mcp_server_tools = [{"id": mcp_server.name, "tools": [tool.name for tool in mcp_server.get_tools()]} for mcp_server in mcp_servers]
|
|
37
|
+
mcp_server_tools = [{"id": mcp_server.name, "tools": [{"name": tool.name, "description": tool.description} for tool in mcp_server.get_tools()]} for mcp_server in mcp_servers]
|
|
38
38
|
mcp_server_tools = [tool for tool in mcp_server_tools if len(tool["tools"]) > 0]
|
|
39
|
+
# sort by server id
|
|
40
|
+
mcp_server_tools.sort(key=lambda server: server["id"])
|
|
39
41
|
|
|
40
42
|
extensions = []
|
|
41
43
|
for extension_id, toolsets in ai_service_manager.get_extension_toolsets().items():
|
|
@@ -43,7 +45,7 @@ class GetCapabilitiesHandler(APIHandler):
|
|
|
43
45
|
for toolset in toolsets:
|
|
44
46
|
tools = []
|
|
45
47
|
for tool in toolset.tools:
|
|
46
|
-
tools.append(tool.name)
|
|
48
|
+
tools.append({"name": tool.name, "description": tool.description})
|
|
47
49
|
ts.append({
|
|
48
50
|
"id": toolset.id,
|
|
49
51
|
"name": toolset.name,
|
|
@@ -55,6 +57,8 @@ class GetCapabilitiesHandler(APIHandler):
|
|
|
55
57
|
"name": extension.name,
|
|
56
58
|
"toolsets": ts
|
|
57
59
|
})
|
|
60
|
+
# sort by extension id
|
|
61
|
+
extensions.sort(key=lambda extension: extension["id"])
|
|
58
62
|
|
|
59
63
|
response = {
|
|
60
64
|
"using_github_copilot_service": nbi_config.using_github_copilot_service,
|
{notebook_intelligence-2.0.0 → notebook_intelligence-2.2.0}/notebook_intelligence/github_copilot.py
RENAMED
|
@@ -412,8 +412,58 @@ def inline_completions(model_id, prefix, suffix, language, filename, context: Co
|
|
|
412
412
|
|
|
413
413
|
return result
|
|
414
414
|
|
|
415
|
+
def _aggregate_streaming_response(client: sseclient.SSEClient) -> dict:
|
|
416
|
+
final_tool_calls = []
|
|
417
|
+
final_content = ''
|
|
418
|
+
|
|
419
|
+
def _format_llm_response():
|
|
420
|
+
for tool_call in final_tool_calls:
|
|
421
|
+
if 'arguments' in tool_call['function'] and tool_call['function']['arguments'] == '':
|
|
422
|
+
tool_call['function']['arguments'] = '{}'
|
|
423
|
+
|
|
424
|
+
return {
|
|
425
|
+
"choices": [
|
|
426
|
+
{
|
|
427
|
+
"message": {
|
|
428
|
+
"tool_calls": final_tool_calls if len(final_tool_calls) > 0 else None,
|
|
429
|
+
"content": final_content,
|
|
430
|
+
"role": "assistant"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
for event in client.events():
|
|
437
|
+
if event.data == '[DONE]':
|
|
438
|
+
return _format_llm_response()
|
|
439
|
+
|
|
440
|
+
chunk = json.loads(event.data)
|
|
441
|
+
if len(chunk['choices']) == 0:
|
|
442
|
+
continue
|
|
443
|
+
|
|
444
|
+
content_chunk = chunk['choices'][0]['delta'].get('content')
|
|
445
|
+
if content_chunk:
|
|
446
|
+
final_content += content_chunk
|
|
447
|
+
|
|
448
|
+
for tool_call in chunk['choices'][0]['delta'].get('tool_calls', []):
|
|
449
|
+
if 'index' not in tool_call:
|
|
450
|
+
continue
|
|
451
|
+
|
|
452
|
+
index = tool_call['index']
|
|
453
|
+
|
|
454
|
+
if index >= len(final_tool_calls):
|
|
455
|
+
tc = tool_call.copy()
|
|
456
|
+
if 'arguments' not in tc:
|
|
457
|
+
tc['function']['arguments'] = ''
|
|
458
|
+
final_tool_calls.append(tc)
|
|
459
|
+
else:
|
|
460
|
+
if 'arguments' in tool_call['function']:
|
|
461
|
+
final_tool_calls[index]['function']['arguments'] += tool_call['function']['arguments']
|
|
462
|
+
|
|
463
|
+
return _format_llm_response()
|
|
464
|
+
|
|
415
465
|
def completions(model_id, messages, tools = None, response: ChatResponse = None, cancel_token: CancelToken = None, options: dict = {}) -> Any:
|
|
416
|
-
|
|
466
|
+
aggregate = response is None
|
|
417
467
|
|
|
418
468
|
try:
|
|
419
469
|
data = {
|
|
@@ -426,7 +476,7 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
426
476
|
'n': 1,
|
|
427
477
|
'stop': ['<END>'],
|
|
428
478
|
'nwo': 'NotebookIntelligence',
|
|
429
|
-
'stream':
|
|
479
|
+
'stream': True
|
|
430
480
|
}
|
|
431
481
|
|
|
432
482
|
if 'tool_choice' in options:
|
|
@@ -434,12 +484,13 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
434
484
|
|
|
435
485
|
if cancel_token is not None and cancel_token.is_cancel_requested:
|
|
436
486
|
response.finish()
|
|
487
|
+
return
|
|
437
488
|
|
|
438
489
|
request = requests.post(
|
|
439
490
|
f"{API_ENDPOINT}/chat/completions",
|
|
440
491
|
headers = generate_copilot_headers(),
|
|
441
492
|
json = data,
|
|
442
|
-
stream =
|
|
493
|
+
stream = True
|
|
443
494
|
)
|
|
444
495
|
|
|
445
496
|
if request.status_code != 200:
|
|
@@ -449,8 +500,10 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
449
500
|
response.finish()
|
|
450
501
|
raise Exception(msg)
|
|
451
502
|
|
|
452
|
-
|
|
453
|
-
|
|
503
|
+
client = sseclient.SSEClient(request)
|
|
504
|
+
if aggregate:
|
|
505
|
+
return _aggregate_streaming_response(client)
|
|
506
|
+
else:
|
|
454
507
|
for event in client.events():
|
|
455
508
|
if cancel_token is not None and cancel_token.is_cancel_requested:
|
|
456
509
|
response.finish()
|
|
@@ -458,9 +511,7 @@ def completions(model_id, messages, tools = None, response: ChatResponse = None,
|
|
|
458
511
|
response.finish()
|
|
459
512
|
else:
|
|
460
513
|
response.stream(json.loads(event.data))
|
|
461
|
-
|
|
462
|
-
else:
|
|
463
|
-
return request.json()
|
|
514
|
+
return
|
|
464
515
|
except requests.exceptions.ConnectionError:
|
|
465
516
|
raise Exception("Connection error")
|
|
466
517
|
except Exception as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notebook-intelligence/notebook-intelligence",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "AI coding assistant for JupyterLab",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"AI",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
"_build": {
|
|
133
|
-
"load": "static/remoteEntry.
|
|
133
|
+
"load": "static/remoteEntry.83c8fe1714ab92a47234.js",
|
|
134
134
|
"extension": "./extension",
|
|
135
135
|
"style": "./style"
|
|
136
136
|
}
|
notebook_intelligence-2.2.0/notebook_intelligence/labextension/static/144.ea73716e650ab32a5118.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_notebook_intelligence_notebook_intelligence=self.webpackChunk_notebook_intelligence_notebook_intelligence||[]).push([[144],{85947:(e,t,n)=>{n.r(t),n.d(t,{BackendMessageType:()=>I,BuiltinToolsetType:()=>w,ContextType:()=>x,GITHUB_COPILOT_PROVIDER_ID:()=>S,INotebookIntelligence:()=>T,RequestDataType:()=>N,ResponseStreamDataType:()=>A,TelemetryEventType:()=>j,default:()=>Le});var o=n(39983),i=n(45551),l=n(72226),a=n(18178),s=n(8914),c=n(2653),r=n(50273),d=n(35263),u=n(54461),m=n(50498),g=n(85713),p=n(42235),h=n(35256),C=n(46167),f=n(50409),v=n(93345),b=n.n(v),M=n(67262),y=n(37227),E=n(3266);async function k(e="",t={}){const n=g.ServerConnection.makeSettings(),o=E.URLExt.join(n.baseUrl,"notebook-intelligence",e);let i;try{i=await g.ServerConnection.makeRequest(o,t,n)}catch(e){throw new g.ServerConnection.NetworkError(e)}let l=await i.text();if(l.length>0)try{l=JSON.parse(l)}catch(e){console.log("Not a JSON response body.",i)}if(!i.ok)throw new g.ServerConnection.ResponseError(i,l.message||l.error||l);return l}var N,I,A,x,w,D=n(74602);!function(e){e.ChatRequest="chat-request",e.ChatUserInput="chat-user-input",e.ClearChatHistory="clear-chat-history",e.RunUICommandResponse="run-ui-command-response",e.GenerateCode="generate-code",e.CancelChatRequest="cancel-chat-request",e.InlineCompletionRequest="inline-completion-request",e.CancelInlineCompletionRequest="cancel-inline-completion-request"}(N||(N={})),function(e){e.StreamMessage="stream-message",e.StreamEnd="stream-end",e.RunUICommand="run-ui-command"}(I||(I={})),function(e){e.LLMRaw="llm-raw",e.Markdown="markdown",e.MarkdownPart="markdown-part",e.Image="image",e.HTMLFrame="html-frame",e.Button="button",e.Anchor="anchor",e.Progress="progress",e.Confirmation="confirmation"}(A||(A={})),function(e){e.Custom="custom",e.CurrentFile="current-file"}(x||(x={})),function(e){e.NotebookEdit="nbi-notebook-edit",e.NotebookExecute="nbi-notebook-execute"}(w||(w={}));const S="github-copilot";var j;!function(e){e.InlineCompletionRequest="inline-completion-request",e.ExplainThisRequest="explain-this-request",e.FixThisCodeRequest="fix-this-code-request",e.ExplainThisOutputRequest="explain-this-output-request",e.TroubleshootThisOutputRequest="troubleshoot-this-output-request",e.GenerateCodeRequest="generate-code-request",e.ChatRequest="chat-request",e.InlineChatRequest="inline-chat-request",e.ChatResponse="chat-response",e.InlineChatResponse="inline-chat-response",e.InlineCompletionResponse="inline-completion-response"}(j||(j={}));const T=new M.Token("@notebook-intelligence/notebook-intelligence:INotebookIntelligence","AI coding assistant for JupyterLab.");var L,_;!function(e){e.NotLoggedIn="NOT_LOGGED_IN",e.ActivatingDevice="ACTIVATING_DEVICE",e.LoggingIn="LOGGING_IN",e.LoggedIn="LOGGED_IN"}(_||(_={}));class O{static async initialize(){await this.fetchCapabilities(),this.updateGitHubLoginStatus(),setInterval((()=>{this.updateGitHubLoginStatus()}),2e3),O.initializeWebsocket()}static async initializeWebsocket(){const e=g.ServerConnection.makeSettings(),t=E.URLExt.join(e.wsUrl,"notebook-intelligence","copilot");this._webSocket=new e.WebSocket(t),this._webSocket.onmessage=e=>{this._messageReceived.emit(e.data)},this._webSocket.onerror=e=>{console.error(`Websocket error: ${e}. Closing...`),this._webSocket.close()},this._webSocket.onclose=e=>{console.log(`Websocket is closed: ${e.reason}. Reconnecting...`),setTimeout((()=>{O.initializeWebsocket()}),1e3)}}static getLoginStatus(){return this._loginStatus}static getDeviceVerificationInfo(){return this._deviceVerificationInfo}static async loginToGitHub(){return this._loginStatus=_.ActivatingDevice,new Promise(((e,t)=>{k("gh-login",{method:"POST"}).then((t=>{e({verificationURI:t.verification_uri,userCode:t.user_code}),this.updateGitHubLoginStatus()})).catch((e=>{console.error(`Failed to login to GitHub Copilot.\n${e}`),t(e)}))}))}static async logoutFromGitHub(){return this._loginStatus=_.ActivatingDevice,new Promise(((e,t)=>{k("gh-logout",{method:"GET"}).then((t=>{this.updateGitHubLoginStatus().then((()=>{e(t)}))})).catch((e=>{console.error(`Failed to logout from GitHub Copilot.\n${e}`),t(e)}))}))}static async updateGitHubLoginStatus(){return new Promise(((e,t)=>{k("gh-login-status").then((t=>{this._loginStatus=t.status,this._deviceVerificationInfo.verificationURI=t.verification_uri||"",this._deviceVerificationInfo.userCode=t.user_code||"",e()})).catch((e=>{console.error(`Failed to fetch GitHub Copilot login status.\n${e}`),t(e)}))}))}static async fetchCapabilities(){return new Promise(((e,t)=>{k("capabilities",{method:"GET"}).then((t=>{this.config.capabilities=structuredClone(t),this.config.chatParticipants=structuredClone(t.chat_participants),this.configChanged.emit(),e()})).catch((e=>{console.error(`Failed to get extension capabilities.\n${e}`),t(e)}))}))}static async setConfig(e){k("config",{method:"POST",body:JSON.stringify(e)}).then((e=>{O.fetchCapabilities()})).catch((e=>{console.error(`Failed to set NBI config.\n${e}`)}))}static async updateOllamaModelList(){return new Promise(((e,t)=>{k("update-provider-models",{method:"POST",body:JSON.stringify({provider:"ollama"})}).then((async t=>{await O.fetchCapabilities(),e()})).catch((e=>{console.error(`Failed to update ollama model list.\n${e}`),t(e)}))}))}static async chatRequest(e,t,n,o,i,l,a,s,c){this._messageReceived.connect(((t,n)=>{(n=JSON.parse(n)).id===e&&c.emit(n)})),this._webSocket.send(JSON.stringify({id:e,type:N.ChatRequest,data:{chatId:t,prompt:n,language:o,filename:i,additionalContext:l,chatMode:a,toolSelections:s}}))}static async generateCode(e,t,n,o,i,l,a,s){const c=M.UUID.uuid4();this._messageReceived.connect(((e,t)=>{(t=JSON.parse(t)).id===c&&s.emit(t)})),this._webSocket.send(JSON.stringify({id:c,type:N.GenerateCode,data:{chatId:e,prompt:t,prefix:n,suffix:o,existingCode:i,language:l,filename:a}}))}static async sendChatUserInput(e,t){this._webSocket.send(JSON.stringify({id:e,type:N.ChatUserInput,data:t}))}static async sendWebSocketMessage(e,t,n){this._webSocket.send(JSON.stringify({id:e,type:t,data:n}))}static async inlineCompletionsRequest(e,t,n,o,i,l,a){this._messageReceived.connect(((e,n)=>{(n=JSON.parse(n)).id===t&&a.emit(n)})),this._webSocket.send(JSON.stringify({id:t,type:N.InlineCompletionRequest,data:{chatId:e,prefix:n,suffix:o,language:i,filename:l}}))}static async emitTelemetryEvent(e){return new Promise(((t,n)=>{k("emit-telemetry-event",{method:"POST",body:JSON.stringify(e)}).then((async e=>{t()})).catch((e=>{console.error(`Failed to emit telemetry event.\n${e}`),n(e)}))}))}}L=O,O._loginStatus=_.NotLoggedIn,O._deviceVerificationInfo={verificationURI:"",userCode:""},O._messageReceived=new D.Signal(L),O.config=new class{constructor(){this.capabilities={},this.chatParticipants=[],this.changed=new D.Signal(this)}get llmProviders(){return this.capabilities.llm_providers}get chatModels(){return this.capabilities.chat_models}get inlineCompletionModels(){return this.capabilities.inline_completion_models}get chatModel(){return this.capabilities.chat_model}get inlineCompletionModel(){return this.capabilities.inline_completion_model}get usingGitHubCopilotModel(){return this.chatModel.provider===S||this.inlineCompletionModel.provider===S}get storeGitHubAccessToken(){return!0===this.capabilities.store_github_access_token}get toolConfig(){return this.capabilities.tool_config}},O.configChanged=L.config.changed;var R=n(14067),W=n.n(R),z=n(93798),P=n.n(z),G=n(50238),U=n(50695),F=n(13151);const q=(0,n(96559).encoding_for_model)("gpt-4o");function Q(e){e.endsWith("```")&&(e=e.slice(0,-3));const t=e.split("\n");if(t.length<2)return e;const n=t.length;let o=-1,i=n;for(let e=0;e<n;e++)if(-1===o){if(t[e].trimStart().startsWith("```")){o=e;continue}}else if(t[e].trimStart().startsWith("```")){i=e;break}return-1!==o?t.slice(o+1,i).join("\n"):e}function Z(){return"false"===document.body.getAttribute("data-jp-theme-light")}function V(e){return e.split("\n").map((e=>`# ${e}`)).join("\n")}function Y(e){let t="";const n=e.outputArea.model.toJSON();for(const e of n)"execute_result"===e.output_type?t+="object"==typeof e.data&&null!==e.data?e.data["text/plain"]:"\n":"stream"===e.output_type?t+=e.text+"\n":"error"===e.output_type&&Array.isArray(e.traceback)&&(t+=e.ename+": "+e.evalue+"\n",t+=e.traceback.map((e=>e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""))).join("\n")+"\n");return t}function $(e,t){return e.line===t.line&&e.column===t.column}function J(e){return e.start.line===e.end.line&&e.start.column===e.end.column}function H(e){const t=e.getSelection(),n=e.getOffsetAt(t.start),o=e.getOffsetAt(t.end);return e.model.sharedModel.getSource().substring(n,o)}function B(e,t){var n;const o=e.getSelection(),i=e.getOffsetAt(o.start),l=e.getOffsetAt(o.end);e.model.sharedModel.updateSource(i,l,t);const a=t.split("\n").length,s=Math.min(o.start.line+a-1,e.lineCount-1),c=(null===(n=e.getLine(s))||void 0===n?void 0:n.length)||0;e.setCursorPosition({line:s,column:c})}function K({children:e,getApp:t,getActiveDocumentInfo:n}){const o=t(),i=n().filename.endsWith(".ipynb");return b().createElement(W(),{remarkPlugins:[P()],components:{code({node:e,inline:t,className:n,children:l,getApp:a,...s}){const c=/language-(\w+)/.exec(n||""),r=String(l).replace(/\n$/,""),d=c?c[1]:"text";return!t&&c?b().createElement("div",null,b().createElement("div",{className:"code-block-header"},b().createElement("div",{className:"code-block-header-language"},b().createElement("span",null,d)),b().createElement("div",{className:"code-block-header-button",onClick:()=>{navigator.clipboard.writeText(r)}},b().createElement(F.ASe,{size:16,title:"Copy to clipboard"}),b().createElement("span",null,"Copy")),b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:insert-at-cursor",{language:d,code:r})}},b().createElement(F.Mo,{size:16,title:"Insert at cursor"})),i&&b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:add-code-as-new-cell",{language:d,code:r})}},b().createElement(F.ivV,{size:16,title:"Add as new cell"})),b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:create-new-file",{language:d,code:r})}},b().createElement(F.NEl,{size:16,title:"New file"})),"python"===d&&b().createElement("div",{className:"code-block-header-button",onClick:()=>{o.commands.execute("notebook-intelligence:create-new-notebook-from-py",{language:d,code:r})}},b().createElement(F.YER,{size:16,title:"New notebook"}))),b().createElement(G.Prism,{style:Z()?U.bM:U.Je,PreTag:"div",language:d,...s},r)):b().createElement("code",{className:n,...s},l)}}},e)}const X='<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M6.25 9.016C6.66421 9.016 7 9.35089 7 9.76399V11.26C7 11.6731 6.66421 12.008 6.25 12.008C5.83579 12.008 5.5 11.6731 5.5 11.26V9.76399C5.5 9.35089 5.83579 9.016 6.25 9.016Z"/><path d="M10.5 9.76399C10.5 9.35089 10.1642 9.016 9.75 9.016C9.33579 9.016 9 9.35089 9 9.76399V11.26C9 11.6731 9.33579 12.008 9.75 12.008C10.1642 12.008 10.5 11.6731 10.5 11.26V9.76399Z"/><path d="M7.86079 1.80482C7.91028 1.8577 7.95663 1.91232 8 1.96856C8.04337 1.91232 8.08972 1.8577 8.13921 1.80482C8.82116 1.07611 9.87702 0.90832 11.0828 1.04194C12.3131 1.17827 13.2283 1.56829 13.8072 2.29916C14.3725 3.01276 14.5 3.90895 14.5 4.77735C14.5 5.34785 14.447 5.92141 14.2459 6.428L14.4135 7.26391L14.4798 7.29699C15.4115 7.76158 16 8.71126 16 9.7501V11.0107C16 11.2495 15.9143 11.4478 15.844 11.5763C15.7691 11.7131 15.6751 11.8368 15.5851 11.9416C15.4049 12.1512 15.181 12.3534 14.9801 12.5202C14.7751 12.6907 14.5728 12.8419 14.4235 12.9494C14.1842 13.1217 13.9389 13.2807 13.6826 13.4277C13.3756 13.6038 12.9344 13.8361 12.3867 14.0679C11.2956 14.5296 9.75604 15 8 15C6.24396 15 4.70442 14.5296 3.61334 14.0679C3.06559 13.8361 2.62435 13.6038 2.31739 13.4277C2.0611 13.2807 1.81581 13.1217 1.57651 12.9494C1.42716 12.8419 1.2249 12.6907 1.01986 12.5202C0.819 12.3534 0.595113 12.1512 0.414932 11.9416C0.3249 11.8368 0.230849 11.7131 0.156031 11.5763C0.0857453 11.4478 0 11.2495 1.90735e-06 11.0107L0 9.7501C0 8.71126 0.588507 7.76158 1.52017 7.29699L1.5865 7.26391L1.75413 6.42799C1.55295 5.9214 1.5 5.34785 1.5 4.77735C1.5 3.90895 1.62745 3.01276 2.19275 2.29916C2.77172 1.56829 3.68694 1.17827 4.91718 1.04194C6.12298 0.90832 7.17884 1.07611 7.86079 1.80482ZM3.0231 7.7282L3 7.8434V12.0931C3.02086 12.1053 3.04268 12.1179 3.06543 12.131C3.32878 12.2821 3.71567 12.4861 4.19916 12.6907C5.17058 13.1017 6.50604 13.504 8 13.504C9.49396 13.504 10.8294 13.1017 11.8008 12.6907C12.2843 12.4861 12.6712 12.2821 12.9346 12.131C12.9573 12.1179 12.9791 12.1053 13 12.0931V7.8434L12.9769 7.7282C12.4867 7.93728 11.9022 8.01867 11.25 8.01867C10.1037 8.01867 9.19051 7.69201 8.54033 7.03004C8.3213 6.80703 8.14352 6.55741 8 6.28924C7.85648 6.55741 7.6787 6.80703 7.45967 7.03004C6.80949 7.69201 5.89633 8.01867 4.75 8.01867C4.09776 8.01867 3.51325 7.93728 3.0231 7.7282ZM6.76421 2.82557C6.57116 2.61928 6.12702 2.41307 5.08282 2.52878C4.06306 2.64179 3.60328 2.93176 3.36975 3.22656C3.12255 3.53861 3 4.01374 3 4.77735C3 5.56754 3.12905 5.94499 3.3082 6.1441C3.47045 6.32443 3.82768 6.52267 4.75 6.52267C5.60367 6.52267 6.08903 6.28769 6.38811 5.98319C6.70349 5.66209 6.91507 5.1591 7.00579 4.43524C7.12274 3.50212 6.96805 3.04338 6.76421 2.82557ZM9.23579 2.82557C9.03195 3.04338 8.87726 3.50212 8.99421 4.43524C9.08493 5.1591 9.29651 5.66209 9.61189 5.98319C9.91097 6.28769 10.3963 6.52267 11.25 6.52267C12.1723 6.52267 12.5295 6.32443 12.6918 6.1441C12.871 5.94499 13 5.56754 13 4.77735C13 4.01374 12.8775 3.53861 12.6303 3.22656C12.3967 2.93176 11.9369 2.64179 10.9172 2.52878C9.87298 2.41307 9.42884 2.61928 9.23579 2.82557Z"/></svg>\n';var ee=n(87284);const te="openai-compatible-chat-model",ne="litellm-compatible-chat-model",oe="openai-compatible-inline-completion-model",ie="litellm-compatible-inline-completion-model";var le;!function(e){e[e.Chat=0]="Chat",e[e.ExplainThis=1]="ExplainThis",e[e.FixThis=2]="FixThis",e[e.GenerateCode=3]="GenerateCode",e[e.ExplainThisOutput=4]="ExplainThisOutput",e[e.TroubleshootThisOutput=5]="TroubleshootThisOutput"}(le||(le={}));class ae extends i.ReactWidget{constructor(e){super(),this._options=e,this.node.style.height="100%"}render(){return b().createElement(Ce,{getActiveDocumentInfo:this._options.getActiveDocumentInfo,getActiveSelectionContent:this._options.getActiveSelectionContent,getCurrentCellContents:this._options.getCurrentCellContents,openFile:this._options.openFile,getApp:this._options.getApp,getTelemetryEmitter:this._options.getTelemetryEmitter})}}class se extends i.ReactWidget{constructor(e,t){super(),this.node.classList.add("inline-prompt-widget"),this.node.style.top=`${e.top+32}px`,this.node.style.left=`${e.left}px`,this.node.style.width=e.width+"px",this.node.style.height="48px",this._options=t,this.node.addEventListener("focusout",(e=>{this.node.contains(e.relatedTarget)||this._options.onRequestCancelled()}))}updatePosition(e){this.node.style.top=`${e.top+32}px`,this.node.style.left=`${e.left}px`,this.node.style.width=e.width+"px"}_onResponse(e){var t,n,o,i,l;if(e.type===I.StreamMessage){if(!(null===(n=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===n?void 0:n.delta))return;const a=null===(l=null===(i=null===(o=e.data.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===l?void 0:l.content;if(!a)return;this._options.onContentStream(a)}else if(e.type===I.StreamEnd){this._options.onContentStreamEnd();const e=((new Date).getTime()-this._requestTime.getTime())/1e3;this._options.telemetryEmitter.emitTelemetryEvent({type:j.InlineChatResponse,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},timeElapsed:e}})}}_onRequestSubmitted(e){""!==this._options.existingCode&&(this.node.style.height="300px"),this._options.prompt=e,this._options.onRequestSubmitted(e),this._requestTime=new Date,this._options.telemetryEmitter.emitTelemetryEvent({type:j.InlineChatRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},prompt:e}})}render(){return b().createElement(fe,{prompt:this._options.prompt,existingCode:this._options.existingCode,onRequestSubmitted:this._onRequestSubmitted.bind(this),onRequestCancelled:this._options.onRequestCancelled,onResponseEmit:this._onResponse.bind(this),prefix:this._options.prefix,suffix:this._options.suffix,onUpdatedCodeChange:this._options.onUpdatedCodeChange,onUpdatedCodeAccepted:this._options.onUpdatedCodeAccepted})}}class ce extends i.ReactWidget{constructor(e){super(),this._getApp=e.getApp}render(){return b().createElement(Me,{getApp:this._getApp})}}class re extends i.ReactWidget{constructor(e){super(),this._onLoggedIn=e.onLoggedIn}render(){return b().createElement(ye,{onLoggedIn:()=>this._onLoggedIn()})}}class de extends i.ReactWidget{constructor(e){super(),this._onSave=e.onSave}render(){return b().createElement(Ee,{onSave:this._onSave})}}const ue=new Map;function me(e){const t=(0,v.useMemo)((()=>URL.createObjectURL(new Blob([e.source],{type:"text/html"}))),[]);return b().createElement("div",{className:"chat-response-html-frame",key:`key-${e.index}`},b().createElement("iframe",{className:"chat-response-html-frame-iframe",height:e.height,sandbox:"allow-scripts",src:t}))}function ge(e){var t,n,o;const[i,l]=(0,v.useState)(0),a=e.message,s=a.date.toLocaleTimeString("en-US",{hour12:!1}),c=(t,n)=>{e.getApp().commands.execute(t,n)},r=[];let d;const u=e=>{let t=e.content;if("string"!=typeof t)return!1;let n="",o=new Date;const i=new Date,l=t.indexOf("<think>"),a=l>=0;o=new Date(e.created),a&&(t=t.substring(l+7));const s=t.indexOf("</think>"),c=s>=0;return c?(n+=t.substring(0,s),t=t.substring(s+8)):a&&(n+=t,t=""),e.content=t,e.reasoningContent=n,e.reasoningFinished=c,e.reasoningTime=(i.getTime()-o.getTime())/1e3,a&&!c};for(let e=0;e<a.contents.length;e++){const t=a.contents[e];t.type===d&&d===A.MarkdownPart?r[r.length-1].content+=t.content:(r.push(structuredClone(t)),d=t.type)}const[m,g]=(0,v.useState)(!1);for(const e of r)u(e)&&!m&&g(!0);return(0,v.useEffect)((()=>{let e;return m&&(e=setInterval((()=>{l((e=>e+1)),g(!1)}),1e3)),()=>clearInterval(e)}),[m]),b().createElement("div",{className:`chat-message chat-message-${a.from}`,"data-render-count":i},b().createElement("div",{className:"chat-message-header"},b().createElement("div",{className:"chat-message-from"},(null===(t=a.participant)||void 0===t?void 0:t.iconPath)&&b().createElement("div",{className:`chat-message-from-icon ${"default"===(null===(n=a.participant)||void 0===n?void 0:n.id)?"chat-message-from-icon-default":""} ${Z()?"dark":""}`},b().createElement("img",{src:a.participant.iconPath})),b().createElement("div",{className:"chat-message-from-title"},"user"===a.from?"User":(null===(o=a.participant)||void 0===o?void 0:o.name)||"AI Assistant"),b().createElement("div",{className:"chat-message-from-progress",style:{display:e.showGenerating?"visible":"none"}},b().createElement("div",{className:"loading-ellipsis"},"Generating"))),b().createElement("div",{className:"chat-message-timestamp"},s)),b().createElement("div",{className:"chat-message-content"},r.map(((t,n)=>{switch(t.type){case A.Markdown:case A.MarkdownPart:return b().createElement(b().Fragment,null,t.reasoningContent&&b().createElement("div",{className:"chat-reasoning-content"},b().createElement("div",{className:"chat-reasoning-content-title",onClick:e=>(e=>{const t=e.currentTarget.parentElement;t.classList.contains("expanded")?t.classList.remove("expanded"):t.classList.add("expanded")})(e)},b().createElement(F.ny8,{className:"collapsed-icon"}),b().createElement(F.xDk,{className:"expanded-icon"})," ",t.reasoningFinished?"Thought":`Thinking (${Math.floor(t.reasoningTime)} s)`),b().createElement("div",{className:"chat-reasoning-content-text"},b().createElement(K,{key:`key-${n}`,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo},t.reasoningContent))),b().createElement(K,{key:`key-${n}`,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo},t.content));case A.Image:return b().createElement("div",{className:"chat-response-img",key:`key-${n}`},b().createElement("img",{src:t.content}));case A.HTMLFrame:return b().createElement(me,{index:n,source:t.content.source,height:t.content.height});case A.Button:return b().createElement("div",{className:"chat-response-button",key:`key-${n}`},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:()=>c(t.content.commandId,t.content.args)},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.title)));case A.Anchor:return b().createElement("div",{className:"chat-response-anchor",key:`key-${n}`},b().createElement("a",{href:t.content.uri,target:"_blank"},t.content.title));case A.Progress:return n===r.length-1?b().createElement("div",{className:"chat-response-progress",key:`key-${n}`},"✓ ",t.content):null;case A.Confirmation:return"confirmed"===ue.get(t.id)?null:"canceled"===ue.get(t.id)?b().createElement("div",null,"✖ Canceled"):b().createElement("div",{className:"chat-confirmation-form",key:`key-${n}`},t.content.title?b().createElement("div",null,b().createElement("b",null,t.content.title)):null,t.content.message?b().createElement("div",null,t.content.message):null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:()=>{var e;e=t.id,ue.set(e,"confirmed"),l((e=>e+1)),c("notebook-intelligence:chat-user-input",t.content.confirmArgs)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.confirmLabel)),b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:()=>{var e;e=t.id,ue.set(e,"canceled"),l((e=>e+1)),c("notebook-intelligence:chat-user-input",t.content.cancelArgs)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},t.content.cancelLabel)))}return null})),a.notebookLink&&b().createElement("a",{className:"copilot-generated-notebook-link","data-ref":a.notebookLink,onClick:t=>{const n=t.target.dataset.ref;e.openFile(n)}},"open notebook")))}async function pe(e,t){switch(e.type){case le.Chat:return O.chatRequest(e.messageId,e.chatId,e.content,e.language||"python",e.filename||"Untitled.ipynb",e.additionalContext||[],e.chatMode,e.toolSelections||{},t);case le.ExplainThis:case le.FixThis:case le.ExplainThisOutput:case le.TroubleshootThisOutput:return O.chatRequest(e.messageId,e.chatId,e.content,e.language||"python",e.filename||"Untitled.ipynb",[],"ask",{},t);case le.GenerateCode:return O.generateCode(e.chatId,e.content,e.prefix||"",e.suffix||"",e.existingCode||"",e.language||"python",e.filename||"Untitled.ipynb",t)}}function he(e){const t=e.indent||0;return b().createElement("div",{className:`checkbox-item checkbox-item-indent-${t} ${e.header?"checkbox-item-header":""}`,title:e.title,onClick:t=>e.onClick(t)},b().createElement("div",{className:"checkbox-item-toggle"},e.checked?b().createElement(ee.lEn,{className:"checkbox-icon"}):b().createElement(ee.ZRN,{className:"checkbox-icon"}),e.label),e.title&&b().createElement("div",{className:"checkbox-item-description"},e.title))}function Ce(e){const[t,n]=(0,v.useState)([]),[o,i]=(0,v.useState)(""),[l,a]=(0,v.useState)(""),s=(0,v.useRef)(null),[c,r]=(0,v.useState)(_.NotLoggedIn),[d,u]=(0,v.useState)(0),[m,g]=(0,v.useState)(!1),[p,h]=(0,v.useState)(!1),[C,f]=(0,v.useState)([]),[y,E]=(0,v.useState)([]),[k,D]=(0,v.useState)(0),T=(0,v.useRef)(null),[L,R]=(0,v.useState)([]),[W,z]=(0,v.useState)(0),[P,G]=(0,v.useState)(M.UUID.uuid4()),U=(0,v.useRef)(""),q=(0,v.useRef)(new Date),[Q,Z]=(0,v.useState)(!1),[V,Y]=(0,v.useState)(null),[$,J]=(0,v.useState)(""),H=e.getTelemetryEmitter(),[B,K]=(0,v.useState)("ask"),[X,ee]=(0,v.useState)("Tool selection"),[te,ne]=(0,v.useState)(0),[oe,ie]=(0,v.useState)(!1),[ae,se]=(0,v.useState)({builtinToolsets:[{id:w.NotebookEdit,name:"Notebook edit"},{id:w.NotebookExecute,name:"Notebook execute"}],mcpServers:[],extensions:[]}),[ce,re]=(0,v.useState)(!1),de={builtinToolsets:[w.NotebookEdit],mcpServers:{},extensions:{}},ue={builtinToolsets:[],mcpServers:{},extensions:{}},[me,Ce]=(0,v.useState)(de),[fe,ve]=(0,v.useState)(!1);O.configChanged.connect((()=>{se(O.config.toolConfig)})),(0,v.useEffect)((()=>{let e=!1;for(const t of ae.extensions)if(t.toolsets.length>0){e=!0;break}ve(e)}),[ae]),(0,v.useEffect)((()=>{const e=me.builtinToolsets.length;let t=0,n=0;for(const e in me.mcpServers)t+=me.mcpServers[e].length;for(const e in me.extensions){const t=me.extensions[e];for(const e in t)n+=t[e].length}const o=[];e>0&&o.push(`${e} built-in`),t>0&&o.push(`${t} mcp`),n>0&&o.push(`${n} ext`),ne(e+t+n),ie(me.builtinToolsets.includes(w.NotebookExecute)),ee(0===o.length?"Tool selection":`Tool selection (${o.join(", ")})`)}),[me]);const be=e=>me.builtinToolsets.includes(e),Me=e=>{if(!(e in me.mcpServers))return!1;const t=ae.mcpServers.find((t=>t.id===e)),n=me.mcpServers[e];for(const e of t.tools)if(!n.includes(e.name))return!1;return!0},ye=(e,t)=>e in me.mcpServers&&me.mcpServers[e].includes(t),Ee=e=>{if(!(e in me.extensions))return!1;const t=ae.extensions.find((t=>t.id===e));for(const n of t.toolsets)if(!ke(e,n.id))return!1;return!0},ke=(e,t)=>{if(!(e in me.extensions))return!1;if(!(t in me.extensions[e]))return!1;const n=ae.extensions.find((t=>t.id===e)).toolsets.find((e=>e.id===t)),o=me.extensions[e][t];for(const e of n.tools)if(!o.includes(e.name))return!1;return!0},Ne=(e,t,n)=>{if(!(e in me.extensions))return!1;const o=me.extensions[e];return t in o&&o[t].includes(n)};(0,v.useEffect)((()=>{const e=[];if("ask"!==B)return e.push("/clear"),f(e),void E(e);const t=O.config.chatParticipants;for(const n of t){const t=n.id,o=n.commands,i="default"===t?"":`@${t}`;""!==i&&e.push(i);const l=""===i?"":`${i} `;for(const t of o)e.push(`${l}/${t}`)}f(e),E(e)}),[B]),(0,v.useEffect)((()=>{const e=()=>{r(O.getLoginStatus())};e();const t=setInterval(e,1e3);return()=>clearInterval(t)}),[d]),(0,v.useEffect)((()=>{D(0)}),[y]);const Ie=e=>{var t;e.includes(o)?i(`${e} `):i(`${e} ${o} `),h(!1),null===(t=T.current)||void 0===t||t.focus(),D(0)},Ae=async()=>{re(!1),m?we():xe()},xe=async()=>{z(L.length+1),R([...L,o]),h(!1);const l=[],a=o.split(" ");if(a.length>1)for(let e=0;e<Math.min(a.length,2);e++){const t=a[e];(t.startsWith("@")||t.startsWith("/"))&&l.push(t)}const s=l.length>0?l.join(" ")+" ":"";U.current=M.UUID.uuid4(),q.current=new Date;const c=[...t,{id:U.current,date:new Date,from:"user",contents:[{id:M.UUID.uuid4(),type:A.Markdown,content:o,created:new Date}]}];if(n(c),o.startsWith("/clear"))return n([]),i(""),je(),Se(),R([]),z(0),void O.sendWebSocketMessage(M.UUID.uuid4(),N.ClearChatHistory,{chatId:P});g(!0);const r=e.getActiveDocumentInfo(),d=o,u=[],m=e.getApp(),p=[];if(Q&&(null==V?void 0:V.filename)){const t=V.selection,n=t&&!(t.start.line===t.end.line&&t.start.column===t.end.column);p.push({type:x.CurrentFile,content:e.getActiveSelectionContent(),currentCellContents:n?null:e.getCurrentCellContents(),filePath:V.filePath,cellIndex:V.activeCellIndex,startLine:t?t.start.line+1:1,endLine:t?t.end.line+1:1})}pe({messageId:U.current,chatId:P,type:le.Chat,content:d,language:r.language,filename:r.filename,additionalContext:p,chatMode:B,toolSelections:me},{emit:async e=>{var t,o,i,l,a;if(e.id!==U.current)return;let s="";if(e.type===I.StreamMessage){const n=null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta;if(!n)return;if(n.nbiContent){const t=n.nbiContent;u.push({id:M.UUID.uuid4(),type:t.type,content:t.content,created:new Date(e.created)})}else{if(s=null===(a=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===a?void 0:a.content,!s)return;u.push({id:M.UUID.uuid4(),type:A.MarkdownPart,content:s,created:new Date(e.created)})}}else if(e.type===I.StreamEnd){g(!1);const e=((new Date).getTime()-q.current.getTime())/1e3;H.emitTelemetryEvent({type:j.ChatResponse,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},timeElapsed:e}})}else if(e.type===I.RunUICommand){const t=e.id,n=await m.commands.execute(e.data.commandId,e.data.args),o={callback_id:e.data.callback_id,result:n||"void"};try{JSON.stringify(o)}catch(e){o.result="Could not serialize the result"}O.sendWebSocketMessage(t,N.RunUICommandResponse,o)}n([...c,{id:M.UUID.uuid4(),date:new Date,from:"copilot",contents:u,participant:O.config.chatParticipants.find((t=>t.id===e.participant))}])}});const C=o.startsWith("/settings")?"":s;i(C),De(C),H.emitTelemetryEvent({type:j.ChatRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},prompt:d}})},we=async()=>{O.sendWebSocketMessage(U.current,N.CancelChatRequest,{chatId:P}),U.current="",g(!1)},De=e=>{const t=e.trimStart();E(""===t?C:C.filter((e=>e.includes(t))))},Se=()=>{E(C),D(0)},je=()=>{G(M.UUID.uuid4())},Te=async()=>{e.getApp().commands.execute("notebook-intelligence:open-configuration-dialog")};(0,v.useEffect)((()=>{(()=>{var e;null===(e=s.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})()}),[t]);const Le=(0,v.useCallback)((e=>{const o=e.detail;o.chatId=P;let i="";switch(o.type){case le.ExplainThis:i=`Explain this code:\n\`\`\`\n${o.content}\n\`\`\`\n`;break;case le.FixThis:i=`Fix this code:\n\`\`\`\n${o.content}\n\`\`\`\n`;break;case le.ExplainThisOutput:i=`Explain this notebook cell output: \n\`\`\`\n${o.content}\n\`\`\`\n`;break;case le.TroubleshootThisOutput:i=`Troubleshoot errors reported in the notebook cell output: \n\`\`\`\n${o.content}\n\`\`\`\n`}const l=M.UUID.uuid4();o.messageId=l;const a=[...t,{id:l,date:new Date,from:"user",contents:[{id:l,type:A.Markdown,content:i,created:new Date}]}];n(a),g(!0);const s=[];pe(o,{emit:e=>{var t,o,i,l,c;if(e.type===I.StreamMessage){if(!(null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta))return;const n=null===(c=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===c?void 0:c.content;if(!n)return;s.push({id:e.id,type:A.MarkdownPart,content:n,created:new Date(e.created)})}else e.type===I.StreamEnd&&g(!1);const r=M.UUID.uuid4();n([...a,{id:r,date:new Date,from:"copilot",contents:s,participant:O.config.chatParticipants.find((t=>t.id===e.participant))}])}})}),[t]);(0,v.useEffect)((()=>(document.addEventListener("copilotSidebar:runPrompt",Le),()=>{document.removeEventListener("copilotSidebar:runPrompt",Le)})),[t]);const _e=e=>{var t;(null===(t=e.detail.activeDocumentInfo)||void 0===t?void 0:t.filePath)!==(null==V?void 0:V.filePath)&&Z(!1),Y({...e.detail.activeDocumentInfo,activeWidget:null}),J(Oe(e.detail.activeDocumentInfo))};(0,v.useEffect)((()=>(document.addEventListener("copilotSidebar:activeDocumentChanged",_e),()=>{document.removeEventListener("copilotSidebar:activeDocumentChanged",_e)})),[V]);const Oe=e=>{if(!(null==e?void 0:e.filename))return"";let t="";return!e.selection||e.selection.start.line===e.selection.end.line&&e.selection.start.column===e.selection.end.column||(e.filename.endsWith(".ipynb")&&(t=` · Cell ${e.activeCellIndex+1}`),e.selection.start.line===e.selection.end.line?t+=`:${e.selection.start.line+1}`:t+=`:${e.selection.start.line+1}-${e.selection.end.line+1}`),`${e.filename}${t}`},Re=O.config,We=()=>Re.usingGitHubCopilotModel&&O.getLoginStatus()===_.NotLoggedIn,ze=()=>Re.chatModel.provider===S?!We():Re.llmProviders.find((e=>e.id===Re.chatModel.provider)),[Pe,Ge]=(0,v.useState)(We()),[Ue,Fe]=(0,v.useState)(ze());return O.configChanged.connect((()=>{Ge(We()),Fe(ze())})),(0,v.useEffect)((()=>{Ge(We()),Fe(ze())}),[c]),b().createElement("div",{className:"sidebar"},b().createElement("div",{className:"sidebar-header"},b().createElement("div",{className:"sidebar-title"},"Notebook Intelligence"),b().createElement("div",{className:"user-input-footer-button",onClick:()=>(async()=>{re(!1),e.getApp().commands.execute("notebook-intelligence:open-configuration-dialog")})()},b().createElement(F.Fy3,null))),!Ue&&!Pe&&b().createElement("div",{className:"sidebar-login-info"},"Chat is disabled as you don't have a model configured.",b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:Te},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Configure models"))),Pe&&b().createElement("div",{className:"sidebar-login-info"},b().createElement("div",null,"You are not logged in to GitHub Copilot. Please login now to activate chat."),b().createElement("div",{className:"sidebar-login-buttons"},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:async()=>{e.getApp().commands.execute("notebook-intelligence:open-github-copilot-login-dialog")}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Login to GitHub Copilot")),b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:Te},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Change provider")))),Ue&&(0===t.length?b().createElement("div",{className:"sidebar-messages"},b().createElement("div",{className:"sidebar-greeting"},"Welcome! How can I assist you today?")):b().createElement("div",{className:"sidebar-messages"},t.map(((n,o)=>b().createElement(ge,{key:`key-${o}`,message:n,openFile:e.openFile,getApp:e.getApp,getActiveDocumentInfo:e.getActiveDocumentInfo,showGenerating:o===t.length-1&&"copilot"===n.from&&m}))),b().createElement("div",{ref:s}))),Ue&&b().createElement("div",{className:"sidebar-user-input "+(m?"generating":"")},b().createElement("textarea",{ref:T,rows:3,onChange:e=>{const t=e.target.value;i(t);const n=t.trimStart();"@"===n||"/"===n?(h(!0),De(n)):n.startsWith("@")||n.startsWith("/")||""===n?De(n):h(!1)},onKeyDown:async e=>{if("Enter"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void Ie(y[k]);D(0),Ae()}else if("Tab"===e.key){if(p)return e.stopPropagation(),e.preventDefault(),void Ie(y[k])}else if("Escape"===e.key)e.stopPropagation(),e.preventDefault(),h(!1),re(!1),D(0);else if("ArrowUp"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void D((k-1+y.length)%y.length);if(h(!1),L.length>0&&W===L.length&&a(o),L.length>0&&W>0&&W<=L.length){const e=L[W-1],t=W-1;i(e),z(t)}}else if("ArrowDown"===e.key){if(e.stopPropagation(),e.preventDefault(),p)return void D((k+1+y.length)%y.length);if(h(!1),L.length>0&&W>=0&&W<L.length){if(W===L.length-1)return i(l),void z(L.length);const e=L[W+1],t=W+1;i(e),z(t)}}},placeholder:"Ask Notebook Intelligence...",spellCheck:!1,value:o}),(null==V?void 0:V.filename)&&b().createElement("div",{className:"user-input-context-row"},b().createElement("div",{className:"user-input-context user-input-context-active-file "+(Q?"on":"off")},b().createElement("div",null,$),Q?b().createElement("div",{className:"user-input-context-toggle",onClick:()=>Z(!Q)},b().createElement(F.gZ8,{title:"Use as context"})):b().createElement("div",{className:"user-input-context-toggle",onClick:()=>Z(!Q)},b().createElement(F.iWd,{title:"Don't use as context"})))),b().createElement("div",{className:"user-input-footer"},"ask"===B&&b().createElement("div",null,b().createElement("a",{href:"javascript:void(0)",onClick:()=>{var e;h(!0),null===(e=T.current)||void 0===e||e.focus()},title:"Select chat participant"},"@")),b().createElement("div",{style:{flexGrow:1}}),b().createElement("div",{className:"chat-mode-widgets-container"},b().createElement("div",null,b().createElement("select",{className:"chat-mode-select",title:"Chat mode",value:B,onChange:e=>{"ask"===e.target.value?Ce(ue):"agent"===e.target.value&&Ce(de),re(!1),K(e.target.value)}},b().createElement("option",{value:"ask"},"Ask"),b().createElement("option",{value:"agent"},"Agent"))),"ask"!==B&&b().createElement("div",{className:"user-input-footer-button tools-button "+(oe?"tools-button-warning":te>0?"tools-button-active":""),onClick:()=>(async()=>{ce||O.fetchCapabilities(),re(!ce)})(),title:oe?`Notebook execute tool selected!\n${X}`:X},b().createElement(F.OVZ,null),te>0&&b().createElement(b().Fragment,null,te))),b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled send-button",onClick:()=>Ae(),disabled:0===o.length&&!m},m?b().createElement(F.nK7,null):b().createElement(F.tON,null)))),p&&y.length>0&&b().createElement("div",{className:"user-input-autocomplete"},y.map(((e,t)=>b().createElement("div",{key:`key-${t}`,className:"user-input-autocomplete-item "+(t===k?"selected":""),"data-value":e,onClick:e=>(e=>{const t=e.target.dataset.value;Ie(t)})(e)},e)))),ce&&b().createElement("div",{className:"mode-tools-popover",tabIndex:1,autoFocus:!0,onKeyDown:e=>{"Escape"!==e.key&&"Enter"!==e.key||(e.stopPropagation(),e.preventDefault(),re(!1))}},b().createElement("div",{className:"mode-tools-popover-header"},b().createElement("div",{className:"mode-tools-popover-header-icon"},b().createElement(F.OVZ,null)),b().createElement("div",{className:"mode-tools-popover-title"},X),b().createElement("div",{className:"mode-tools-popover-clear-tools-button",style:{visibility:te>0?"visible":"hidden"}},b().createElement("div",null,b().createElement(F.TQi,null)),b().createElement("div",null,b().createElement("a",{href:"javascript:void(0);",onClick:()=>{Ce(ue)}},"clear"))),b().createElement("div",{className:"mode-tools-popover-close-button",onClick:()=>re(!1)},b().createElement("div",null,b().createElement(F.Mk4,null)),b().createElement("div",null,"Done"))),b().createElement("div",{className:"mode-tools-popover-tool-list"},b().createElement("div",{className:"mode-tools-group-header"},"Built-in"),b().createElement("div",{className:"mode-tools-group mode-tools-group-built-in"},ae.builtinToolsets.map((e=>b().createElement(he,{key:e.id,label:e.name,checked:be(e.id),header:!0,onClick:()=>{((e,t)=>{const n={...me};if(t)me.builtinToolsets.includes(e)||n.builtinToolsets.push(e);else{const t=n.builtinToolsets.indexOf(e);-1!==t&&n.builtinToolsets.splice(t,1)}Ce(n)})(e.id,!be(e.id))}})))),ae.mcpServers.length>0&&b().createElement("div",{className:"mode-tools-group-header"},"MCP Servers"),ae.mcpServers.map(((e,t)=>b().createElement("div",{className:"mode-tools-group"},b().createElement(he,{label:e.id,header:!0,checked:Me(e.id),onClick:()=>(e=>{if((e=>e in me.mcpServers&&me.mcpServers[e].length>0)(e)){const t={...me};delete t.mcpServers[e],Ce(t)}else{const t=ae.mcpServers.find((t=>t.id===e)),n={...me};n.mcpServers[e]=structuredClone(t.tools.map((e=>e.name))),Ce(n)}})(e.id)}),e.tools.map(((t,n)=>b().createElement(he,{label:t.name,title:t.description,indent:1,checked:ye(e.id,t.name),onClick:()=>((e,t,n)=>{const o={...me};n&&!(e in o.mcpServers)&&(o.mcpServers[e]=[]);const i=o.mcpServers[e];if(n)i.push(t);else{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}Ce(o)})(e.id,t.name,!ye(e.id,t.name))})))))),fe&&b().createElement("div",{className:"mode-tools-group-header"},"Extension tools"),ae.extensions.map(((e,t)=>b().createElement("div",{className:"mode-tools-group"},b().createElement(he,{label:`${e.name} (${e.id})`,header:!0,checked:Ee(e.id),onClick:()=>(e=>{if((e=>e in me.extensions&&Object.keys(me.extensions[e]).length>0)(e)){const t={...me};delete t.extensions[e],Ce(t)}else{const t={...me},n=ae.extensions.find((t=>t.id===e));e in t.extensions&&delete t.extensions[e],t.extensions[e]={};for(const o of n.toolsets)t.extensions[e][o.id]=structuredClone(o.tools.map((e=>e.name)));Ce(t)}})(e.id)}),e.toolsets.map(((t,n)=>b().createElement(b().Fragment,null,b().createElement(he,{label:`${t.name} (${t.id})`,indent:1,checked:ke(e.id,t.id),onClick:()=>((e,t)=>{if(((e,t)=>e in me.extensions&&t in me.extensions[e]&&me.extensions[e][t].length>0)(e,t)){const n={...me};t in n.extensions[e]&&delete n.extensions[e][t],Ce(n)}else{const n=ae.extensions.find((t=>t.id===e)).toolsets.find((e=>e.id===t)),o={...me};e in o.extensions||(o.extensions[e]={}),o.extensions[e][t]=structuredClone(n.tools.map((e=>e.name))),Ce(o)}})(e.id,t.id)}),t.tools.map(((n,o)=>b().createElement(he,{label:n.name,title:n.description,indent:2,checked:Ne(e.id,t.id,n.name),onClick:()=>((e,t,n,o)=>{const i={...me};o&&!(e in i.extensions)&&(i.extensions[e]={}),o&&!(t in i.extensions[e])&&(i.extensions[e][t]=[]);const l=i.extensions[e][t];if(o)l.push(n);else{const e=l.indexOf(n);-1!==e&&l.splice(e,1)}Ce(i)})(e.id,t.id,n.name,!Ne(e.id,t.id,n.name))})))))))))))))}function fe(e){const[t,n]=(0,v.useState)(""),[o,i]=(0,v.useState)(!1),l=e.onRequestSubmitted,a=e.onResponseEmit;return b().createElement("div",{className:"inline-popover"},b().createElement(be,{...e,onRequestSubmitted:e=>{n(""),i(!0),l(e)},onResponseEmit:e=>{var t,o,i,l,s;if(e.type===I.StreamMessage){if(!(null===(o=null===(t=e.data.choices)||void 0===t?void 0:t[0])||void 0===o?void 0:o.delta))return;const a=null===(s=null===(l=null===(i=e.data.choices)||void 0===i?void 0:i[0])||void 0===l?void 0:l.delta)||void 0===s?void 0:s.content;if(!a)return;n((e=>e+a))}else e.type===I.StreamEnd&&n((e=>Q(e)));a(e)},onUpdatedCodeAccepted:e.onUpdatedCodeAccepted,limitHeight:""!==e.existingCode&&o}),""!==e.existingCode&&o&&b().createElement(b().Fragment,null,b().createElement(ve,{...e,modifiedCode:t}),b().createElement("div",{className:"inline-popover-footer"},b().createElement("div",null,b().createElement("button",{className:"jp-Button jp-mod-accept jp-mod-styled jp-mod-small",onClick:()=>e.onUpdatedCodeAccepted()},"Accept")),b().createElement("div",null,b().createElement("button",{className:"jp-Button jp-mod-reject jp-mod-styled jp-mod-small",onClick:()=>e.onRequestCancelled()},"Cancel")))))}function ve(e){const t=(0,v.useRef)(null),[n,o]=(0,v.useState)(null);return(0,v.useEffect)((()=>{const n=t.current;n.className="monaco-editor-container";const i=y.editor.createModel(e.existingCode,"text/plain"),l=y.editor.createModel(e.modifiedCode,"text/plain"),a=y.editor.createDiffEditor(n,{originalEditable:!1,automaticLayout:!0,theme:Z()?"vs-dark":"vs"});a.setModel({original:i,modified:l}),l.onDidChangeContent((()=>{e.onUpdatedCodeChange(l.getValue())})),o(a)}),[]),(0,v.useEffect)((()=>{var t;null===(t=null==n?void 0:n.getModifiedEditor().getModel())||void 0===t||t.setValue(e.modifiedCode)}),[e.modifiedCode]),b().createElement("div",{ref:t,className:"monaco-editor-container"})}function be(e){const[t,n]=(0,v.useState)(e.prompt),o=(0,v.useRef)(null),[i,l]=(0,v.useState)(!1);return(0,v.useEffect)((()=>{var e;const t=o.current;t&&(t.select(),null===(e=o.current)||void 0===e||e.focus())}),[]),b().createElement("div",{className:"inline-prompt-container",style:{height:e.limitHeight?"40px":"100%"}},b().createElement("textarea",{ref:o,rows:3,onChange:e=>{const t=e.target.value;n(t)},onKeyDown:async n=>{"Enter"===n.key?(n.stopPropagation(),n.preventDefault(),i&&(n.metaKey||n.ctrlKey)?e.onUpdatedCodeAccepted():(e.onRequestSubmitted(t),(async()=>{const n=[],o=t.split(" ");if(o.length>1)for(let e=0;e<Math.min(o.length,2);e++){const t=o[e];(t.startsWith("@")||t.startsWith("/"))&&n.push(t)}pe({messageId:M.UUID.uuid4(),chatId:M.UUID.uuid4(),type:le.GenerateCode,content:t,language:void 0,filename:void 0,prefix:e.prefix,suffix:e.suffix,existingCode:e.existingCode,chatMode:"ask"},{emit:async t=>{e.onResponseEmit(t)}}),l(!0)})())):"Escape"===n.key&&(n.stopPropagation(),n.preventDefault(),e.onRequestCancelled())},placeholder:"Ask Notebook Intelligence to generate Python code...",spellCheck:!1,value:t}))}function Me(e){const[t,n]=(0,v.useState)(_.NotLoggedIn),[o,i]=(0,v.useState)(0);return(0,v.useEffect)((()=>{const e=()=>{n(O.getLoginStatus())};e();const t=setInterval(e,1e3);return()=>clearInterval(t)}),[o]),b().createElement("div",{title:"GitHub Copilot: "+(t===_.LoggedIn?"Logged in":"Not logged in"),className:"github-copilot-status-bar",onClick:()=>{e.getApp().commands.execute("notebook-intelligence:open-github-copilot-login-dialog")},dangerouslySetInnerHTML:{__html:t===_.LoggedIn?X:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M7.86079 1.76938C7.91028 1.8224 7.95663 1.87717 8 1.93356C8.04336 1.87717 8.08972 1.8224 8.13921 1.76938C8.82116 1.03872 9.87702 0.870477 11.0828 1.00446C12.3131 1.14115 13.2283 1.53222 13.8072 2.26504C14.3725 2.98056 14.5 3.87915 14.5 4.74987C14.5 5.21326 14.4653 5.67866 14.3451 6.10875C13.9119 5.84737 13.4429 5.63921 12.9473 5.49331C12.9809 5.29773 13 5.05436 13 4.74987C13 3.98422 12.8774 3.50781 12.6303 3.19493C12.3967 2.89934 11.9369 2.60859 10.9172 2.49528C9.87298 2.37926 9.42884 2.58602 9.23579 2.79286C9.03195 3.01126 8.87725 3.47123 8.99421 4.40684C9.05402 4.88539 9.16638 5.26766 9.32639 5.56486C8.14474 5.96456 7.12813 6.72232 6.40569 7.70903C5.92566 7.90339 5.37217 7.99987 4.75 7.99987C4.09776 7.99987 3.51325 7.91826 3.0231 7.70862L3 7.82413V12.0852C3.02086 12.0974 3.04268 12.1101 3.06543 12.1232C3.32878 12.2747 3.71567 12.4793 4.19916 12.6844C4.59656 12.853 5.05487 13.0201 5.56004 13.1588C5.77061 13.7867 6.08221 14.3683 6.47552 14.8842C5.35549 14.7159 4.37511 14.3885 3.61334 14.0653C3.06559 13.8329 2.62435 13.6 2.31739 13.4234C2.16373 13.335 2.0432 13.2604 1.95925 13.2066C1.91725 13.1797 1.88437 13.158 1.86101 13.1423L1.83316 13.1235L1.82736 13.1195L1.81237 13.1094C1.79971 13.1008 1.7818 13.0886 1.75941 13.0731C1.71466 13.0422 1.65169 12.9981 1.57651 12.9438C1.42716 12.836 1.2249 12.6844 1.01986 12.5135C0.819 12.3461 0.595113 12.1435 0.414932 11.9333C0.3249 11.8282 0.230849 11.7042 0.156031 11.567C0.0857453 11.4382 0 11.2394 1.90735e-06 10.9999L0 9.73594C0 8.69432 0.588507 7.74209 1.52017 7.27626L1.5865 7.24309L1.75413 6.40494C1.55295 5.89699 1.5 5.3219 1.5 4.74987C1.5 3.87915 1.62745 2.98056 2.19275 2.26504C2.77172 1.53222 3.68694 1.14115 4.91717 1.00446C6.12298 0.870477 7.17884 1.03872 7.86079 1.76938ZM6.76421 2.79286C6.57116 2.58602 6.12702 2.37926 5.08282 2.49528C4.06305 2.60859 3.60327 2.89934 3.36974 3.19493C3.12255 3.50781 3 3.98422 3 4.74987C3 5.54218 3.12905 5.92064 3.3082 6.12028C3.47045 6.30109 3.82768 6.49987 4.75 6.49987C5.60367 6.49987 6.08903 6.26426 6.38811 5.95894C6.70349 5.63698 6.91507 5.13264 7.00579 4.40684C7.12274 3.47123 6.96805 3.01126 6.76421 2.79286Z"/><path d="M8.49808 14.8106C9.25887 15.3994 10.2135 15.7499 11.25 15.7499C13.7353 15.7499 15.75 13.7352 15.75 11.2499C15.75 9.60081 14.863 8.15893 13.54 7.37532C12.8692 6.97796 12.0862 6.74987 11.25 6.74987C10.417 6.74987 9.63686 6.97621 8.96772 7.37074C7.64049 8.1533 6.75 9.59759 6.75 11.2499C6.75 12.0588 6.96343 12.8178 7.33706 13.4738C7.63262 13.9927 8.02841 14.4471 8.49808 14.8106ZM10.5 8.74987C10.5 8.33566 10.8366 7.99987 11.2508 7.99987C11.6647 8.00031 12 8.33593 12 8.74987V10.9999C12 11.4141 11.6642 11.7499 11.25 11.7499C10.8358 11.7499 10.5 11.4141 10.5 10.9999V8.74987ZM11.25 14.4999C10.6977 14.4999 10.25 14.0522 10.25 13.4999C10.25 12.9476 10.6977 12.4999 11.25 12.4999C11.8023 12.4999 12.25 12.9476 12.25 13.4999C12.25 14.0522 11.8023 14.4999 11.25 14.4999Z"/></svg>\n'}})}function ye(e){const[t,n]=(0,v.useState)(_.NotLoggedIn),[o,i]=(0,v.useState)(0),[l,a]=(0,v.useState)(!1),[s,c]=(0,v.useState)(""),[r,d]=(0,v.useState)("");(0,v.useEffect)((()=>{const t=()=>{const t=O.getLoginStatus();n(t),t===_.LoggedIn&&l&&setTimeout((()=>{e.onLoggedIn()}),1e3)};t();const o=setInterval(t,1e3);return()=>clearInterval(o)}),[o]);const u=async()=>{await O.logoutFromGitHub(),i(o+1)},m=t===_.LoggedIn;return b().createElement("div",{className:"github-copilot-login-dialog"},b().createElement("div",{className:"github-copilot-login-status"},b().createElement("h4",null,"Login status:"," ",b().createElement("span",{className:"github-copilot-login-status-text "+(m?"logged-in":"")},m?"Logged in":t===_.LoggingIn?"Logging in...":t===_.ActivatingDevice?"Activating device...":t===_.NotLoggedIn?"Not logged in":"Unknown"))),t===_.NotLoggedIn&&b().createElement(b().Fragment,null,b().createElement("div",null,"Your code and data are directly transferred to GitHub Copilot as needed without storing any copies other than keeping in the process memory."),b().createElement("div",null,b().createElement("a",{href:"https://github.com/features/copilot",target:"_blank"},"GitHub Copilot")," ","requires a subscription and it has a free tier. GitHub Copilot is subject to the"," ",b().createElement("a",{href:"https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features",target:"_blank"},"GitHub Terms for Additional Products and Features"),"."),b().createElement("div",null,b().createElement("h4",null,"Privacy and terms"),"By using Notebook Intelligence with GitHub Copilot subscription you agree to"," ",b().createElement("a",{href:"https://docs.github.com/en/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-chat-in-your-ide",target:"_blank"},"GitHub Copilot chat terms"),". Review the terms to understand about usage, limitations and ways to improve GitHub Copilot. Please review"," ",b().createElement("a",{href:"https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement",target:"_blank"},"Privacy Statement"),"."),b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-reject jp-mod-styled",onClick:async()=>{const e=await O.loginToGitHub();c(e.verificationURI),d(e.userCode),i(o+1),a(!0)}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Login using your GitHub account")))),m&&b().createElement("div",null,b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:u},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Logout"))),t===_.ActivatingDevice&&s&&r&&b().createElement("div",null,b().createElement("div",{className:"copilot-activation-message"},"Copy code"," ",b().createElement("span",{className:"user-code-span",onClick:()=>(navigator.clipboard.writeText(r),!0)},b().createElement("b",null,r," ",b().createElement("span",{className:"copy-icon",dangerouslySetInnerHTML:{__html:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--\x3e<path fill="currentColor" d="M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z"/></svg>\n'}})))," ","and enter at"," ",b().createElement("a",{href:s,target:"_blank"},s)," ","to allow access to GitHub Copilot from this app. Activation could take up to a minute after you enter the code.")),t===_.ActivatingDevice&&b().createElement("div",{style:{marginTop:"10px"}},b().createElement("button",{className:"jp-Dialog-button jp-mod-reject jp-mod-styled",onClick:u},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Cancel activation"))))}function Ee(e){const t=O.config,n=t.llmProviders,[o,i]=(0,v.useState)([]),[l,a]=(0,v.useState)([]),[s,c]=(0,v.useState)(t.chatModel.provider||"none"),[r,d]=(0,v.useState)(t.inlineCompletionModel.provider||"none"),[u,m]=(0,v.useState)(t.chatModel.model),[g,p]=(0,v.useState)([]),[h,C]=(0,v.useState)([]),[f,M]=(0,v.useState)(t.inlineCompletionModel.model),[y,E]=(0,v.useState)(t.storeGitHubAccessToken),k=(e,n)=>{"chat"===n?c(e):d(e);const o="chat"===n?t.chatModels:t.inlineCompletionModels,l="chat"===n?t.chatModel.model:t.inlineCompletionModel.model,s=o.filter((t=>t.provider===e));"chat"===n?i(s):a(s);let r=s.find((e=>e.id===l));r||(r=null==s?void 0:s[0]),r?"chat"===n?(m(r.id),p(r.properties)):(M(r.id),C(r.properties)):"chat"===n?p([]):C([])},N=(e,t,n)=>{const o=("chat"===e?g:h).map((e=>e.id===t?{...e,value:n}:e));"chat"===e?p(o):C(o)};return(0,v.useEffect)((()=>{k(s,"chat"),k(r,"inline-completion")}),[]),b().createElement("div",{className:"config-dialog"},b().createElement("div",{className:"config-dialog-body"},b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"Chat model"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Provider"),b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>k(e.target.value,"chat")},n.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===s},e.name))),b().createElement("option",{key:-1,value:"none",selected:"none"===s||!n.find((e=>e.id===s))},"None")))),!["openai-compatible","litellm-compatible","none"].includes(s)&&o.length>0&&b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Model"),![te,ne].includes(u)&&o.length>0&&b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>m(e.target.value)},o.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===u},e.name))))))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},"ollama"===s&&0===o.length&&b().createElement("div",{className:"ollama-warning-message"},"No Ollama models found! Make sure"," ",b().createElement("a",{href:"https://ollama.com/",target:"_blank"},"Ollama")," ","is running and models are downloaded to your computer."," ",b().createElement("a",{href:"javascript:void(0)",onClick:async()=>{await O.updateOllamaModelList(),k(s,"chat")}},"Try again")," ","once ready."))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},g.map(((e,t)=>b().createElement("div",{className:"form-field-row",key:t},b().createElement("div",{className:"form-field-description"},e.name," ",e.optional?"(optional)":""),b().createElement("input",{name:"chat-model-id-input",placeholder:e.description,className:"jp-mod-styled",spellCheck:!1,value:e.value,onChange:t=>N("chat",e.id,t.target.value)})))))))),b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header"},"Auto-complete model"),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Provider"),b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>k(e.target.value,"inline-completion")},n.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===r},e.name))),b().createElement("option",{key:-1,value:"none",selected:"none"===r||!n.find((e=>e.id===r))},"None")))),!["openai-compatible","litellm-compatible","none"].includes(r)&&b().createElement("div",{className:"model-config-section-column"},b().createElement("div",null,"Model"),![oe,ie].includes(f)&&b().createElement("div",null,b().createElement("select",{className:"jp-mod-styled",onChange:e=>M(e.target.value)},l.map(((e,t)=>b().createElement("option",{key:t,value:e.id,selected:e.id===f},e.name))))))),b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},h.map(((e,t)=>b().createElement("div",{className:"form-field-row",key:t},b().createElement("div",{className:"form-field-description"},e.name," ",e.optional?"(optional)":""),b().createElement("input",{name:"inline-completion-model-id-input",placeholder:e.description,className:"jp-mod-styled",spellCheck:!1,value:e.value,onChange:t=>N("inline-completion",e.id,t.target.value)})))))))),("github-copilot"===s||"github-copilot"===r)&&b().createElement("div",{className:"model-config-section"},b().createElement("div",{className:"model-config-section-header access-token-config-header"},"GitHub Copilot login"," ",b().createElement("a",{href:"https://github.com/notebook-intelligence/notebook-intelligence/blob/main/README.md#remembering-github-copilot-login",target:"_blank"}," ",b().createElement(F.vDk,{className:"access-token-warning",title:"Click to learn more about security implications"}))),b().createElement("div",{className:"model-config-section-body"},b().createElement("div",{className:"model-config-section-row"},b().createElement("div",{className:"model-config-section-column"},b().createElement("label",null,b().createElement("input",{type:"checkbox",checked:y,onChange:e=>{E(e.target.checked)}}),"Remember my GitHub Copilot access token")))))),b().createElement("div",{className:"config-dialog-footer"},b().createElement("button",{className:"jp-Dialog-button jp-mod-accept jp-mod-styled",onClick:async()=>{const t={chat_model:{provider:s,model:u,properties:g},inline_completion_model:{provider:r,model:f,properties:h}};"github-copilot"!==s&&"github-copilot"!==r||(t.store_github_access_token=y),await O.setConfig(t),e.onSave()}},b().createElement("div",{className:"jp-Dialog-buttonLabel"},"Save"))))}const ke='<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="var(--jp-inverse-layout-color3)"><path d="M 5.398 10.807 C 5.574 10.931 5.785 10.998 6 10.997 C 6.216 10.998 6.427 10.93 6.602 10.804 C 6.78 10.674 6.915 10.494 6.989 10.286 L 7.436 8.913 C 7.551 8.569 7.744 8.256 8 7.999 C 8.257 7.743 8.569 7.549 8.913 7.434 L 10.304 6.983 C 10.456 6.929 10.594 6.84 10.706 6.724 C 10.817 6.608 10.901 6.467 10.949 6.313 C 10.998 6.159 11.01 5.996 10.985 5.837 C 10.96 5.677 10.898 5.526 10.804 5.394 C 10.67 5.208 10.479 5.071 10.26 5.003 L 8.885 4.556 C 8.541 4.442 8.228 4.249 7.971 3.993 C 7.714 3.736 7.52 3.424 7.405 3.079 L 6.953 1.691 C 6.881 1.489 6.748 1.314 6.571 1.191 C 6.439 1.098 6.286 1.036 6.125 1.012 C 5.965 0.987 5.801 1.001 5.646 1.051 C 5.492 1.101 5.351 1.187 5.236 1.301 C 5.12 1.415 5.033 1.555 4.98 1.708 L 4.523 3.108 C 4.409 3.443 4.22 3.748 3.97 3.999 C 3.721 4.25 3.418 4.441 3.083 4.557 L 1.692 5.005 C 1.541 5.06 1.404 5.149 1.292 5.265 C 1.18 5.381 1.097 5.521 1.048 5.675 C 1 5.829 0.988 5.992 1.013 6.151 C 1.038 6.31 1.099 6.462 1.192 6.593 C 1.32 6.773 1.501 6.908 1.709 6.979 L 3.083 7.424 C 3.524 7.571 3.91 7.845 4.193 8.212 C 4.356 8.423 4.481 8.66 4.564 8.912 L 5.016 10.303 C 5.088 10.507 5.222 10.683 5.398 10.807 Z M 11.535 14.849 C 11.671 14.946 11.834 14.997 12 14.997 C 12.165 14.997 12.326 14.946 12.461 14.851 C 12.601 14.753 12.706 14.613 12.761 14.451 L 13.009 13.689 C 13.063 13.531 13.152 13.387 13.269 13.268 C 13.387 13.15 13.531 13.061 13.689 13.009 L 14.461 12.757 C 14.619 12.703 14.756 12.6 14.852 12.464 C 14.926 12.361 14.974 12.242 14.992 12.117 C 15.011 11.992 14.999 11.865 14.959 11.745 C 14.918 11.625 14.85 11.516 14.76 11.428 C 14.669 11.34 14.559 11.274 14.438 11.236 L 13.674 10.987 C 13.516 10.935 13.372 10.846 13.254 10.729 C 13.136 10.611 13.047 10.467 12.994 10.309 L 12.742 9.536 C 12.689 9.379 12.586 9.242 12.449 9.146 C 12.347 9.073 12.23 9.025 12.106 9.006 C 11.982 8.987 11.855 8.998 11.736 9.037 C 11.616 9.076 11.508 9.142 11.419 9.231 C 11.33 9.319 11.264 9.427 11.224 9.546 L 10.977 10.308 C 10.925 10.466 10.838 10.61 10.721 10.728 C 10.607 10.845 10.467 10.934 10.312 10.987 L 9.539 11.239 C 9.38 11.293 9.242 11.396 9.145 11.533 C 9.047 11.669 8.995 11.833 8.996 12.001 C 8.997 12.169 9.051 12.333 9.15 12.468 C 9.249 12.604 9.388 12.705 9.547 12.757 L 10.31 13.004 C 10.469 13.058 10.614 13.147 10.732 13.265 C 10.851 13.384 10.939 13.528 10.99 13.687 L 11.243 14.461 C 11.298 14.618 11.4 14.753 11.535 14.849 Z"/></svg>\n';var Ne;!function(e){e.chatuserInput="notebook-intelligence:chat-user-input",e.insertAtCursor="notebook-intelligence:insert-at-cursor",e.addCodeAsNewCell="notebook-intelligence:add-code-as-new-cell",e.createNewFile="notebook-intelligence:create-new-file",e.createNewNotebookFromPython="notebook-intelligence:create-new-notebook-from-py",e.addCodeCellToNotebook="notebook-intelligence:add-code-cell-to-notebook",e.addMarkdownCellToNotebook="notebook-intelligence:add-markdown-cell-to-notebook",e.editorGenerateCode="notebook-intelligence:editor-generate-code",e.editorExplainThisCode="notebook-intelligence:editor-explain-this-code",e.editorFixThisCode="notebook-intelligence:editor-fix-this-code",e.editorExplainThisOutput="notebook-intelligence:editor-explain-this-output",e.editorTroubleshootThisOutput="notebook-intelligence:editor-troubleshoot-this-output",e.openGitHubCopilotLoginDialog="notebook-intelligence:open-github-copilot-login-dialog",e.openConfigurationDialog="notebook-intelligence:open-configuration-dialog",e.addMarkdownCellToActiveNotebook="notebook-intelligence:add-markdown-cell-to-active-notebook",e.addCodeCellToActiveNotebook="notebook-intelligence:add-code-cell-to-active-notebook",e.deleteCellAtIndex="notebook-intelligence:delete-cell-at-index",e.insertCellAtIndex="notebook-intelligence:insert-cell-at-index",e.setCellTypeAndSource="notebook-intelligence:set-cell-type-and-source",e.getNumberOfCells="notebook-intelligence:get-number-of-cells",e.getCellType="notebook-intelligence:get-cell-type",e.getCellSource="notebook-intelligence:get-cell-source",e.getCellOutput="notebook-intelligence:get-cell-output",e.runCellAtIndex="notebook-intelligence:run-cell-at-index",e.getCurrentFileContent="notebook-intelligence:get-current-file-content",e.setCurrentFileContent="notebook-intelligence:set-current-file-content"}(Ne||(Ne={}));const Ie=new p.LabIcon({name:"notebook-intelligence:github-copilot-icon",svgstr:X}),Ae=new p.LabIcon({name:"notebook-intelligence:sparkles-icon",svgstr:ke}),xe={cells:[],metadata:{},nbformat:4,nbformat_minor:5},we="backend-telemetry-listener";class De{static initialize(e,t){var n;De._languageRegistry=t,null===(n=e.shell.currentChanged)||void 0===n||n.connect(((e,t)=>{De.watchDocument(t.newValue)})),De.activeDocumentInfo.activeWidget=e.shell.currentWidget,De.handleWatchDocument()}static watchDocument(e){De.activeDocumentInfo.activeWidget!==e&&(clearInterval(De._watchTimer),De.activeDocumentInfo.activeWidget=e,De._watchTimer=setInterval((()=>{De.handleWatchDocument()}),1e3),De.handleWatchDocument())}static handleWatchDocument(){var e,t,n,o,i,l,a;const s=De.activeDocumentInfo,c={...s,activeWidget:null},r=s.activeWidget;if(r instanceof d.NotebookPanel){const l=r;s.filename=l.sessionContext.name,s.filePath=l.sessionContext.path,s.language=(null===(o=null===(n=null===(t=null===(e=l.model)||void 0===e?void 0:e.sharedModel)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.kernelspec)||void 0===o?void 0:o.language)||"python";const{activeCellIndex:a,activeCell:c}=l.content;s.activeCellIndex=a,s.selection=null===(i=null==c?void 0:c.editor)||void 0===i?void 0:i.getSelection()}else if(r){const e=null===(l=r.context)||void 0===l?void 0:l.contentsModel;if("text"===(null==e?void 0:e.format)){const t=e.name,n=e.path,o=De._languageRegistry.findByMIME(e.mimetype)||De._languageRegistry.findByFileName(t);if(s.language=(null==o?void 0:o.name)||"unknown",s.filename=t,s.filePath=n,r instanceof u.FileEditorWidget){const e=r;s.selection=null===(a=e.content.editor)||void 0===a?void 0:a.getSelection()}else s.selection=void 0}else s.filename="",s.filePath="",s.language=""}De.documentInfoChanged(c,s)&&De.fireActiveDocumentChangedEvent()}static documentInfoChanged(e,t){return!e||!t||e.filename!==t.filename||e.filePath!==t.filePath||e.language!==t.language||e.activeCellIndex!==t.activeCellIndex||!function(e,t){return!(e&&t||!e&&!t)||e===t||$(e.start,t.start)&&$(e.end,t.end)}(e.selection,t.selection)}static getActiveSelectionContent(){var e,t;const n=De.activeDocumentInfo.activeWidget;if(n instanceof d.NotebookPanel){const e=n,t=e.content.activeCell.editor;return J(t.getSelection())?function(e){let t="";for(const n of e.content.widgets){const e=n.model.sharedModel;"code"===e.cell_type?t+=e.source+"\n":"markdown"===e.cell_type&&(t+=V(e.source)+"\n")}return t}(e):H(t)}if(n instanceof u.FileEditorWidget){const e=n.content.editor;return J(e.getSelection())?e.model.sharedModel.getSource():H(e)}{const o=2048;return(null===(t=null===(e=null==n?void 0:n.context)||void 0===e?void 0:e.model)||void 0===t?void 0:t.toString()).substring(0,o)}}static getCurrentCellContents(){const e=De.activeDocumentInfo.activeWidget;if(e instanceof d.NotebookPanel){const t=e,n=t.content.activeCell,o=n.model.sharedModel.source.trim();let i="";return n instanceof s.CodeCell&&(i=Y(t.content.activeCell)),{input:o,output:i}}return null}static fireActiveDocumentChangedEvent(){document.dispatchEvent(new CustomEvent("copilotSidebar:activeDocumentChanged",{detail:{activeDocumentInfo:De.activeDocumentInfo}}))}}De.activeDocumentInfo={language:"python",filename:"nb-doesnt-exist.ipynb",filePath:"nb-doesnt-exist.ipynb",activeWidget:null,activeCellIndex:-1,selection:null};class Se{constructor(e){this._lastRequestInfo=null,this._telemetryEmitter=e}get schema(){return{default:{debouncerDelay:200,timeout:15e3}}}fetch(e,t){let n="",o="";const i=e.text.substring(0,e.offset),l=e.text.substring(e.offset);let a=De.activeDocumentInfo.language,s="file-editor";if(t.widget instanceof d.NotebookPanel){s="notebook";const e=t.widget.content.activeCell;"markdown"===e.model.sharedModel.cell_type&&(a="markdown");let i=!1;for(const l of t.widget.content.widgets){const t=l.model.sharedModel;l===e?i=!0:i?"code"===t.cell_type?o+=t.source+"\n":"markdown"===t.cell_type&&(o+=V(t.source)+"\n"):"code"===t.cell_type?n+=t.source+"\n":"markdown"===t.cell_type&&(n+=V(t.source)+"\n")}}const c=O.config,r=c.inlineCompletionModel.provider===S?O.getLoginStatus()===_.LoggedIn:"none"!==c.inlineCompletionModel.provider;return this._telemetryEmitter.emitTelemetryEvent({type:j.InlineCompletionRequest,data:{inlineCompletionModel:{provider:O.config.inlineCompletionModel.provider,model:O.config.inlineCompletionModel.model},editorType:s}}),new Promise(((e,t)=>{const s=[];if(!r)return void e({items:s});this._lastRequestInfo&&O.sendWebSocketMessage(this._lastRequestInfo.messageId,N.CancelInlineCompletionRequest,{chatId:this._lastRequestInfo.chatId});const c=M.UUID.uuid4(),d=M.UUID.uuid4();this._lastRequestInfo={chatId:d,messageId:c,requestTime:new Date},O.inlineCompletionsRequest(d,c,n+i,l+o,a,De.activeDocumentInfo.filename,{emit:n=>{if(n.type===I.StreamMessage&&n.id===this._lastRequestInfo.messageId){s.push({insertText:n.data.completions});const t=((new Date).getTime()-this._lastRequestInfo.requestTime.getTime())/1e3;this._telemetryEmitter.emitTelemetryEvent({type:j.InlineCompletionResponse,data:{inlineCompletionModel:{provider:O.config.inlineCompletionModel.provider,model:O.config.inlineCompletionModel.model},timeElapsed:t}}),e({items:s})}else t()}})}))}get name(){return"Notebook Intelligence"}get identifier(){return"@notebook-intelligence/notebook-intelligence"}get icon(){return O.config.usingGitHubCopilotModel?Ie:Ae}}class je{constructor(){this._listeners=new Set}registerTelemetryListener(e){const t=e.name;t!==we&&console.warn(`Notebook Intelligence telemetry listener '${t}' registered. Make sure it is from a trusted source.`);let n=!1;this._listeners.forEach((e=>{e.name===t&&(n=!0)})),n?console.error(`Notebook Intelligence telemetry listener '${t}' already exists!`):this._listeners.add(e)}unregisterTelemetryListener(e){this._listeners.delete(e)}emitTelemetryEvent(e){this._listeners.forEach((t=>{t.onTelemetryEvent(e)}))}}const Te={id:"@notebook-intelligence/notebook-intelligence:plugin",description:"Notebook Intelligence",autoStart:!0,requires:[r.ICompletionProviderManager,o.IDocumentManager,m.IDefaultFileBrowser,a.IEditorLanguageRegistry,i.ICommandPalette,l.IMainMenu],optional:[c.ISettingRegistry,f.IStatusBar],provides:T,activate:async(e,t,n,o,l,a,c,r,m)=>{console.log("JupyterLab extension @notebook-intelligence/notebook-intelligence is activated!");const f=new je;f.registerTelemetryListener({name:we,onTelemetryEvent:e=>{O.emitTelemetryEvent(e)}});const v={registerTelemetryListener:e=>{f.registerTelemetryListener(e)},unregisterTelemetryListener:e=>{f.unregisterTelemetryListener(e)}};await O.initialize();let b=null;t.registerInlineProvider(new Se(f)),r&&r.load(Te.id).then((e=>{})).catch((e=>{console.error("Failed to load settings for @notebook-intelligence/notebook-intelligence.",e)}));const M=async t=>{const n=t.endsWith(".ipynb");return new Promise(((o,i)=>{const l=()=>{const i=De.activeDocumentInfo.filePath,a=t,s=e.shell.currentWidget;i===a&&(n&&s instanceof d.NotebookPanel&&s.content.activeCell&&s.content.activeCell.node.contains(document.activeElement)||!n&&s instanceof u.FileEditorWidget&&s.content.editor.hasFocus())?o(!0):setTimeout(l,200)};l(),async function(){return new Promise((e=>{setTimeout((()=>{e()}),1e4)}))}().then((()=>{o(!1)}))}))},y=new h.Panel;y.id="notebook-intelligence-tab",y.title.caption="Notebook Intelligence";const E=new p.LabIcon({name:"ui-components:palette",svgstr:ke});y.title.icon=E;const k=new ae({getActiveDocumentInfo:()=>De.activeDocumentInfo,getActiveSelectionContent:()=>De.getActiveSelectionContent(),getCurrentCellContents:()=>De.getCurrentCellContents(),openFile:e=>{n.openOrReveal(e)},getApp:()=>e,getTelemetryEmitter:()=>f});y.addWidget(k),e.shell.add(y,"left",{rank:1e3}),e.shell.activateById(y.id),e.commands.addCommand(Ne.chatuserInput,{execute:e=>{O.sendChatUserInput(e.id,e.data)}}),e.commands.addCommand(Ne.insertAtCursor,{execute:t=>{const n=e.shell.currentWidget;if(n instanceof d.NotebookPanel){const e=n.content.activeCell;if(e)return void B(e.editor,t.code)}else if(n instanceof u.FileEditorWidget)return void B(n.content.editor,t.code);e.commands.execute("apputils:notify",{message:"Failed to insert at cursor. Open a notebook or file to insert the code.",type:"error",options:{autoClose:!0}})}}),e.commands.addCommand(Ne.addCodeAsNewCell,{execute:t=>{var n;const o=e.shell.currentWidget;if(o instanceof d.NotebookPanel){let e=o.content.activeCellIndex;e=-1===e?o.content.widgets.length:e+1,null===(n=o.model)||void 0===n||n.sharedModel.insertCell(e,{cell_type:"code",metadata:{trusted:!0},source:t.code}),o.content.activeCellIndex=e}else e.commands.execute("apputils:notify",{message:"Open a notebook to insert the code as new cell",type:"error",options:{autoClose:!0}})}}),e.commands.addCommand(Ne.createNewFile,{execute:async e=>{const t=new g.ContentsManager,i=await t.newUntitled({ext:".py",path:null==o?void 0:o.model.path});return t.save(i.path,{content:Q(e.code),format:"text",type:"file"}),n.openOrReveal(i.path),await M(i.path),i}}),e.commands.addCommand(Ne.createNewNotebookFromPython,{execute:async e=>{var t;let i=null;const l=new g.ContentsManager,a=new g.KernelSpecManager;await a.ready;const s=null===(t=a.specs)||void 0===t?void 0:t.kernelspecs;if(s)for(const e in s){const t=s[e];if("python"===(null==t?void 0:t.language)){i=t;break}}const c=await l.newUntitled({ext:".ipynb",path:null==o?void 0:o.model.path}),r=structuredClone(xe);return i&&(r.metadata={kernelspec:{language:"python",name:i.name,display_name:i.display_name}}),e.code&&r.cells.push({cell_type:"code",metadata:{trusted:!0},source:[e.code],outputs:[]}),l.save(c.path,{content:r,format:"json",type:"notebook"}),n.openOrReveal(c.path),await M(c.path),c}});const N=e=>1===e.cells.length&&"code"===e.cells[0].cell_type&&""===e.cells[0].source,I=()=>O.config.chatModel.provider===S?!(O.config.usingGitHubCopilotModel&&O.getLoginStatus()===_.NotLoggedIn):"none"!==O.config.chatModel.provider,A=()=>e.shell.currentWidget instanceof d.NotebookPanel&&e.shell.currentWidget.content.activeCell instanceof s.CodeCell,x=(t,n,o)=>{const i=e.shell.currentWidget;if(!(i instanceof d.NotebookPanel&&i.sessionContext.path===t&&i.model))return e.commands.execute("apputils:notify",{message:`Failed to access the notebook: ${t}`,type:"error",options:{autoClose:!0}}),!1;const l=i.model.sharedModel,a=N(l)?0:l.cells.length-1;return l.insertCell(a,{cell_type:n,metadata:{trusted:!0},source:o}),!0};e.commands.addCommand(Ne.addCodeCellToNotebook,{execute:e=>x(e.path,"code",e.code)}),e.commands.addCommand(Ne.addMarkdownCellToNotebook,{execute:e=>x(e.path,"markdown",e.markdown)});const w=()=>{const t=e.shell.currentWidget;return!!(t instanceof d.NotebookPanel&&t.model)||(e.commands.execute("apputils:notify",{message:"Failed to find active notebook",type:"error",options:{autoClose:!0}}),!1)},D=()=>!!(e.shell.currentWidget instanceof u.FileEditorWidget)||(e.commands.execute("apputils:notify",{message:"Failed to find active file",type:"error",options:{autoClose:!0}}),!1);e.commands.addCommand(Ne.addMarkdownCellToActiveNotebook,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=N(n)?0:n.cells.length-1;return n.insertCell(o,{cell_type:"markdown",metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(Ne.addCodeCellToActiveNotebook,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=N(n)?0:n.cells.length-1;return n.insertCell(o,{cell_type:"code",metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(Ne.setCellTypeAndSource,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex,i=t.cellType,l=n.getCell(o);return n.deleteCell(o),n.insertCell(o,{cell_type:i,metadata:l.metadata,source:t.source}),!0}}),e.commands.addCommand(Ne.getNumberOfCells,{execute:t=>!!w()&&e.shell.currentWidget.model.sharedModel.cells.length}),e.commands.addCommand(Ne.getCellType,{execute:t=>!!w()&&e.shell.currentWidget.model.sharedModel.cells[t.cellIndex].cell_type}),e.commands.addCommand(Ne.getCellSource,{execute:t=>!!w()&&e.shell.currentWidget.model.sharedModel.cells[t.cellIndex].source}),e.commands.addCommand(Ne.getCellOutput,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget,o=t.cellIndex,i=n.content.widgets[o];return i instanceof s.CodeCell?Y(i):""}}),e.commands.addCommand(Ne.insertCellAtIndex,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex,i=t.cellType;return n.insertCell(o,{cell_type:i,metadata:{trusted:!0},source:t.source}),!0}}),e.commands.addCommand(Ne.deleteCellAtIndex,{execute:t=>{if(!w())return!1;const n=e.shell.currentWidget.model.sharedModel,o=t.cellIndex;return n.deleteCell(o),!0}}),e.commands.addCommand(Ne.runCellAtIndex,{execute:async t=>{if(!w())return!1;e.shell.currentWidget.content.activeCellIndex=t.cellIndex,await e.commands.execute("notebook:run-cell")}}),e.commands.addCommand(Ne.getCurrentFileContent,{execute:async t=>!!D()&&e.shell.currentWidget.content.editor.model.sharedModel.getSource()}),e.commands.addCommand(Ne.setCurrentFileContent,{execute:async t=>{if(!D())return!1;const n=e.shell.currentWidget.content.editor;return n.model.sharedModel.setSource(t.content),n.model.sharedModel.getSource()}}),e.commands.addCommand(Ne.openGitHubCopilotLoginDialog,{execute:e=>{let t=null;const n=new re({onLoggedIn:()=>null==t?void 0:t.dispose()});t=new i.Dialog({title:"GitHub Copilot Status",hasClose:!0,body:n,buttons:[]}),t.launch()}}),e.commands.addCommand(Ne.openConfigurationDialog,{label:"Notebook Intelligence Settings",execute:e=>{let t=null;const n=new de({onSave:()=>{null==t||t.dispose(),O.fetchCapabilities()}});t=new i.Dialog({title:"Notebook Intelligence Settings",hasClose:!0,body:n,buttons:[]}),t.node.classList.add("config-dialog-container"),t.launch()}}),a.addItem({command:Ne.openConfigurationDialog,category:"Notebook Intelligence"}),c.settingsMenu.addGroup([{command:Ne.openConfigurationDialog}]);const T={execute:t=>{(()=>{const t=A(),n=e.shell.currentWidget;let o,i=null,l=null;if(t){const e=n,t=e.content.activeCell;if(i=t.node.querySelector(".jp-InputArea-editor"),!i)return;l=e.node.querySelector(".jp-WindowedPanel-outer"),o=t.editor}else{const e=n;i=e.node,l=e.node.querySelector(".cm-scroller"),o=e.content.editor}const a=()=>{const e=o.getSelection(),n=Math.min(e.end.line+1,o.lineCount-1),l=o.getCoordinateForPosition({line:n,column:e.end.column}),a=i.getBoundingClientRect();if(!l)return a;let s=l.top-30;const c=l.bottom-l.top;return t||s+c+300>a.bottom&&(s=a.bottom-c-300,s<a.top&&(s=a.top)),new DOMRect(a.left,s,a.right-a.left,c)},s=a(),c=()=>{if(null!==b){const e=a();b.updatePosition(e)}},r=new ResizeObserver(c),m=()=>{null!==b&&(r.unobserve(i),l&&l.removeEventListener("scroll",c),b=null,h.Widget.detach(x)),t&&(null==i||i.classList.remove("generating"))};let g="",p="",C="",v="",M="";if(t){const t=(()=>{let t="",n="";const o=e.shell.currentWidget;if(!(o instanceof d.NotebookPanel&&o.content.activeCell))return{prefix:t,suffix:n};const i=o.content.activeCellIndex,l=o.content.widgets.length;for(let e=1;e<l;++e){const s=i-e,c=i+e;if(s<0&&c>=l||(a=`${t} ${n}`,q.encode(a).length>=2867.2))break;if(s>=0){const e=o.content.widgets[s].model.sharedModel;"code"===e.cell_type?t=e.source+"\n"+t:"markdown"===e.cell_type&&(t=V(e.source)+"\n"+t)}if(c<l){const e=o.content.widgets[c].model.sharedModel;"code"===e.cell_type?n+=e.source+"\n":"markdown"===e.cell_type&&(n+=V(e.source)+"\n")}}var a;return{prefix:t,suffix:n}})();v=t.prefix,M=t.suffix}else{const t=(()=>{let t="",n="";const o=e.shell.currentWidget;if(!(o instanceof u.FileEditorWidget))return{prefix:t,suffix:n};const i=o,l=i.content.editor.getCursorPosition(),a=i.content.editor.getOffsetAt(l),s=i.content.editor.model.sharedModel.getSource();return t=s.substring(0,a),n=s.substring(a),{prefix:t,suffix:n}})();v=t.prefix,M=t.suffix}const y=o.getSelection(),E=o.getOffsetAt(y.start),k=o.getOffsetAt(y.end),N=o.model.sharedModel.getSource();t?(v+="\n"+N.substring(0,E),p=N.substring(E,k),M=N.substring(k)+"\n"+M):p=N.substring(E,k);const I=()=>{C=Q(C),B(o,C),C="",m()};m();const x=new se(s,{prompt:g,existingCode:p,prefix:v,suffix:M,onRequestSubmitted:e=>{g=e,C="",""===p&&(m(),t&&(null==i||i.classList.add("generating")))},onRequestCancelled:()=>{m(),o.focus()},onContentStream:e=>{""===p&&(C+=e)},onContentStreamEnd:()=>{""===p&&(I(),o.focus())},onUpdatedCodeChange:e=>{C=e},onUpdatedCodeAccepted:()=>{I(),o.focus()},telemetryEmitter:f});b=x,r.observe(i),l&&l.addEventListener("scroll",c),h.Widget.attach(x,document.body),f.emitTelemetryEvent({type:j.GenerateCodeRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model},editorType:t?"notebook":"file-editor"}})})()},label:"Generate code",isEnabled:()=>I()&&(A()||e.shell.currentWidget instanceof u.FileEditorWidget)};e.commands.addCommand(Ne.editorGenerateCode,T);const L=new C.CommandRegistry;L.addCommand(Ne.editorGenerateCode,T),L.addCommand(Ne.editorExplainThisCode,{execute:()=>{const t=e.shell.currentWidget.content.activeCell,n=(null==t?void 0:t.model.sharedModel.source)||"";document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:le.ExplainThis,content:n,language:De.activeDocumentInfo.language,filename:De.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:y.id}),f.emitTelemetryEvent({type:j.ExplainThisRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Explain code",isEnabled:()=>I()&&A()}),L.addCommand(Ne.editorFixThisCode,{execute:()=>{const t=e.shell.currentWidget.content.activeCell,n=(null==t?void 0:t.model.sharedModel.source)||"";document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:le.FixThis,content:n,language:De.activeDocumentInfo.language,filename:De.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:y.id}),f.emitTelemetryEvent({type:j.FixThisCodeRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Fix code",isEnabled:()=>I()&&A()}),L.addCommand(Ne.editorExplainThisOutput,{execute:()=>{const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof s.CodeCell))return;const n=Y(t);document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:le.ExplainThisOutput,content:n,language:De.activeDocumentInfo.language,filename:De.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:y.id}),f.emitTelemetryEvent({type:j.ExplainThisOutputRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Explain output",isEnabled:()=>{if(!(I()&&e.shell.currentWidget instanceof d.NotebookPanel))return!1;const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof s.CodeCell))return!1;const n=t.outputArea.model.toJSON();return Array.isArray(n)&&n.length>0}}),L.addCommand(Ne.editorTroubleshootThisOutput,{execute:()=>{const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof s.CodeCell))return;const n=Y(t);document.dispatchEvent(new CustomEvent("copilotSidebar:runPrompt",{detail:{type:le.TroubleshootThisOutput,content:n,language:De.activeDocumentInfo.language,filename:De.activeDocumentInfo.filename}})),e.commands.execute("tabsmenu:activate-by-id",{id:y.id}),f.emitTelemetryEvent({type:j.TroubleshootThisOutputRequest,data:{chatModel:{provider:O.config.chatModel.provider,model:O.config.chatModel.model}}})},label:"Troubleshoot errors in output",isEnabled:()=>{if(!(I()&&e.shell.currentWidget instanceof d.NotebookPanel))return!1;const t=e.shell.currentWidget.content.activeCell;if(!(t instanceof s.CodeCell))return!1;const n=t.outputArea.model.toJSON();return Array.isArray(n)&&n.length>0&&n.some((e=>"error"===e.output_type))}});const R=new h.Menu({commands:L});if(R.id="notebook-intelligence:editor-context-menu",R.title.label="Notebook Intelligence",R.title.icon=E,R.addItem({command:Ne.editorGenerateCode}),R.addItem({command:Ne.editorExplainThisCode}),R.addItem({command:Ne.editorFixThisCode}),R.addItem({command:Ne.editorExplainThisOutput}),R.addItem({command:Ne.editorTroubleshootThisOutput}),e.contextMenu.addItem({type:"submenu",submenu:R,selector:".jp-Editor",rank:1}),e.contextMenu.addItem({type:"submenu",submenu:R,selector:".jp-OutputArea-child",rank:1}),m){const t=new ce({getApp:()=>e});m.registerStatusItem("notebook-intelligence:github-copilot-status",{item:t,align:"right",rank:100,isActive:()=>O.config.usingGitHubCopilotModel}),O.configChanged.connect((()=>{O.config.usingGitHubCopilotModel?t.show():t.hide()}))}const W=e;return De.initialize(W,l),v}},Le=Te},68968:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAAHUlEQVQYV2PYvXu3JAi7uLiAMaYAjAGTQBPYLQkAa/0Zef3qRswAAAAASUVORK5CYII="},3552:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAL0lEQVQoz2NgCD3x//9/BhBYBWdhgFVAiVW4JBFKGIa4AqD0//9D3pt4I4tAdAMAHTQ/j5Zom30AAAAASUVORK5CYII="},62974:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVRIx2NgYGBY/R8I/vx5eelX3n82IJ9FxGf6tksvf/8FiTMQAcAGQMDvSwu09abffY8QYSAScNk45G198eX//yev73/4///701eh//kZSARckrNBRvz//+8+6ZohwCzjGNjdgQxkAg7B9WADeBjIBqtJCbhRA0YNoIkBSNmaPEMoNmA0FkYNoFKhapJ6FGyAH3nauaSmPfwI0v/3OukVi0CIZ+F25KrtYcx/CTIy0e+rC7R1Z4KMICVTQQ14feVXIbR695u14+Ir4gwAAD49E54wc1kWAAAAAElFTkSuQmCC"},54676:e=>{e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA1MyAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00OC4wMzY0IDQuMDEwNDJINC4wMDc3OUw0LjAwNzc5IDMyLjAyODZINDguMDM2NFY0LjAxMDQyWk00LjAwNzc5IDAuMDA3ODEyNUMxLjc5NzIxIDAuMDA3ODEyNSAwLjAwNTE4Nzk5IDEuNzk5ODQgMC4wMDUxODc5OSA0LjAxMDQyVjMyLjAyODZDMC4wMDUxODc5OSAzNC4yMzkyIDEuNzk3MjEgMzYuMDMxMiA0LjAwNzc5IDM2LjAzMTJINDguMDM2NEM1MC4yNDcgMzYuMDMxMiA1Mi4wMzkgMzQuMjM5MiA1Mi4wMzkgMzIuMDI4NlY0LjAxMDQyQzUyLjAzOSAxLjc5OTg0IDUwLjI0NyAwLjAwNzgxMjUgNDguMDM2NCAwLjAwNzgxMjVINC4wMDc3OVpNOC4wMTA0MiA4LjAxMzAySDEyLjAxM1YxMi4wMTU2SDguMDEwNDJWOC4wMTMwMlpNMjAuMDE4MiA4LjAxMzAySDE2LjAxNTZWMTIuMDE1NkgyMC4wMTgyVjguMDEzMDJaTTI0LjAyMDggOC4wMTMwMkgyOC4wMjM0VjEyLjAxNTZIMjQuMDIwOFY4LjAxMzAyWk0zNi4wMjg2IDguMDEzMDJIMzIuMDI2VjEyLjAxNTZIMzYuMDI4NlY4LjAxMzAyWk00MC4wMzEyIDguMDEzMDJINDQuMDMzOVYxMi4wMTU2SDQwLjAzMTJWOC4wMTMwMlpNMTYuMDE1NiAxNi4wMTgySDguMDEwNDJWMjAuMDIwOEgxNi4wMTU2VjE2LjAxODJaTTIwLjAxODIgMTYuMDE4MkgyNC4wMjA4VjIwLjAyMDhIMjAuMDE4MlYxNi4wMTgyWk0zMi4wMjYgMTYuMDE4MkgyOC4wMjM0VjIwLjAyMDhIMzIuMDI2VjE2LjAxODJaTTQ0LjAzMzkgMTYuMDE4MlYyMC4wMjA4SDM2LjAyODZWMTYuMDE4Mkg0NC4wMzM5Wk0xMi4wMTMgMjQuMDIzNEg4LjAxMDQyVjI4LjAyNkgxMi4wMTNWMjQuMDIzNFpNMTYuMDE1NiAyNC4wMjM0SDM2LjAyODZWMjguMDI2SDE2LjAxNTZWMjQuMDIzNFpNNDQuMDMzOSAyNC4wMjM0SDQwLjAzMTJWMjguMDI2SDQ0LjAzMzlWMjQuMDIzNFoiIGZpbGw9IiM0MjQyNDIiLz4NCjwvZz4NCjxkZWZzPg0KPGNsaXBQYXRoIGlkPSJjbGlwMCI+DQo8cmVjdCB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIGZpbGw9IndoaXRlIi8+DQo8L2NsaXBQYXRoPg0KPC9kZWZzPg0KPC9zdmc+DQo="},51240:e=>{e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA1MyAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00OC4wMzY0IDQuMDEwNDJINC4wMDc3OUw0LjAwNzc5IDMyLjAyODZINDguMDM2NFY0LjAxMDQyWk00LjAwNzc5IDAuMDA3ODEyNUMxLjc5NzIxIDAuMDA3ODEyNSAwLjAwNTE4Nzk5IDEuNzk5ODQgMC4wMDUxODc5OSA0LjAxMDQyVjMyLjAyODZDMC4wMDUxODc5OSAzNC4yMzkyIDEuNzk3MjEgMzYuMDMxMiA0LjAwNzc5IDM2LjAzMTJINDguMDM2NEM1MC4yNDcgMzYuMDMxMiA1Mi4wMzkgMzQuMjM5MiA1Mi4wMzkgMzIuMDI4NlY0LjAxMDQyQzUyLjAzOSAxLjc5OTg0IDUwLjI0NyAwLjAwNzgxMjUgNDguMDM2NCAwLjAwNzgxMjVINC4wMDc3OVpNOC4wMTA0MiA4LjAxMzAySDEyLjAxM1YxMi4wMTU2SDguMDEwNDJWOC4wMTMwMlpNMjAuMDE4MiA4LjAxMzAySDE2LjAxNTZWMTIuMDE1NkgyMC4wMTgyVjguMDEzMDJaTTI0LjAyMDggOC4wMTMwMkgyOC4wMjM0VjEyLjAxNTZIMjQuMDIwOFY4LjAxMzAyWk0zNi4wMjg2IDguMDEzMDJIMzIuMDI2VjEyLjAxNTZIMzYuMDI4NlY4LjAxMzAyWk00MC4wMzEyIDguMDEzMDJINDQuMDMzOVYxMi4wMTU2SDQwLjAzMTJWOC4wMTMwMlpNMTYuMDE1NiAxNi4wMTgySDguMDEwNDJWMjAuMDIwOEgxNi4wMTU2VjE2LjAxODJaTTIwLjAxODIgMTYuMDE4MkgyNC4wMjA4VjIwLjAyMDhIMjAuMDE4MlYxNi4wMTgyWk0zMi4wMjYgMTYuMDE4MkgyOC4wMjM0VjIwLjAyMDhIMzIuMDI2VjE2LjAxODJaTTQ0LjAzMzkgMTYuMDE4MlYyMC4wMjA4SDM2LjAyODZWMTYuMDE4Mkg0NC4wMzM5Wk0xMi4wMTMgMjQuMDIzNEg4LjAxMDQyVjI4LjAyNkgxMi4wMTNWMjQuMDIzNFpNMTYuMDE1NiAyNC4wMjM0SDM2LjAyODZWMjguMDI2SDE2LjAxNTZWMjQuMDIzNFpNNDQuMDMzOSAyNC4wMjM0SDQwLjAzMTJWMjguMDI2SDQ0LjAzMzlWMjQuMDIzNFoiIGZpbGw9IiNDNUM1QzUiLz4NCjwvZz4NCjxkZWZzPg0KPGNsaXBQYXRoIGlkPSJjbGlwMCI+DQo8cmVjdCB3aWR0aD0iNTMiIGhlaWdodD0iMzYiIGZpbGw9IndoaXRlIi8+DQo8L2NsaXBQYXRoPg0KPC9kZWZzPg0KPC9zdmc+DQo="}}]);
|
notebook_intelligence-2.2.0/notebook_intelligence/labextension/static/728.2f7d112a9c63a34d9d0f.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_notebook_intelligence_notebook_intelligence=self.webpackChunk_notebook_intelligence_notebook_intelligence||[]).push([[728],{68475:(n,e,o)=>{o.d(e,{A:()=>l});var t=o(31601),r=o.n(t),i=o(76314),a=o.n(i)()(r());a.push([n.id,"/*\n Copyright (c) Mehmet Bektas <mbektasgh@outlook.com>\n\n See the JupyterLab Developer Guide for useful CSS Patterns:\n https://jupyterlab.readthedocs.io/en/stable/developer/css.html\n*/\n\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n.sidebar-header {\n height: 25px;\n padding: 5px 10px;\n display: flex;\n}\n\n.sidebar-title {\n font-size: 14px;\n font-weight: bold;\n flex-grow: 1;\n}\n\n.sidebar-messages {\n flex-grow: 1;\n overflow-y: auto;\n padding: 5px;\n}\n\n.sidebar-user-input {\n height: 80px;\n padding: 5px;\n display: flex;\n flex-direction: column;\n background-color: var(--jp-cell-editor-background);\n border: 2px solid var(--jp-border-color1);\n margin: 4px;\n border-radius: 3px;\n}\n\n/* stylelint-disable */\n.sidebar-user-input.generating {\n background:\n linear-gradient(\n var(--jp-cell-editor-active-background),\n var(--jp-cell-editor-active-background)\n )\n padding-box,\n linear-gradient(var(--angle), #f1259c, #687aff) border-box;\n animation: 4s rotate-gen linear infinite;\n border: 2px solid #0000 !important;\n}\n/* stylelint-enable */\n\n.sidebar-user-input:focus-within {\n border-radius: 2px;\n border-color: var(--jp-brand-color1);\n}\n\n.sidebar-user-input textarea {\n width: 100%;\n font-family: var(--jp-ui-font-family);\n color: var(--jp-ui-font-color1);\n outline: none;\n border: none;\n resize: none;\n background: none;\n}\n\n.sidebar-user-input .user-input-context-row {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.user-input-context {\n display: flex;\n align-items: center;\n border: 1px solid var(--jp-border-color1);\n border-radius: 4px;\n padding: 2px;\n gap: 5px;\n font-size: 11px;\n}\n\n.user-input-context.off {\n color: var(--jp-ui-font-color2);\n font-style: italic;\n}\n\n.user-input-context-toggle {\n cursor: pointer;\n}\n\n.user-input-context-toggle:hover {\n background-color: var(--jp-layout-color2);\n}\n\n.user-input-context svg {\n width: 16px;\n height: 16px;\n margin: -4px 0;\n}\n\n.sidebar-user-input .user-input-footer {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 10px;\n}\n\n.chat-mode-widgets-container {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 5px;\n margin-right: 5px;\n}\n\n.chat-mode-select {\n height: 24px;\n background-color: initial;\n color: var(--jp-ui-font-color1);\n padding: 0 5px;\n border-color: var(--jp-border-color0);\n outline: none;\n}\n\n.user-input-footer-button {\n width: 24px;\n height: 24px;\n box-sizing: border-box;\n padding: 2px;\n cursor: pointer;\n color: var(--jp-ui-font-color2);\n}\n\n.user-input-footer-button.tools-button {\n width: auto;\n border: 1px solid var(--jp-border-color0);\n display: flex;\n align-items: center;\n gap: 2px;\n padding-right: 3px;\n}\n\n.user-input-footer-button.tools-button-warning {\n color: var(--jp-warn-color0);\n border-color: var(--jp-warn-color0);\n}\n\n.user-input-footer-button.tools-button-active {\n color: var(--jp-brand-color0);\n border-color: var(--jp-brand-color0);\n}\n\n.user-input-footer-button svg {\n width: 18px;\n height: 18px;\n}\n\n.chat-message {\n padding: 5px;\n display: flex;\n flex-direction: column;\n}\n\n.chat-message pre {\n padding: 3px;\n border-radius: 3px;\n border: 1px solid var(--jp-border-color1);\n}\n\npre:has(.code-block-header) {\n padding: 2px;\n background-color: var(--jp-layout-color2);\n}\n\n.chat-message-header {\n display: flex;\n}\n\n.chat-message-from {\n display: flex;\n align-items: center;\n flex-grow: 1;\n}\n\n.chat-message-from-icon {\n margin-right: 6px;\n}\n\n.chat-message-from-icon img {\n width: 18px;\n height: 18px;\n}\n\n.chat-response-img img {\n max-width: 100%;\n}\n\n.chat-message-from-icon-default.dark img {\n filter: invert(100%);\n}\n\n.chat-message-from-title {\n font-weight: bold;\n}\n\n.chat-message-from-progress {\n padding-left: 10px;\n flex-grow: 1;\n font-size: 12px;\n}\n\n.loading-ellipsis::after {\n display: inline-block;\n animation: animated-ellipsis steps(1, end) 1s infinite;\n content: '';\n}\n\n@keyframes animated-ellipsis {\n 0% {\n content: '';\n }\n\n 25% {\n content: '.';\n }\n\n 50% {\n content: '..';\n }\n\n 75% {\n content: '...';\n }\n\n 100% {\n content: '';\n }\n}\n\n.chat-message-timestamp {\n padding-left: 10px;\n font-size: 11px;\n}\n\n.chat-message-content p {\n margin-block: 5px 5px;\n line-height: 18px;\n}\n\n.chat-message-content a {\n text-decoration: underline;\n}\n\n.chat-message-copilot {\n background-color: rgb(159 153 208 / 15%);\n}\n\n.copilot-generated-notebook-link {\n text-decoration: underline;\n cursor: pointer;\n}\n\n.sidebar-login-info {\n padding: 5px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n line-height: 20px;\n}\n\n.sidebar-login-info a {\n text-decoration: underline;\n}\n\n.sidebar-login-buttons {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n}\n\n.sidebar-login-buttons .jp-Dialog-button.jp-mod-styled {\n margin-right: 0;\n}\n\n.sidebar-greeting {\n padding: 5px;\n font-size: 14px;\n line-height: 20px;\n}\n\n.user-code-span {\n cursor: pointer;\n color: var(--jp-content-link-color);\n}\n\n.user-code-span:hover {\n text-shadow: 1px 1px var(--jp-border-color1);\n}\n\n.user-code-span:active {\n color: var(--jp-ui-font-color2);\n}\n\n.chat-response-html-frame {\n margin: 5px 0;\n}\n\n.chat-response-html-frame-iframe {\n width: 100%;\n border: none;\n}\n\n.chat-response-anchor {\n margin: 5px 0;\n}\n\n.chat-response-button {\n margin: 5px 0;\n}\n\n.chat-response-progress {\n margin: 5px 0;\n}\n\n.chat-confirmation-form {\n border: 1px solid var(--jp-border-color1);\n padding: 5px;\n line-height: 20px;\n}\n\n.chat-confirmation-form button {\n height: 24px;\n line-height: 24px;\n padding: 0 6px;\n margin-top: 2px;\n}\n\n.user-input-autocomplete,\n.mode-tools-popover {\n display: flex;\n background-color: var(--jp-layout-color2);\n border: 1px solid var(--jp-border-color1);\n flex-direction: column;\n position: absolute;\n bottom: 98px;\n left: 4px;\n gap: 2px;\n /* stylelint-disable */\n max-height: min(calc(100% - 120px), 400px);\n /* stylelint-enable */\n overflow-y: auto;\n user-select: none;\n}\n\n.mode-tools-popover {\n width: calc(100% - 10px);\n /* stylelint-disable */\n max-height: min(calc(100% - 200px), 400px);\n /* stylelint-enable */\n box-shadow: var(--jp-brand-color0) 0 0 1px 1px;\n display: flex;\n flex-direction: column;\n}\n\n.mode-tools-popover-title {\n font-weight: bold;\n}\n\n.mode-tools-popover-header {\n display: flex;\n align-items: center;\n gap: 5px;\n height: 24px;\n background-color: var(--jp-layout-color1);\n padding: 2px;\n}\n\n.mode-tools-popover-header-icon svg {\n width: 18px;\n height: 18px;\n}\n\n.mode-tools-popover-clear-tools-button {\n flex-grow: 1;\n color: var(--jp-ui-font-color2);\n display: flex;\n padding-top: 3px;\n}\n\n.mode-tools-popover-clear-tools-button svg {\n width: 16px;\n height: 16px;\n}\n\n.mode-tools-popover-close-button {\n display: flex;\n align-items: center;\n cursor: pointer;\n width: auto;\n height: 24px;\n color: white;\n background-color: var(--jp-brand-color0);\n padding-right: 6px;\n border-radius: 2px;\n}\n\n.mode-tools-popover-close-button svg {\n width: 16px;\n height: 16px;\n padding: 4px;\n margin-top: 2px;\n}\n\n.mode-tools-popover-tool-list {\n flex-grow: 1;\n overflow-y: auto;\n}\n\n.mode-tools-group {\n display: flex;\n flex-direction: column;\n padding-left: 5px;\n margin-bottom: 5px;\n}\n\n.mode-tools-group-header {\n padding: 5px 0;\n border-bottom: 1px solid var(--jp-border-color1);\n margin: 0 5px;\n font-weight: bold;\n}\n\n.user-input-autocomplete-item {\n cursor: pointer;\n padding: 4px;\n}\n\n.user-input-autocomplete-item.selected {\n background-color: var(--jp-layout-color1);\n}\n\n.code-block-header {\n display: flex;\n align-items: flex-end;\n gap: 5px;\n padding: 3px;\n padding-bottom: 0;\n}\n\n.code-block-header-language {\n flex-grow: 1;\n}\n\n.code-block-header-button {\n display: flex;\n align-items: center;\n gap: 4px;\n cursor: pointer;\n padding: 2px;\n}\n\n.code-block-header-button:hover {\n background-color: var(--jp-layout-color1);\n}\n\n.code-block-header-button:active {\n background-color: var(--jp-layout-color3);\n}\n\n.copy-icon svg {\n width: 12px;\n height: 12px;\n}\n\n.send-button {\n display: flex;\n align-items: center;\n cursor: pointer;\n gap: 5px;\n border: 1px solid var(--jp-border-color1);\n}\n\n.send-button:hover:enabled {\n background-color: var(--jp-layout-color1);\n}\n\n.send-button svg {\n width: 18px;\n height: 18px;\n}\n\nbutton.send-button {\n padding: 4px;\n width: 24px;\n height: 24px;\n}\n\n.inline-popover {\n width: calc(100% - 6px);\n height: calc(100% - 6px);\n display: flex;\n flex-direction: column;\n position: absolute;\n background-color: #f2f3ff;\n}\n\nbody[data-jp-theme-light='false'] .inline-popover {\n background-color: #14162b;\n}\n\n.inline-prompt-container {\n width: 100%;\n height: 100%;\n padding: 2px;\n}\n\n.monaco-editor-container {\n width: 100%;\n flex-grow: 1;\n border: 1px solid var(--jp-border-color2);\n border-left: none;\n border-right: none;\n}\n\n.inline-popover-footer {\n height: 32px;\n width: calc(100% - 6px);\n display: flex;\n flex-direction: row;\n gap: 5px;\n align-items: center;\n padding-left: 5px;\n background-color: var(--jp-layout-color2);\n}\n\n.inline-prompt-container textarea {\n width: calc(100% - 2px);\n height: calc(100% - 2px);\n font-family: var(--jp-ui-font-family);\n color: var(--jp-ui-font-color1);\n resize: none;\n background: none;\n outline: none;\n border: none;\n}\n\n.inline-popover-footer .jp-Button {\n height: 24px;\n padding: 4px;\n}\n\n.github-copilot-status-bar {\n color: var(--jp-inverse-layout-color2);\n}\n\n.github-copilot-status-bar svg {\n margin-top: 4px;\n}\n\n.github-copilot-login-dialog {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 10px;\n width: 500px;\n line-height: 20px;\n}\n\n.github-copilot-login-status-text.logged-in {\n color: var(--jp-brand-color1);\n}\n\n.config-dialog {\n display: flex;\n flex-direction: column;\n width: 500px;\n height: 100%;\n}\n\n.config-dialog-container .jp-Dialog-footer {\n display: none;\n}\n\n.config-dialog-body {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n padding: 10px 0;\n gap: 15px;\n}\n\n.model-config-section-row {\n display: flex;\n flex-direction: row;\n gap: 10px;\n}\n\n.model-config-section-column {\n display: flex;\n flex-direction: column;\n gap: 10px;\n flex: 1 1 0px;\n}\n\n.config-dialog-footer {\n height: 32px;\n display: flex;\n margin-top: 10px;\n}\n\n.config-dialog-body select.jp-mod-styled {\n appearance: auto;\n}\n\n.config-dialog-body input.jp-mod-styled {\n width: 100%;\n}\n\n.model-config-section {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.form-field-row {\n padding-left: 15px;\n}\n\n.form-field-description {\n color: var(--jp-ui-font-color2);\n margin-bottom: 5px;\n}\n\n.model-config-section-header {\n font-weight: bold;\n font-size: 15px;\n}\n\n.model-config-section-body {\n padding-left: 10px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.inline-prompt-widget {\n border-radius: 4px;\n padding: 3px;\n z-index: 1000;\n box-shadow: rgba(90 76 191 / 30%) 0 0 10px 10px;\n}\n\n.inline-prompt-widget::before {\n border-radius: 4px;\n content: '';\n background-image: conic-gradient(\n from 270deg at 50% 50%,\n #3b37ff 0deg,\n #096bde 160deg,\n #f1259c 175deg,\n #7c3ffe 200deg,\n #7c3ffe 350deg,\n #3b37ff 360deg\n );\n /* stylelint-disable */\n left: -1px;\n right: -1px;\n top: -1px;\n bottom: -1px;\n /* stylelint-enable */\n position: absolute;\n z-index: -1;\n}\n\n/* stylelint-disable */\n.jp-InputArea-editor.generating {\n background:\n linear-gradient(\n var(--jp-cell-editor-active-background),\n var(--jp-cell-editor-active-background)\n )\n padding-box,\n linear-gradient(var(--angle), #f1259c, #687aff) border-box;\n animation: 4s rotate-gen linear infinite;\n border: 2px solid #0000 !important;\n}\n\n@keyframes rotate-gen {\n to {\n --angle: 360deg;\n }\n}\n\n@property --angle {\n syntax: '<angle>';\n initial-value: 0deg;\n inherits: false;\n}\n/* stylelint-enable */\n\n.ollama-warning-message {\n color: var(--jp-warn-color0);\n line-height: 20px;\n}\n\n.chat-reasoning-content-title {\n margin-top: 5px;\n display: flex;\n align-items: center;\n gap: 5px;\n cursor: pointer;\n color: var(--jp-ui-font-color2);\n}\n\n.chat-reasoning-content-text {\n display: none;\n margin: 5px;\n padding: 0 5px;\n border: 1px dashed var(--jp-border-color1);\n border-radius: 5px;\n}\n\n.chat-reasoning-content .collapsed-icon {\n display: inline;\n}\n\n.chat-reasoning-content .expanded-icon {\n display: none;\n}\n\n.chat-reasoning-content.expanded .expanded-icon {\n display: inline;\n}\n\n.chat-reasoning-content.expanded .chat-reasoning-content-text {\n display: block;\n}\n\n.chat-reasoning-content.expanded .collapsed-icon {\n display: none;\n}\n\n.access-token-config-header {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\nsvg.access-token-warning {\n color: var(--jp-warn-color0);\n width: 18px;\n height: 18px;\n}\n\n.checkbox-item {\n display: flex;\n flex-direction: column;\n cursor: pointer;\n}\n\n.checkbox-item:hover {\n background-color: var(--jp-layout-color1);\n}\n\n.checkbox-item-indent-0 {\n padding-left: 0;\n}\n\n.checkbox-item-indent-1 {\n padding-left: 12px;\n}\n\n.checkbox-item-indent-2 {\n padding-left: 24px;\n}\n\n.checkbox-item-indent-3 {\n padding-left: 36px;\n}\n\n.checkbox-icon {\n width: 16px;\n height: 16px;\n color: var(--jp-brand-color1);\n padding-top: 1px;\n}\n\n.checkbox-item-toggle {\n display: flex;\n align-items: center;\n gap: 5px;\n margin: 0 2px;\n padding: 3px 2px;\n color: var(--jp-ui-font-color1);\n}\n\n.checkbox-item-header .checkbox-item-toggle {\n color: var(--jp-ui-font-color0);\n font-weight: bold;\n}\n\n.mode-tools-group-built-in .checkbox-item-toggle {\n font-weight: normal;\n}\n\n.checkbox-item-description {\n padding-left: 25px;\n color: var(--jp-ui-font-color2);\n padding-bottom: 4px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n",""]);const l=a},76314:n=>{n.exports=function(n){var e=[];return e.toString=function(){return this.map((function(e){var o="",t=void 0!==e[5];return e[4]&&(o+="@supports (".concat(e[4],") {")),e[2]&&(o+="@media ".concat(e[2]," {")),t&&(o+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),o+=n(e),t&&(o+="}"),e[2]&&(o+="}"),e[4]&&(o+="}"),o})).join("")},e.i=function(n,o,t,r,i){"string"==typeof n&&(n=[[null,n,void 0]]);var a={};if(t)for(var l=0;l<this.length;l++){var p=this[l][0];null!=p&&(a[p]=!0)}for(var d=0;d<n.length;d++){var c=[].concat(n[d]);t&&a[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),o&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=o):c[2]=o),r&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=r):c[4]="".concat(r)),e.push(c))}},e}},31601:n=>{n.exports=function(n){return n[1]}},85072:n=>{var e=[];function o(n){for(var o=-1,t=0;t<e.length;t++)if(e[t].identifier===n){o=t;break}return o}function t(n,t){for(var i={},a=[],l=0;l<n.length;l++){var p=n[l],d=t.base?p[0]+t.base:p[0],c=i[d]||0,s="".concat(d," ").concat(c);i[d]=c+1;var g=o(s),x={css:p[1],media:p[2],sourceMap:p[3],supports:p[4],layer:p[5]};if(-1!==g)e[g].references++,e[g].updater(x);else{var u=r(x,t);t.byIndex=l,e.splice(l,0,{identifier:s,updater:u,references:1})}a.push(s)}return a}function r(n,e){var o=e.domAPI(e);return o.update(n),function(e){if(e){if(e.css===n.css&&e.media===n.media&&e.sourceMap===n.sourceMap&&e.supports===n.supports&&e.layer===n.layer)return;o.update(n=e)}else o.remove()}}n.exports=function(n,r){var i=t(n=n||[],r=r||{});return function(n){n=n||[];for(var a=0;a<i.length;a++){var l=o(i[a]);e[l].references--}for(var p=t(n,r),d=0;d<i.length;d++){var c=o(i[d]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}i=p}}},77659:n=>{var e={};n.exports=function(n,o){var t=function(n){if(void 0===e[n]){var o=document.querySelector(n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(n){o=null}e[n]=o}return e[n]}(n);if(!t)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");t.appendChild(o)}},10540:n=>{n.exports=function(n){var e=document.createElement("style");return n.setAttributes(e,n.attributes),n.insert(e,n.options),e}},55056:(n,e,o)=>{n.exports=function(n){var e=o.nc;e&&n.setAttribute("nonce",e)}},97825:n=>{n.exports=function(n){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=n.insertStyleElement(n);return{update:function(o){!function(n,e,o){var t="";o.supports&&(t+="@supports (".concat(o.supports,") {")),o.media&&(t+="@media ".concat(o.media," {"));var r=void 0!==o.layer;r&&(t+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),t+=o.css,r&&(t+="}"),o.media&&(t+="}"),o.supports&&(t+="}");var i=o.sourceMap;i&&"undefined"!=typeof btoa&&(t+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(t,n,e.options)}(e,n,o)},remove:function(){!function(n){if(null===n.parentNode)return!1;n.parentNode.removeChild(n)}(e)}}}},41113:n=>{n.exports=function(n,e){if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}},29728:(n,e,o)=>{var t=o(85072),r=o.n(t),i=o(97825),a=o.n(i),l=o(77659),p=o.n(l),d=o(55056),c=o.n(d),s=o(10540),g=o.n(s),x=o(41113),u=o.n(x),f=o(68475),h={};h.styleTagTransform=u(),h.setAttributes=c(),h.insert=p().bind(null,"head"),h.domAPI=a(),h.insertStyleElement=g(),r()(f.A,h),f.A&&f.A.locals&&f.A.locals}}]);
|