AI Extension Jupyter AI edits and creates Jupyter Notebooks
Project Jupyter launched the Jupyter AI extension as an official sub-project. The open-source extension provides a chat interface and equips Jupyter Notebooks with Generative Artificial Intelligence (AI) capabilities to edit and explain existing notebooks and create new ones.
Advertisement
To do this, Jupyter AI requires the use of the web-based user interface JupyterLab, uses large language models (LLM) from providers such as Open AI, AWS and Anthropic and should attach importance to data protection. The extension offers two ways to interact: either via chat UI or via magic command %%ai.
Notebook changes through conversations with Jupyternaut
Jupyter AI provides a chat interface where users can communicate with Jupyternaut. Jupyternaut is a conversational agent with a user-selected language model that communicates primarily via text. However, he can also interact with files in JupyterLab and include their contents in his answers, as well as insert output into notebooks or generate new notebooks.
The development team cites inserting code from a notebook into a prompt and asking for an explanation as a possible application example. In addition, Jupyternaut can change the code, find errors in it and optionally replace the marked section. However, Project Jupyter emphasizes that developers should review any AI-generated code themselves before executing it, just as they would anyone else’s code.
In this example, Jupyternaut is instructed to rewrite existing code with comments. To do this, it sends the code to the selected language model and replaces the selection with its output:
Instructing Jupyternaut to rewrite code highlighted in a notebook with comments.
(Image: Project Jupyter)
Jupyternaut modified the notebook content accordingly using a language model.
(Image: Project Jupyter)
To create a completely new notebook, use the /generate command with an associated text description. Using the language model used, Jupyternaut will name the workbook and fill it with markdown and code cells, which can take a few minutes. The chat UI can still be used while waiting. Again, Project Jupyter advises to validate any code in the newly generated notebook before running it.
Advertisement
While Jupyternaut generates a new notebook, the conversation agent is still responsive.
(Image: Project Jupyter)
Other Jupyternaut capabilities include learning from local files via /learn and answering questions about them via /ask.
Operation by magic command
In addition to the chat interface, Jupyter AI allows the use of so-called magic commands that can be used in notebook cells and in the IPython command line interface. To do this, the Magics extension must first be loaded using %load_ext jupyter_ai_magics. Then you can use Jupyter AI with the %%ai magic command. %ai help provides information on this.
%%ai can be used anywhere the IPython kernel can run, including JupyterLab, Notebook, IPython, Colab, and Visual Studio Code.
Development, connection and installation instructions
Jupyter AI is the brainchild of five AWS employees who contribute to Project Jupyter, some of whom are founding members or members of the JupyterLab Council. As the developers point out, they built Jupyter AI with responsible AI and privacy in mind. It should only contact a language model or transmit data there if users explicitly request it.
As a vendor-neutral tool, Jupyter AI can currently handle the major language models of AI21, Anthropic, AWS, Cohere, HuggingFace Hub, and OpenAI. Additional language models are to follow.
To use Jupyter AI, JupyterLab must be installed. Jupyter AI 1.0 is designed exclusively for JupyterLab 3, Jupyter AI 2.0 exclusively for JupyterLab 4, with the development team recommending the latter.
The extension can be obtained via pip:
pip install ‘jupyter-ai>=1.0,<2.0' # when using JupyterLab 3 pip install jupyter-ai # when using JupyterLab 4
More information about Jupyter AI can be found in a blog post, as well as in the GitHub repository and on the project’s website.
(May)
Go to home page
#Extension #Jupyter #edits #creates #Jupyter #Notebooks