Skip to content

Add multi-language and kernel-aware notebook support#379

Open
moyiliyi wants to merge 1 commit into
plmbr:mainfrom
moyiliyi:feat/multi-lang-kernels
Open

Add multi-language and kernel-aware notebook support#379
moyiliyi wants to merge 1 commit into
plmbr:mainfrom
moyiliyi:feat/multi-lang-kernels

Conversation

@moyiliyi

Copy link
Copy Markdown
Contributor

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:

  1. Using other popular data science languages like R, Julia, or C++.
  2. Selecting specific Python kernels when multiple Python kernels were present.
  3. Applying AI rules tailored to specific languages vs. specific kernel implementations.

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

  1. Environment Discovery: Added a new tool list_available_notebook_kernels that 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.

  2. 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.

  3. 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

  • Adds language and kernel_name to ChatRequest
  • RuleContext: Replaced generic kernel with specific language and kernel_name fields.
  • Tools:
    • create_new_notebook: Now accepts optional language and kernel_name parameters.
    • list_available_notebook_kernels: New tool to fetch kernel profiles from the frontend.

Frontend

  • Commands:
    • notebook-intelligence:create-new-notebook: Replaces the Python-only create-new-notebook-from-py.
    • notebook-intelligence:list-available-notebook-kernels: Fetches the list of INotebookKernelProfile.
  • INotebookKernelProfile: New interface representing a kernel's language, kernelName, and displayName.
  • IActiveDocumentInfo: Now includes optional kernelName and kernelDisplayName.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant