ChatGPT AI: Guess a Historical Figure (Difficulty: 3)
-
Introduction
In the previous tutorials, you learned how to build a simple chat app with ChatGPT. In this tutorial, we will build a learning game called “Who Am I?”. We will make ChatGPT pretend it is a historical figure, and have the user guess who that person is:
You will find that there is almost no code change, and most of the work is in rewriting the prompt. This may change how you think about “coding”. A new skill is needed if you want to build fun projects using ChatGPT: writing great prompts to get ChatGPT to do exactly what you want. In a way, you just need a new prompt to build a new app!
Step 1 - Create a Starting Project
We will use the project from the previous tutorial as the starting point. If you don’t have it, you can follow that tutorial to build one, or remix the following project:
https://play.creaticode.com/projects/1d57389810eb8ce8b178c684
Step 2 - Clean Up
Before we add a new prompt to the project, let’s clean it up:
- Remove the prompt in the system request. We will work on this later.
- Change the name of ChatGPT from “Einstein” to “AI” or some other name you like.
Step 3 - Add a Comment to Edit Our Prompt
Since we will be working on a fairly long prompt, it is awkward to write it in the system request block directly. Instead, we can use the comment box provided by Scratch:
Now we can compose the entire prompt in the comment, then copy it into the system request block later.
Step 4 - Write the Prompt: Describe the Scenario
For the first step of writing our new prompt, it’s important to describe the scenario, so that ChatGPT “knows” what is expected of it.
For our game, we can describe it like this:
You are a 5th-grade history teacher and the user is a 5th-grade student. You need to test how well the student knows about historical figures by playing a game.
Feel free to adjust the student’s grade level or the role of the chatbot. You need to type or copy the description into the comment box.
Step 5 - Write the Prompt: Describe the Game Rules
With the given prompt above, ChatGPT knows it needs to test a student’s historical knowledge through a game. However, it still doesn’t know the exact rules of the game. We need to give it very clear rules on what it should and should not do, such as:
In this game, you pretend to be a historical figure, but you do not tell the student who you are pretending. The student has to guess who you are by asking you questions.
Again, put this into the comment box:
Step 6 - Write the Prompt: Describe What to Do Next
Now our chatbot is ready to play the game. However, we still need to tell it what to do to get the game started. For example, we can make it wait for the user to start asking the first question:
Now wait for the student's question, then answer the question as if you are that historical figure.
Again, add it to the comment box:
Step 7 - Copy the Prompt
Now we have a complete prompt, copy it from the comment box into the “system request” block. Note that after pasting the long prompt, you won’t see other blocks, but you can press the ENTER key or the TAB key to exit the input box.
Step 8 - Instruct the User
Now our chatbot is ready, we still need to explain to the user how to play the game. We can tell the user to start asking questions with a chat message like this:
Step 9 - Test Our Game
Now we have completed the changes. It’s very important to thoroughly test it. You need to think about what the “worst” users would do to break your game.
For example, we should test if the chatbot would stick to the game rules.
Next, we should test if the chatbot can guide the user properly:
Lastly, test if our chatbot knows when to end the game. Note that even if we have a typo (“Jeferson” instead of “Jefferson”), ChatGPT can still correctly guess what we meant:
If you find any issues during the test, think about how to improve the prompt to prevent them. For example, if you do not want ChatGPT to discuss anything besides the game, you can add this to the prompt:Do not respond to any topic unrelated to this game."
Step 10 - Fix the “First Name” Issue
One issue you may find is that when the user simply asks “what’s your first name”, our AI will give out the answer right away:
To fix this issue, we need to add some additional rules to our prompt. For example, we can append this sentence:Do not give out your first name or last name in any format.
Now if you try to ask for first name, you will get an answer like this:
Creative Ideas
Besides historical figures, you can modify the prompt to test the user on other topics. The choice of topics is almost infinite. Here are some fun examples:
- Guess a planet in our solar system
- Guess an invention or inventor
- Guess an animal or a plant
- Guess a literary character
- Guess a country or a place on Earth
- Guess a chemical element
- Guess a word or a number
You should also continue to find other ways to improve the prompt, and make the game more robust against trick questions. -
info-creaticode
-
hi whats the character