My experience with ChatGPT

Published on: Tue Dec 27 2022

Introduction

What is ChatGPT? Actually, I’m going to let ChatGPT introduce himself to you:

Hi there! I’m ChatGPT, a chatbot tool developed by OpenAI that uses the GPT language model to generate human-like text. I’ve been trained on a massive dataset of human conversation, so I can produce responses that are natural, coherent, and relevant to the conversation at hand. With me, developers can easily create chatbots that can hold engaging and informative conversations on a wide range of topics. These chatbots can handle tasks like answering questions, providing recommendations, and engaging in casual conversation, all while providing a seamless and engaging user experience. Whether you’re looking to build a customer service chatbot or simply want to create a chatbot for fun, I’m a powerful and versatile tool for creating chatbots that can hold intelligent and engaging conversations.

As you can see, ChatGPT is the next step in actually useful natural language AI. It was built upon the GPT3 language model (so it’s sort of like a GPT 3.5) with additional manual human feedback. The result is an AI that exceeded all of my exepectations of what we can accomplish with natural language AI in the year 2022. Don’t get me wrong, GPT3 and its predecesors were already incredible. However, as you will see in this article, ChatGPT will make you excited and scared for the future and the limits of human productivity.

Disclaimer!: ChatGPT only has access to knowledge up to 2021. So it is not aware of any newer information past 2021. I hope that in the future they will make an architecture that can continuously get updated, but this is what we have for now.

As you can imagine, I will mostly go into what ChatGPT can do for software related topics. But before we get into those topics, I want to share what I was able to acquire on non-technical topics. This will give you a better picture of how broad ChatGPT’s knowledge is.

Omega 3

Prompt: Should you take omega 3 after a fatty meal?
ChatGPT: It is generally recommended to take omega-3 supplements with a meal, as this can help increase the absorption of the fatty acids. However, it is not necessary to take them after a particularly fatty meal. Omega-3 supplements can be taken at any time that is convenient for you, as long as you are consistent in your daily dosage. It is important to follow the dosage instructions provided by the manufacturer of the supplement you are using.

Omega-3 supplements are usually taken to help support heart health, brain function, and overall health and well-being. They are found in a variety of sources, including fish oil, flaxseed oil, and algae oil. It is generally recommended to aim for a daily intake of at least 250 to 500 milligrams of EPA and DHA, the two main types of omega-3 fatty acids found in fish oil.

It is also important to note that while omega-3 supplements can be beneficial, they should not be used as a substitute for a healthy diet that includes a variety of foods rich in omega-3s. These include fatty fish, nuts and seeds, and plant-based oils.
Prompt: is omega 3 stored in the body for a long time?
ChatGPT: Omega-3 fatty acids are not stored in the body for a long time. They are classified as essential fatty acids, which means that the body cannot produce them on its own and must obtain them from the diet. Omega-3 fatty acids are used by the body for a variety of functions, including maintaining the structure of cell membranes, regulating inflammation, and supporting brain and heart health.

Once they are consumed, omega-3 fatty acids are incorporated into the tissues of the body, where they can be used for energy or stored in the form of fat. However, the body's stores of omega-3s are relatively small and are continuously being used up and replenished. This is why it is important to consume a sufficient amount of omega-3s on a regular basis through the diet or supplements.

There are three main types of omega-3 fatty acids: EPA (eicosapentaenoic acid), DHA (docosahexaenoic acid), and ALA (alpha-linolenic acid). EPA and DHA are found primarily in fatty fish and algae, while ALA is found in plant-based sources such as nuts, seeds, and certain vegetable oils. The body can convert a small amount of ALA into EPA and DHA, but this process is inefficient, so it is important to consume EPA and DHA directly.

Cooking A Goose

Prompt: We're cooking a goose. What do I need to look out for
ChatGPT: Cooking a goose can be a bit of a challenge, as they are a large bird with a lot of fat that needs to be rendered out during the cooking process. Here are some things to keep in mind when cooking a goose:

1. Start by preheating your oven to 350°F (175°C).
2. Before cooking, it's important to properly prepare the goose. This includes removing any excess fat from the cavity, as well as trussing the legs to help the bird cook evenly.
3. To help the fat render out, it's a good idea to prick the skin all over with a fork. This will also help the skin get crispy.
4. Place the goose in a roasting pan, breast side up. Add some vegetables, such as carrots and onions, to the pan to add flavor and moisture to the bird.
5. Roast the goose for about 20 minutes per pound, or until the internal temperature reaches 165°F (74°C).
6. Baste the goose with the pan juices every 30 minutes or so to help keep it moist.
7. When the goose is done cooking, let it rest for at least 15 minutes before carving. This will allow the juices to redistribute and make the meat more tender.
8. When carving the goose, be sure to slice through the breast meat horizontally, rather than vertically. This will help to keep the slices more moist.

I hope these tips are helpful! Good luck with your cooking.

Teaching Korean

Prompt: How do I say "I'm walking in the woods" in korean?
ChatGPT: To say "I'm walking in the woods" in Korean, you can use the following phrase:

나는 숲 속에서 걷고 있어요. (naneun sup sogeseo geotgo isseoyo)

Here's a breakdown of the grammar points used in this sentence:
- "나는" (naneun) is the first person pronoun "I," and it is followed by the particle "은/는" (eun/neun) to mark the topic of the sentence.
- "숲 속에서" (sup sogeseo) means "in the woods." "숲" (sup) means "woods," and "속에서" (sogeseo) means "in."
- "걷고 있어요" (geotgo isseoyo) is the present tense form of the verb "걷다" (geotda), which means "to walk." "걷고" (geotgo) is the stem of the verb "걷다" (geotda) with the suffix "-(으)ㄴ/는" (-(eu)n/neun) added to indicate the present tense, and "있어요" (isseoyo) is the present tense form of the copula "있다" (issda), which means "to be."

So, the full phrase "나는 숲 속에서 걷고 있어요" (naneun sup sogeseo geotgo isseoyo) means "I'm walking in the woods."
Prompt: I need an NDA with a client to manage his login credentials
ChatGPT: An NDA, or non-disclosure agreement, is a legal contract between two parties in which one party agrees to keep certain information confidential. An NDA can be used to protect a wide range of information, including login credentials.

Here is an example of how an NDA might be used to protect login credentials:

"The Receiving Party (the party receiving the login credentials) agrees to use the Confidential Information (the login credentials) only for the purpose of performing the services specified in this Agreement. The Receiving Party shall keep the Confidential Information strictly confidential and shall not disclose the Confidential Information to any third party without the prior written consent of the Disclosing Party (the party disclosing the login credentials). The Receiving Party shall take all reasonable precautions to prevent the unauthorized disclosure of the Confidential Information."

It's important to note that an NDA is a legally binding document and can have serious consequences if violated. If you are considering using an NDA to protect login credentials, it's a good idea to have a lawyer review the document to ensure that it is properly drafted and meets your needs.

As you can see, ChatGPT is only limited by your thirst of knowledge. Ever wondered what the differences between the Harry Potter books and movies are? Ever needed help with a recipee? Need gift ideas for a friend? Why German college is mostly free? Whatever it is, you’ll certainly get something useful out of ChatGPT. And even if it’s not on the first prompt, you can steer it gently in the right direction over a conversation.

Now, let’s get to the technical prompts and how they might make your job of developing software easier.

Research

This is, in my experience, ChatGPT’s strongest side: Its ability to provide useful and condensed information about a new topic.

Instead of googling X, opening 30 tabs and scrolling through forums, you can save yourself a lot of time by just asking ChatGPT and continously prompting more information.

A practical example: I acquired a project where another software company wanted to modernize their legacy windows desktop application, that was literally written in 1994 and last updated 2007. It was a collection of flash animations and interactive elements. So to minimize effort I was wondering if we could do something with the existing flash files and not have to rewrite everything in HTMl5 Canvas and JavaScript. This is my conversation with ChatGPT:

Prompt: How can I make flash content work in a modern web application?
ChatGPT: Flash content is not supported in most modern web browsers, so it is not possible to make it work in a modern web application. Instead, you can try using HTML5 or other newer technologies that are supported by modern web browsers and offer similar capabilities as Flash. For example, you could use HTML5 to create interactive graphics, animations, and other types of multimedia content for your web application. Additionally, many popular web browsers now have built-in tools that allow you to convert Flash content into HTML5 format. This can help you make your existing Flash content work on modern web platforms.
Prompt: How can I convert flash content into html5 formats?
ChatGPT: There are a few different tools and methods that you can use to convert Flash content into HTML5 format. One option is to use a dedicated converter tool, such as Adobe Animate or Google Swiffy, which are specifically designed to convert Flash files into HTML5 format. You can also use a web-based converter tool, such as the one available at https://flash-to-html5.com/, which allows you to convert your Flash files directly in your web browser.
Prompt: Google Swiffy doesnt seem to be maintained anymore
ChatGPT: You are correct. Google Swiffy was a tool that was used to convert Flash files into HTML5 format, but it has not been actively maintained by Google since 2012. As a result, it may not be able to convert more recent or complex Flash files into HTML5 format. There are other tools that you can use to convert Flash files into HTML5 format, such as Adobe Animate or other web-based converter tools. You can also try using a tool that specializes in converting Flash files into other formats, such as SWF to MP4 or SWF to GIF, which can then be used in your HTML5 web application.
Prompt: What about interactive flash elements that use actionscript?
ChatGPT: If your Flash content uses ActionScript, a programming language used to create interactive elements in Flash, it may be more difficult to convert it into HTML5 format. This is because HTML5 does not support ActionScript and does not have a direct equivalent for many of the features and functions that are available in ActionScript. However, there are tools and techniques that you can use to recreate the interactive elements of your Flash content in HTML5.

