top of page
Search
  • Dror Margalit

GPTrivia

GPTrivia is an AI-based trivia game where contestants answer questions generated by Chat GPT. This game explores possible applications for implementing generative AI in web development. While GPTrivia utilizes a relatively simple aspect of OpenAI API, this project presents how generative AI can make online interfaces interactive in a sophisticated way.


Play the game here


It has been almost 30 years since a computer beat the chess world champion. It's been over a decade since humans lost a Jeopardy game to a machine. And last year, machine-generated art won an art contest. As machine learning technology improves exponentially, it is time to admit our loss and turn the tables. Long gone are the days when machines try to prove their intelligence and knowledge to humans. Now, humans can demonstrate their knowledge to machines.



Running the application on a remote server

I created a Node.js web application and ran it on a Digital Ocean remote server. Then, I used Express and Socket.io to communicate between the server and the clients. I used the server to define the order of the clients on the screen, send them the questions from the OpenAI API, and keep the score of the players. On the client side, I checked whether the player pressed the correct response and sent it back to the server.


Natural language - programing language writing

OpenAI API uses natural language. The web server uses Javascript. To connect the two, I had to find a way to turn natural language into data and use it. Doing so made me realize that to fully utilize AI, we need to not only use it to write code, but also write code with it. In this example, I gave ChatGPT this prompt:


"generate a four-choice trivia question as a string formatted like this: the question '/' each answer '/' correct response"


While this prompt is not written in any programing language, it was the main component of the program and allowed me to use GPT's response as data. Using it allowed me to have an array of possible responses and populate the response



Find the code here




Special thanks to:

Mary Mark

Austen Li

bottom of page