Skip to content

Generative AI in Jupyter Notebooks

Carlos Lizarraga-Celaya edited this page May 4, 2024 · 1 revision

(Credit: Open Data Science, Medium)

User-friendly and powerful way to explore generative AI models in notebooks and improve your productivity in JupyterLab and the Jupyter Notebook.


Some ways to enhance Jupyter notebooks with AI tools:

  • Code generation: Generative AI can be used to generate code, which can save developers time and effort. For example, a developer could use generative AI to generate a skeleton of a new codebase, or to fill in the details of a specific function.
  • Code summarization: Generative AI can be used to summarize code, which can make it easier for developers to understand and maintain code. For example, a developer could use generative AI to generate a summary of a complex algorithm, or to identify the key changes in a codebase.
  • Code debugging: Generative AI can be used to debug code, which can help developers to find and fix errors. For example, a developer could use generative AI to generate a list of potential errors in a codebase, or to suggest solutions to specific errors.
  • Code testing: Generative AI can be used to test code, which can help developers to ensure that their code is working as expected. For example, a developer could use generative AI to generate test cases for a new codebase, or to identify potential security vulnerabilities in a codebase.

Jupyter AI

Jupyter AI brings generative artificial intelligence to Jupyter notebooks, giving users the power to explain and generate code, fix errors, summarize content, ask questions about their local files, and generate entire notebooks from a natural language prompt.

Installation using conda:

conda update conda
conda install -c conda-forge jupyter-ai

Installation using pip:

$ pip install jupyter-ai

The %%ai magic command

The %%ai magic works anywhere the IPython kernel runs, including JupyterLab, Jupyter Notebook, Google Colab, and Visual Studio Code.

Once you have installed the %%ai magic, you can enable it in the Jupyter Lab notebook or the IPython shell by running:

%load_ext jupyter_ai

Created: 05/03/2024 (C. Lizárraga); Last update: 05/06/2024 (C. Lizárraga)

CC BY-NC-SA