Skip to main content

A set of commands for AI in JupyterLab

Project description

jupyterlab-ai-commands

Github Actions Status

A set of commands for AI in JupyterLab

Requirements

  • JupyterLab >= 4.0.0

Install

To install the extension, execute:

pip install jupyterlab-ai-commands

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab-ai-commands

Available Commands

This extension provides the following commands for AI-assisted interactions with JupyterLab:

File Commands

  • jupyterlab-ai-commands:create-file - Create a new file of specified type (text, python, markdown, json, etc.)

    • Arguments:
      • fileName (string): Name of the file to create
      • fileType (string): Type of file to create (e.g., text, python, markdown, json, javascript, typescript, yaml, julia, r, csv)
      • content (string, optional): Initial content for the file
      • cwd (string, optional): Directory where to create the file
  • jupyterlab-ai-commands:open-file - Open a file in the editor

    • Arguments:
      • filePath (string): Path to the file to open
  • jupyterlab-ai-commands:delete-file - Delete a file from the file system

    • Arguments:
      • filePath (string): Path to the file to delete
  • jupyterlab-ai-commands:rename-file - Rename a file or move it to a different location

    • Arguments:
      • oldPath (string): Current path of the file
      • newPath (string): New path/name for the file
  • jupyterlab-ai-commands:copy-file - Copy a file to a new location

    • Arguments:
      • sourcePath (string): Path of the file to copy
      • destinationPath (string): Destination path for the copied file
  • jupyterlab-ai-commands:navigate-to-directory - Navigate to a specific directory in the file browser

    • Arguments:
      • directoryPath (string): Path to the directory to navigate to
  • jupyterlab-ai-commands:list-directory - List files and directories in a specific directory

    • Arguments:
      • directoryPath (string, optional): Path to the directory to list. If not provided, lists the root directory
      • includeHidden (boolean, optional): Whether to include hidden files (default: false)
  • jupyterlab-ai-commands:get-file-info - Get information about a file including its path, name, extension, and content

    • Arguments:
      • filePath (string, optional): Path to the file to read. If not provided, uses the currently active file in the editor
  • jupyterlab-ai-commands:set-file-content - Set or update the content of an existing file

    • Arguments:
      • filePath (string): Path to the file to update
      • content (string): The new content to set for the file
      • save (boolean, optional): Whether to save the file after updating (default: true)
      • showDiff (boolean, optional): Whether to show a diff view of the changes (default: true)

Notebook Commands

  • jupyterlab-ai-commands:create-notebook - Create a new Jupyter notebook with a kernel for the specified programming language

    • Arguments:
      • language (string, optional): The programming language for the notebook (e.g., python, r, julia, javascript, etc.). Will use system default if not specified
      • name (string): Name for the notebook file (without .ipynb extension)
  • jupyterlab-ai-commands:add-cell - Add a cell to the current notebook with optional content

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
      • content (string, optional): Content to add to the cell
      • cellType (string, optional): Type of cell to add - "code", "markdown", or "raw" (default: "code")
      • position (string, optional): Position relative to current cell - "above" or "below" (default: "below")
  • jupyterlab-ai-commands:get-notebook-info - Get information about a notebook including number of cells and active cell index

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
  • jupyterlab-ai-commands:get-cell-info - Get information about a specific cell including its type, source content, and outputs

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
      • cellIndex (number, optional): Index of the cell to get information for (0-based). If not provided, uses the currently active cell
  • jupyterlab-ai-commands:set-cell-content - Set the content of a specific cell

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
      • cellId (string, optional): ID of the cell to modify. If provided, takes precedence over cellIndex
      • cellIndex (number, optional): Index of the cell to modify (0-based). Used if cellId is not provided. If neither is provided, targets the active cell
      • content (string): New content for the cell
      • showDiff (boolean, optional): Whether to show a diff view of the changes (default: true)
  • jupyterlab-ai-commands:run-cell - Run a specific cell in the notebook by index

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
      • cellIndex (number): Index of the cell to run (0-based)
      • recordTiming (boolean, optional): Whether to record execution timing (default: true)
  • jupyterlab-ai-commands:delete-cell - Delete a specific cell from the notebook by index

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook
      • cellIndex (number): Index of the cell to delete (0-based)
  • jupyterlab-ai-commands:save-notebook - Save a specific notebook to disk

    • Arguments:
      • notebookPath (string, optional): Path to the notebook file. If not provided, uses the currently active notebook

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlab_ai_commands directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

pip uninstall jupyterlab_ai_commands

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab-ai-commands within that folder.

Testing the extension

Integration tests

This extension uses Playwright for the integration tests (aka user level tests). More precisely, the JupyterLab helper Galata is used to handle testing the extension in JupyterLab.

More information are provided within the ui-tests README.

Packaging the extension

See RELEASE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_ai_commands-0.1.3.tar.gz (106.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlab_ai_commands-0.1.3-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_ai_commands-0.1.3.tar.gz.

File metadata

  • Download URL: jupyterlab_ai_commands-0.1.3.tar.gz
  • Upload date:
  • Size: 106.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jupyterlab_ai_commands-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f1b920a1135e4fd474a52caf25652872bf00d6a7a81810ac6a082746b8cab214
MD5 1c81ed0d073e7e90542ade9025394a6d
BLAKE2b-256 2d21993d4b1a68f3756b1e8613b0ffa94f6cc4c96507e300a7e83f580b39b597

See more details on using hashes here.

File details

Details for the file jupyterlab_ai_commands-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_ai_commands-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e126783e12771e05bb93b6dc60d69615ec4cc513c56c4812625a4ed8464b3fa7
MD5 14a22b145360705ff9d4eeedeb87f7db
BLAKE2b-256 9d1082aee5c0cfa59d8cb0d0ee060f553f637a8a729f565fb82a4026c08a60dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page