ChatGPT

ChatGPT can transform how you use CoCalc for learning, writing programs, and writing scientific documents.

Here are some areas where CoCalc’s context-sensitive ChatGPT help can save you time and effort:

You can read all CoCalc ChatGPT announcements to date and join the discussion at the links shown:

  1. ChatGPT integration via any chatroom in cocalc.

  2. Cocalc chatrooms now support reply message threads, and chatgpt now has “long memory” of the entire thread it was involved in.

  3. CoCalc Jupyter notebooks now have a new “Explain” button in Jupyter notebooks.

  4. New button to help you fix errors in Jupyter notebooks.

  5. ChatGPT integration with the Linux Terminal.

  6. Easily use the OpenAI ChatGPT API from your Jupyter notebooks in CoCalc.

ChatGPT Tour

You can launch a short introduction to CoCalc’s support for ChatGPT by clicking the blue Tour button at upper right in the ChatGPT dialog box whenever you open ChatGPT in CoCalc. This is one of several Tours of features in CoCalc.

chatgpt tour

ChatGPT tour

GPT-3.5 and GPT-4

CoCalc makes three different versions of ChatGPT available. The options are displayed whenever you ask ChatGPT something. Here is an example showing the choices when ChatGPT is asked to Explain a code block in a Jupyter notebook:

GPT-3.5

The first option is OpenAI’s fastest model, GPT-3.5 with 4k token context. It is offered in CoCalc free of charge and sufficient for most everyday tasks.

GPT-3.5 (4k)

GPT-3.5 (4k token context)

GPT-3.5-16k

The GPT-3.5-16k model is the same as GPT-3.5, but with much larger context size (16k token context).

GPT-3.5 (16k)

GPT-3.5-16k

GPT-4

GPT-4 is OpenAI’s most capable model, great for tasks that require creativity and advanced reasoning (8k token context). GPT4 is generally considerably slower than either of the GPT-3.5 options.

GPT-4

GPT-4

Jupyter Notebooks

Fixing Errors

Have you ever been using a Jupyter notebook and got an error message? You can now click a button and ChatGPT will automatically try to figure out how to fix the error and tell you in a chat next to your main document.

It is often helpful to chat back and forth with ChatGPT in Side Chat to refine the initial answer. Use the “Reply” button in side chat to ask follow-up questions.

ChatGPT can help you understand and fix execution errors in a Jupyter notebook code cell.

ask how to fix an error

asking how to fix an error

Suggesting Code

Here is an example of a code suggestion using ChatGPT with a python Jupyter notebook.

Sample request: plot time series data using a pandas dataframe

  1. Ask the question in the ChatGPT box above the Jupyter notebook.

    ask for suggestion

    asking for a code suggestion

  2. Copy the code from the response in side chat.

    copy chat response

    copying suggested code

  3. Paste the code into a notebook code cell.

  4. Inspect the code for correctness.

  5. Run the code.

Explaining Code

ChatGPT can explain what is going on in a Jupyter notebook code cell.

  • The “Explain” button in the upper right of the cell always uses exactly the current cell.

    explain a code cell

    asking to explain contents of a code cell

  • The “ChatGPT” button at the top uses: the current selection, or if there is no selection, the current cell, or if the cell is empty, all the cells.

Sage Worksheets

You can get help from ChatGPT when an error occurs while running a sage worksheet, too. See ChatGPT help with sage worksheets for details.

Editing Python, R, and Other Files

For programming language file types such as .py, .R, pl, and .c, the CoCalc Frame Editor includes ChatGPT buttons in the top menu. ChatGPT editor support actually works for hundreds of file types (basically everything that exists), including LaTeX (“.tex”) and R markdown (“.rmd”).

  1. Open a .py file in CoCalc.

  2. Notice there’s a ChatGPT button in the top menu bar.

    chat help editing a python file

    ChatGPT button displayed above .py file

Linux Terminal

ChatGPT in combination with the Linux terminal is extremely powerful, because ChatGPT can help you write a script for any command that can be invoked from the command shell. See the next subsections for example.

Linux Terminal windows include a ChatGPT button at the top.

chat button in a terminal window

ChatGPT button displayed above terminal window

Suggest Code for Shell Scripts

You can get help with basic shell scripting as well as with advanced CoCalc commands.

Sample requests:

  • replace ‘x’ by ‘y’ in all files

  • how can I use pari/gp to compute the number of primes up to 2023

  • count the total number of lines of code in all coffeescript files under git in all subdirectories then follow-up with: can you exclude counting blank lines and comments?

  • write a SQL query with psql - full example below.

Help Writing SQL Queries

Sample request:

I am using psql to query a table with a column called “time”. I would like to make a table showing the number of entries in my table for each of the last 7 days.

Scientific Documents

Typeset Scientific Content with LaTeX

You can describe a formula in English and have ChatGPT turn it into a latex formula. Sample requests:

  • Use latex to typeset the following formula: the integral from 0 to infinity of sin(x^2)

  • Use latex to typeset the following formula: (a + b + c) / alpha

custom help latex formulas

ChatGPT help with latex formulas

ChatGPT on Sign-in and Feature Pages

You can ask a question at the start of your CoCalc session. ChatGPT help boxes are at the top of the sign-in page and all feature headings (landing pages).

custom help at sign-in page

ChatGPT help near top of sign-in page

ChatGPT is available near the top of the CoCalc features main page and each of the individual feature pages.

help at features page

ChatGPT help near top of features page

ChatGPT in Chat Rooms and Side Chat

In a chat room or in the side chat next to an open file, you can do an @-mention of ChatGPT and enter your question there.

@-mention help with latex

@-mention help with latex

GPT-4 in CoCalc Courses

See: GPT4 with Courses.

CoCalc Admins: add ChatGPT to your site

CoCalc-Docker: ChatGPT integration in latest image.