ChatGPT AI: Guess a Historical Figure (Difficulty: 3)
-
Introduction
In the previous tutorial, 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 precisely 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: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 - First Part of the Prompt: Describe the Scenario
The entire project will involve writing a new prompt, which can be completed in a few steps.For the first step, it is essential to describe the scenario so that ChatGPT knows its role and what it is expected to do.
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 request box of the system request block. Note that when the request is long, it will automatically be folded into multiple lines.
Step 4 - Second part of the Prompt: Describe the Game Rules
With the scenario described 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 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 to be. The student has to guess who you are by asking you questions.
Again, put this into the request input box. Note that you can hold down the SHIFT key and then press the ENTER key, which will start a new line in the request input.
Step 5 - Part 3 of the Prompt: 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 were that historical figure.
Again, add it to the request input box:
Step 6 - Instruct the User
Now our chatbot is ready, we still need to explain to the user how to play the game. We will apply a small trick here: we can tell the user to start asking questions with a new chat message like the one below, as if the historical figure is talking to the user directly:
Step 7 - Test Our Game
Now we have completed the changes. It’s very important to test it thoroughly. You need to think about what users would do to break your game.For example, we should test whether the chatbot adheres 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 encounter any issues during the test, consider how to refine 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 8 - Fix the “First Name” Issue
One possible “hack” you may find is that when the user 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 the first name, you will get an answer like this:
Further Enhancements
Besides historical figures, you can modify the prompt to test the user on other topics. 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.A more challenging task is to make the historical figure more random. Currently, ChatGPT is likely to pick the few famous presidents, making the game extremely easy to play. One way to do this is to generate a random condition on the historical figure: you can write code to pick a random time period (from a list of time periods) and a random country (from a list of countries), then add both of them as additional requirements on the historical figure. For example, suppose the random time period is “A.D. 1400 to A.D. 1500”, and the random country is “China”, then insert this sentence into the prompt: This historical figure you choose must be born between A.D. 1400 and A.D. 1500 in China.
-
info-creaticode
-
This post is deleted!