Add multi-language and kernel-aware notebook support#379
Open
moyiliyi wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull Request introduces support for multi-language environments and granular kernel management within Notebook-Intelligence. It transitions the system from a Python-centric model to one that can now discover available Jupyter kernels, preserve the active notebook's language/kernel context, and create notebooks against a selected kernel profile.
Motivation
Previously, Notebook-Intelligence was largely hardcoded to assume a Python environment. When creating a new notebook, it would simply iterate through available kernelspecs and pick the first one matching the "python" language. This limitation prevented users from:
By decoupling the language from the kernel name and providing a discovery mechanism, we enable the AI to be truly "polyglot" and aware of its execution environment.
Core Logic Changes
Environment Discovery: Added a new tool
list_available_notebook_kernelsthat allows the AI to query the frontend for all installed kernelspecs. This enables the AI to "know" what languages are supported on the user's machine before attempting to create content.Context Awareness: The ActiveDocumentWatcher now tracks not just the file's language but also the specific kernelName and displayName. This metadata is passed to the AI in requests, providing it with the exact context of the current execution environment.
Prompting and tool instructions were updated accordingly.
Built-in notebook-edit instructions and Claude Jupyter UI prompts now explicitly tell the model to preserve the current language/kernel, and to list available kernels before creating a notebook in a different environment.
New Interfaces & API Updates
Backend
languageandkernel_nametoChatRequestRuleContext: Replaced generic kernel with specificlanguageandkernel_namefields.create_new_notebook: Now accepts optionallanguageandkernel_nameparameters.list_available_notebook_kernels: New tool to fetch kernel profiles from the frontend.Frontend
notebook-intelligence:create-new-notebook: Replaces the Python-onlycreate-new-notebook-from-py.notebook-intelligence:list-available-notebook-kernels: Fetches the list of INotebookKernelProfile.