Did you know you can build a ChatGPT powered personal tutor in just 3 minutes?
Here’s how 🧵
First, fork the GPT-3.5 template on Replit replit.com/@replit/OpenAI…
Then bring over your OpenAI API key to the Secrets Manager as OPEN_API_KEY.
If you click Run, you’ve already got some interaction going right out of the box, but let’s make it more useful!
The new API uses a messages array to deal with nearly everything. You can set up your starting prompt using the new `system` role and give context and instructions to your bot.
Using a prompt borrowed from @emollick we can set GPT-3 up to think of itself as an adaptive tutor, one that will adjust its teaching style and complexity to our level of understanding - that and multiple choice quizzing too! We’ve just got to customise the prompt.
@emollick Let’s set this array up, use an f-string to replace the learning topic with something user generated. Getting the response from the AI is as simple as sending a one-line command to the API.
@emollick When we get back a message from the AI, we want to assign that to the `assistant` role and add it to the messages array. This means that we have a history of the conversation because…
@emollick Each time we go out to the API, we have to send it the full messages array, so it has all the instructions and the original context. If you don’t maintain your messages array no one else will! It’s not chat if it doesn’t remember what the user said.
@emollick The next step is to ask the user for their response and package this all back up for the API.
Nice and simple, we just need to append the dictionary containing the content back to the messages array before the end of the loop.
@emollick Hit run on your Repl and - boom - you’ve built a universal tutor bot, that can teach anyone about anything and adjust its language accordingly.
Can you imagine how much work this would have been six months ago? Now it’s a 3-minute job!
@emollick Want to try it yourself?
Just use this template and bring your own OpenAI API key.
replit.com/@replit/OpenAI…
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.