avatarThe PyCoach

Summary

The undefined website content introduces the ChatGPT extension for Jupyter Notebooks, which integrates ChatGPT functionalities such as code formatting, explanation, debugging, completion, and review directly within the Jupyter environment.

Abstract

The article discusses the integration of ChatGPT into Jupyter Notebooks through a browser extension, enhancing the data science workflow by providing features like automatic code formatting, explanations in ELI5 style, debugging assistance, code completion, and more. Users can install the extension from the Chrome Web Store or locally for Firefox, and it requires an OpenAI API key to function. The extension adds new buttons to the Jupyter toolbar, streamlining tasks such as adding comments and docstrings, explaining code behavior, debugging errors, and completing code snippets based on user instructions. Additionally, the extension offers voice command functionality through the OpenAI Whisper API, albeit at an additional cost. The article also provides a link to a free ChatGPT cheat sheet for subscribers and encourages readers to support the writer by becoming Medium members.

Opinions

  • The author believes that the ChatGPT extension is a valuable tool for data scientists using Jupyter Notebooks, suggesting it as a must-have for anyone working with data.
  • The article implies that the extension, powered by GPT-4, significantly enhances productivity by automating several coding-related tasks within the Jupyter environment.
  • The author highlights the user-friendliness of the extension, emphasizing the ease of installation and setup, as well as the straightforward functionality of the new toolbar buttons.
  • The provision of a free cheat sheet and the call to support the writer through Medium membership signifies the author's commitment to providing value to the data science community while also seeking support for their work.
  • The mention of potential issues with API key saving and the direction to the GitHub repository for troubleshooting suggests a proactive approach to addressing common user difficulties.

ChatGPT for Jupyter: The ChatGPT Extension for Jupyter Notebooks

The extension every data scientist needs.

Image made with Canva

In a previous article, we saw a VSCode extension with ChatGPT-like functionalities, and today we’ll see how to integrate ChatGPT in Jupyter Notebooks, which will be very useful for anyone who works with data.

You heard that right! You can get ChatGPT’s functionalities such as format, explain, debug, complete, and review code right from Jupyter Notebook.

Let’s dive into it!

How to install the ChatGPT extension for Jupyter Notebooks

First of all, this is a browser extension powered by GPT-4, which means that we have to download the extension from the web store.

If you’re a Chrome user, go to this website and install the extension, while if you’re a Firefox you can install it locally following the steps here.

After the extension is installed, open the settings window. You have to select OpenAI API, choose a model you want to use, and insert your OpenAI API key, which you can find here.

Screenshot

Note: In case the “Which AI Provider do you want to use?” prompt has an infinite loading circle and your API key isn’t saved, open up the regular ChatGPT page, send a message there, and then come back to the settings page and refresh it. Now you should see the image above (for other issues like this, visit the Github repo).

In case you don’t have API keys, you can create one by following the steps in the image below.

Screenshot

Once your key is saved, you can open Jupyter Notebook in Chrome. After you open or create a new notebook, you’ll see that there are new buttons on the toolbar.

Screenshot

Let’s explore their functionality.

Note: If you’re a Mac user and Safari is your default browser, you should change the default browser to Chrome/Firefox if you want to work with the extension installed. To change the default browser to Chrome, click on the three dots, settings, and select “default browser” from the left panel.

Format code

This extension allows you to automatically add comments, docstrings, and formatting to your cell. To do so, you have to click on the button below and you’ll automatically get an improved version of the code.

Here’s an example with a Python function.

Source: GitHub

As you can see, the extension added docstrings and comments to our code.

Explain code

With this extension, you can explain the content of your code cell using ELI5 style. Just click on the “Explain” button and a window will pop up with a comprehensive explanation of the code cell.

Source: GitHub

Debug code

You can easily debug an error message in your code cell and obtain an explanation of the error (as you’d get with ChatGPT) by using the “Debug” button.

Source: GitHub

As you can see, ChatGPT found a typo in my code and suggested replace replace date with replace dates .

Complete code

One of my favorite functionalities of this extension is code completion. It allows you to complete a code snippet in your code cell. You only need to leave a comment with the instructions and add some code if necessary.

Here’s an example.

Source: GitHub

As you can see, we only needed a comment and a list of samples to generate the code we wanted.

More Functionalities

There are other things you can do with this extension such as run a code review of your code cell, ask questions to ChatGPT, and even ask ChatGPT a question through your microphone.

Just keep in mind that if you use the voice command feature, you’ll need the OpenAI Whisper API, which charges $0.006 per minute.

Artificial Corner’s Free ChatGPT Cheat Sheet

We’re offering a free cheat sheet to our readers. Join our newsletter with 20K+ people and get our free ChatGPT cheat sheet.

If you enjoy reading stories like these and want to support me as a writer, consider signing up to become a Medium member. It’s $5 a month, giving you unlimited access to thousands of Python guides and Data science articles. If you sign up using my link, I’ll earn a small commission with no extra cost to you.

Artificial Intelligence
ChatGPT
Data Science
Python
Data Analysis
Recommended from ReadMedium