For example, you can use JavaScript, the programming language commonly used in web development, to add interactivity to your HTML5 content. You can also use other web technologies, such as CSS3 and WebGL, to create animations and other visual effects that are similar to those created with ActionScript. Additionally, you can use libraries and frameworks, such as jQuery or three.js, to make it easier to add interactivity and other advanced features to your HTML5 content.

Honestly this blew my mind. I had already done some manual google research the week before, since I hadn’t gotten to use ChatGPT at that time. But the results it gave me in a matter of minutes were equally, if not better, useful than my 3 hours of searching through articles, YouTube and Google search result pages.

Code Generation

This one is very interesting. I have gotten incredible, mediocre and completely results in this category.

A very impressive feat I got was when I asked ChatGPT about generating code for a Mandelbrot set. It’s one of many fractals and looks very pretty.

Prompt: Give me an html page that generates a mandelbrot set
ChatGPT: Here is an HTML page that generates a Mandelbrot set:

... HTML Code ...

To see the Mandelbrot set, save this code to a file with a .html extension and open it in a web browser. You should see a black and white image of the Mandelbrot set. You can modify the color palette to change the colors of the image, and you can also adjust the size of the canvas and the maximum number of iterations to change the detail and smoothness of the image.

I copied the HTML it gave me 1:1 and put it on the following page: mandelbrot

This honestly blew me away… first try and it just works. And the most amazing part is that you can now go into a dialog with ChatGPT and ask it to make any modifications you’d like. “Make it less colorful”, “Use TypeScript”, “Rewrite it with React”, “Make it compatible with IE9”, … All of this will be executed beautifully by ChatGPT.

Now to take away some excitement, there were some flaws when I asked it to do more fancy things. For example I wanted it to do a version using WASM and C. So it would generate the mandelbrot points in C and send them over to JavaScript by compiling it to WASM and rendering it in the canvas.

It honestly failed miserably. It gave me incorrect instructions to install emscripten on my linux system. It provided me wrong C code, that didn’t export anything to WASM. It gave me wrong JavaScript code that didn’t import the .wasm file correctly and gave an error in the Browser. In this case I needed to go back to googleing again and had to fall back to my own coding knowledge to fix most of what ChatGPT gave me.

So the tl;dr is that you might get better results if you break down the task for ChatGPT and don’t ask it to do big tasks in one step. For example I could’ve asked it first to generate a function in C to generate the mandelbrot set, then ask it how to export and compile a C function in WebAssembly, then how to import a WebAssembly module in the browser and then how to call it in JavaScript. That way you might get better individiual results that you can then yourself piece together. However you’ll need good knowledge of the task and technologies at hand, so this will probably not work well in an area that you never touched before.

Advent of Code

This one blew my mind. I had already solved the AOC22 Day 11 problem in TypeScript, but wanted to see what ChatGPT would make out of it.

Your puzzle input for this problem was a list of monkeys that looks like the following:

Monkey 0:
  Starting items: 79, 98
  Operation: new = old * 19
  Test: divisible by 23
    If true: throw to monkey 2
    If false: throw to monkey 3

Monkey 1:
  Starting items: 54, 65, 75, 74
  Operation: new = old + 6
  Test: divisible by 19
    If true: throw to monkey 2
    If false: throw to monkey 0

...

This is what ChatGPT came up with to parse the monkey object:

Prompt: I've got a text with a description of objects that I need to parse into a TypeScript object. Here's what it looks like in raw text form:

Monkey 0:
 Starting items: 79, 98
 Operation: new = old * 19
 Test: divisible by 23
  If true: throw to monkey 2
  If false: throw to monkey 3
class Monkey {
  startingItems: number[];
  operation: string;
  test: {
    divisibleBy: number;
    throwTo: number;
  };

