Build an AI-powered Interactive Quiz with Script Kit
Let's create a new script called TypeScript Quiz.
Open Script Kit and type the filename "TypeScript Quiz", and paste the contents of our ChatGPT script over into the new script.
![demo](https://res.cloudinary.com/johnlindquist/image/upload/v1686016321/transcripts/01-Conversation-taylor-drafts/j6kh
Transcript
00:00 Let's create a new file called TypeScriptQuiz. Hit enter and copy and paste the contents of our chat.gpt script over into here. If we would have run duplicate it would have duplicated a JavaScript file and it would have felt weird to write a TypeScriptQuiz in JavaScript. So we'll rename this to TypeScript Quiz and get rid of the markdown. We can write that later and we'll change the description TypeScript Quiz powered by OpenAI.
00:26 And I'm going to paste in a much longer prompt this time. And to break it down for you this will be an advanced TypeScript test, and this is telling the AI how to behave, and it's also giving us some user commands like start, explain, and skip. So the AI will give us 3 questions with options and then score us following the guidelines that we gave it. Now if I run this script right now it won't start on its own because it's waiting for user input. So I'm going to grab the start command and put it down in the chat components on init.
00:58 Now inside of on init We'll just make this chain call to start the conversation so it can start up without us typing in any text. So we'll go ahead and start up our script. I'm using the command option, semi-colon shortcut from the Script Kit extension to launch this. And it should start chatting right away. I'm pretty sure the answer is 1 for a key value type.
01:21 Oh whoops I guess it's unknown. I'm pretty sure the answer is 2 for append. And I'm pretty sure this will compile. All right looks like I'm terrible at TypeScript. So I got the title of TypeScript Novice.
01:38 So to help myself do a little bit better this time around hopefully I'm going to add in some shortcuts. And shortcuts have names. We'll call this 1 explain. They have a key associated with it and I'm going to use the variable command. So on Mac it's command.
01:55 On Windows and Linux that'll be control and then plus E. And then the bar means where in the action bar it will appear, and we'll say on the right side. And then on press we're going to go ahead and fire off a chain call of explain. Now we're also going to do a similar thing with the other command we set up called skip, and copilot should suggest all of this since it's pretty repetitive and that looks great. Good job copilot.
02:25 So let's try this again. All right question 1. Array is not a primitive type. I'm pretty sure I was correct and I think this is GPT-3 just not giving good questions. And you'll see this isn't perfect.
02:38 It said that the correct answer is null. And that wasn't even an option in here. So I'm going to switch over to... Under chat open AI, I'm going to switch over to model name gpt4. There are still currently some rate limits in place with gpt4 so I avoid using it when testing.
02:57 But now that we can run this let's try it again. Let's try number 3. And you will notice with GPT-4 the text comes in a little slower. That's just the current nature of the GPT-4 API, but it will be able to make things much more difficult and accurate. So let's try explaining this 1 with command-E.
03:23 So let's go ahead and try answer number 1. And now for question 3. I'm just going to go ahead and skip this with command s. It'll give me another question. I'm going to guess number 3, and we'll see how I did.
03:42 I'm a type explorer. I got 2 out of 3 questions right. Now this shows the impact that a model can have when dealing with different scenarios. So we were testing in the default is GPT 3.5, and in 3.5 the advanced TypeScript test just had weird questions and bad options. So GPT 4 is definitely the way to go.
04:02 And importantly GPT-4 acted much more like a quiz machine I described in my prompt, rather than a quiz conversation. So if you're testing with GPT-3.5 you're gonna have way different behaviors than GPT-4. Finally the last thing to add back in is a button to say that we're done, or a shortcut to say that we're done. So let's go ahead and add back in the done shortcut. So we'll say done and we'll say this is command-enter again, bar right.
04:32 And instead of calling out to the chain, the way you say you're done with a prompt is by calling submit. And that will end the current prompt and then send that value back out so that you could grab it as a variable here. So right now this would just be returning an empty string because all of our data is just stored in the memory chat history. So we can just grab it from there instead. So now if we fire this up, and I want to save this question for later, I can hit done and I can keep a record of my quizzes.