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:
CoCalc Jupyter notebooks now have a new “Explain” button in Jupyter notebooks.
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.
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-16k
The GPT-3.5-16k model is the same as GPT-3.5, but with much larger context size (16k token context).
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.
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.
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
Ask the question in the ChatGPT box above the Jupyter notebook.
Copy the code from the response in side chat.
Paste the code into a notebook code cell.
Inspect the code for correctness.
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.
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”).
Open a .py file in CoCalc.
Notice there’s a ChatGPT button in the top menu bar.
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.
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
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).
ChatGPT is available near the top of the CoCalc features main page and each of the individual feature pages.
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.
GPT-4 in CoCalc Courses
See: GPT4 with Courses.
CoCalc Admins: add ChatGPT to your site
CoCalc-Docker: ChatGPT integration in latest image.