  constructor(startingItems: number[], operation: string, test: { divisibleBy: number, throwTo: number }) {
    this.startingItems = startingItems;
    this.operation = operation;
    this.test = test;
  }
}

function parseText(text: string): Monkey {
  // Split the text into lines
  const lines = text.split('\n');

  // Extract the starting items, operation, and test information from the lines
  const startingItems = lines[1].trim().split(':')[1].trim().split(',').map(Number);
  const operation = lines[2].trim().split(':')[1].trim();
  const testDivisibleBy = Number(lines[3].trim().split('by')[1].trim());
  const throwToTrue = Number(lines[4].trim().split(':')[1].trim().split('monkey')[1].trim());
  const throwToFalse = Number(lines[5].trim().split(':')[1].trim().split('monkey')[1].trim());

  // Create a new Monkey object with the extracted information
  const monkey = new Monkey(startingItems, operation, { divisibleBy: testDivisibleBy, throwTo: throwToTrue });

  // Return the Monkey object
  return monkey;
}

const text = 'Monkey 0:\n  Starting items: 79, 98\n  Operation: new = old * 19\n  Test: divisible by 23\n    If true: throw to monkey 2\n    If false: throw to monkey 3';
const monkey = parseText(text);

After asking it to get the text from a file, it gave me this code:

const fs = require('fs');

function parseTextFromFile(filePath: string): Monkey {
  // Read the text from the file
  const text = fs.readFileSync(filePath, 'utf8');

  // Use the parseText function from the previous example to parse the text and create a Monkey object
  return parseText(text);
}

// Example usage
const monkey = parseTextFromFile('path/to/file.txt');

As you might’ve noticed, the monkey object is actually not being parsed correctly. Currently it only has one “throwTo” property, but we need to save another one for the false case.

Thankfully ChatGPT is pretty intelligent and corrects this issue after nudging it into the right direction:

Prompt: "We are missing a property for the monkey. You need to save which monkey to throw to for both the true and false case
class Monkey {
  startingItems: number[];
  operation: string;
  test: {
    divisibleBy: number;
    throwTo: number;
    throwToFalse: number;
  };

  constructor(startingItems: number[], operation: string, test: { divisibleBy: number, throwTo: number, throwToFalse: number }) {
    this.startingItems = startingItems;
    this.operation = operation;
    this.test = test;
  }
}

function parseText(text: string): Monkey {
  // Split the text into lines
  const lines = text.split('\n');

  // Extract the starting items, operation, and test information from the lines
  const startingItems = lines[1].trim().split(':')[1].trim().split(',').map(Number);
  const operation = lines[2].trim().split(':')[1].trim();
  const testDivisibleBy = Number(lines[3].trim().split('by')[1].trim());
  const throwToTrue = Number(lines[4].trim().split(':')[1].trim().split('monkey')[1].trim());
  const throwToFalse = Number(lines[5].trim().split(':')[1].trim().split('monkey')[1].trim());

  // Create a new Monkey object with the extracted information
  const monkey = new Monkey(startingItems, operation, { divisibleBy: testDivisibleBy, throwTo: throwToTrue, throwToFalse });

  // Return the Monkey object
  return monkey;
}

It even corrected the function that parses the text!

Now this is very impressive, it can parse out puzzle input. But can it actually solve the advent of code problem?

Let’s find out.

After each monkey inspects an item but before it tests your worry level, your relief that the monkey's inspection didn't damage the item causes your worry level to be divided by three and rounded down to the nearest integer.

The monkeys take turns inspecting and throwing items. On a single monkey’s turn, it inspects and throws all of the items it is holding one at a time and in the order listed. Monkey 0 goes first, then monkey 1, and so on until each monkey has had one turn. The process of each monkey taking a single turn is called a round.

When a monkey throws an item to another monkey, the item goes on the end of the recipient monkey’s list. A monkey that starts a round with no items could end up inspecting and throwing many items by the time its turn comes around. If a monkey is holding no items at the start of its turn, its turn ends.

Figure out which monkeys to chase by counting how many items they inspect over 20 rounds.

