important note : you need an open ai key in order to use this project locally
Introduction
As a big fans of video games I wanted to create an interactive experience online using AI to power the responses to the user's input. Using OpenAI's API, the player is guided through a murder mystery in the form on journal entries from the AI detective. The player helps the AI detective figure out what clues to investigate, and once enough evidence has been collected the perpetrator and their motives are revealed!
Challenges we faced
- Crafting a good prompt is hard: This part of the project took the most time and even with hours of thinking and testing (repeatedly running into ChatGPT's hourly message limit) and all the iterations we went through, there's still imperfections with how the language model interprets our prompt, or how it chooses to respond to certain player input.
- The OpenAI API can take a while to respond: On average each response takes ~10 seconds. This can be solved in part by enabling streaming of the response, but due to the hackathon time constraints we thought it would be more important to let it be slightly slow and still be able to finish the project than to attempt streaming of the response and leave it incomplete.
OpenAI Rate Limiting is confusing: Sending one message every ~10 seconds max should not be triggering a rate limit when it allows 3,500 requests and 90,000 tokens per minute, but we frequently ran into the rate limiting error when testing. Our prompt has ~300 tokens according to ChatGPT itself, so we definitely should not be bumping against those restraints.
he core framework used is Next.js, which powers the front-end and the backend functions which relay user input to the OpenAI API's ChatGPT-3.5 model.
The AI model is given the context of a prompt written to provide initial information about the game and the AI's role, and to instruct it how to respond to user input.
Assets were drawn and animated using Aseprite. Audio came from royalty free sites like Pixabay.