function countInspections(monkeys: Monkey[]): number[] {
  // Initialize an array to store the counts for each monkey
  const counts = Array(monkeys.length).fill(0);

  // Initialize an array to store the items that each monkey is holding
  const items = Array(monkeys.length).fill([]);

  // Simulate 20 rounds
  for (let round = 0; round < 20; round++) {
    // Loop through the monkeys in order
    for (let i = 0; i < monkeys.length; i++) {
      // Get the current monkey and its items
      const monkey = monkeys[i];
      const monkeyItems = items[i];

      // Loop through the monkey's items
      for (let j = 0; j < monkeyItems.length; j++) {
        // Get the current item
        const item = monkeyItems[j];

        // Increment the count for this monkey
        counts[i]++;

        // Divide the worry level by three and round down to the nearest integer
        let worryLevel = Math.floor(item / 3);

        // Check if the item passes the test
        if (item % monkey.test.divisibleBy === 0) {
          // If the test passes, throw the item to the monkey specified in the "throwTo" property
          items[monkey.test.throwTo].push(worryLevel);
        } else {
          // If the test fails, throw the item to the monkey specified in the "throwToFalse" property
          items[monkey.test.throwToFalse].push(worryLevel);
        }
      }

      // Clear the monkey's items after its turn
      items[i] = [];
    }
  }

  // Return the counts for each monkey
  return counts;
}

const monkeys = [/* Array of Monkey objects */];
const counts = countInspections(monkeys);

Believe it or not, but this is correct! I simulated it and it returned the correct answer.

Let’s try to make it solve the second part of the advent of code problem:

You're worried you might not ever get your items back. So worried, in fact, that your relief that a monkey's inspection didn't damage an item no longer causes your worry level to be divided by three.

Unfortunately, that relief was all that was keeping your worry levels from reaching ridiculous levels. You’ll need to find another way to keep your worry levels manageable.

At this rate, you might be putting up with these monkeys for a very long time - possibly 10000 rounds!

Worry levels are no longer divided by three after each item is inspected; you’ll need to find another way to keep your worry levels manageable.

Sadly, the code it gave me was a lot of nonsense. Its plan was to reduce the worry level by a fixed amount like subtracting 50 of taking off a fixed amount of 10%. I tried to nudge it in the right direction, since I knew that the answer was to find the greatest common denominator of all division tests and modulo % the current item by that to keep the division test correct but the numbers low.

But it wasn’t smart enough to figure this out on its own, even after giving it some hints.

Funnily enough, when I opened a new chat with ChatGPT and specifically asked it to solve an abstract version of this problem, it gave the correct answer:

Prompt: I've got a list of huge numbers in TypeScript. I've another list of number as divisors for those huge numbers. I need my huge numbers to stay smaller because I keep multiplying them. How do I do that while keeping the divisors correct?
ChatGPT: One way to achieve this is to use the modulo operator (%) to reduce the size of the huge numbers while still preserving their relationship to the divisors.

For example, suppose you have a list of huge numbers hugeNumbers and a list of divisors divisors, and you want to reduce the size of the huge numbers while still maintaining their relationship to the divisors. You can do this by iterating through the lists and using the modulo operator to calculate the remainder when each huge number is divided by its corresponding divisor.

Here's an example of how you might do this in TypeScript: ... correct typescript code ...

This will reduce the size of the huge numbers while still preserving their relationship to the divisors. You can then multiply the huge numbers as needed without worrying about them getting too large.

I hope this helps! Let me know if you have any questions or if you'd like further clarification.

So again, you might get stuck with more complicated and bigger tasks. But breaking them into smaller problems or starting a new chat with ChatGPT often can still get you correct results.

Nim

This was a short, but pleasant prompt. I was learning the nim programming language.

All I wanted to do was to split a string and reverse the order. Honestly it’s impressive how bad the nim docs and the google results are, just based on this use case. I couldn’t find anything to help my case for literally an hour.

Frustrated I went to ChatGPT and asked “How do I split a string and reverse the order in nim”. Here’s some of the code I got back:

import strutils

let s = "Hello, World!"
let words = s.split() # split the string into a sequence of words
let reversedWords = rev(words) # reverse the order of the words

# print the reversed words
for word in reversedWords:
    echo word
let s = "Hello, World!"
let words = s.split(",") # split the string on commas
let reversedWords = rev(words) # reverse the order of the words

# print the reversed words
for word in reversedWords:
    echo word

Literally only took one minute. It’s just a much better alternative to scrolling endlessly on StackOverflow and just copy and pasting something.

Bottom Line

The bottom line is that ChatGPT is very useful for a variety of tasks. Research, code snippets, debugging errors, solving math equations, and much more. In the short span of time that I had the fortune to use it, it helped me with actual real world problems, that I was facing as someone who develops software and runs a company.

ChatGPT is one of the most incredible technologies I’ve seen this decade. And the fact that this is only the first version of this conversational AI is kind of scary. I can’t wait for it to become more specialized in many areas so it become your lawyer, doctor, software developer, teacher, cook or architect. I think we only saw a glimpse of what it’s going to be able to do in a couple years further down the line.