ChatGPT is the public face of an AI revolution that is gathering pace, one which promises to transform the worlds of commerce and work as comprehensively as the internal combustion engine did in the 20th century. It’s a thrilling time to be working in tech, but developments are also arriving at such a dizzying pace it can be challenging to stay on top of it all.
At Rant, we know it’s vital to keep up with new technology; staying ahead of the curve means continuously experimenting. One effective way we achieve this is by building small-scale digital prototypes. These prototypes allow us to experiment, refine, and evaluate in a safe, low-risk and controlled sandbox. In this blog post, we’ll delve into our recent experiment with a fun fake news generator using the Open AI API (from the creators of ChatGPT), showcasing both how it was possible and the incredible potential of this API.
Building a Fun Fake News Generator with ChatGPT
Fake news has been a hot topic in recent years, and while it’s a serious issue, we decided to take a whimsical approach to demonstrate the capabilities of the OpenAI API. We set out to create a desktop app that could generate amusing and obviously fake news articles with a single click, in the spirit of the souvenirs that used to allow you to see your name in newsprint.
The valuable byproduct of bringing AI to tacky souvenirs comes with investigating the OpenAI API and discovering the joys and pains of integrating it into a test application. As well as evaluating the API, there is a chance to experiment with prompt engineering – perhaps the hottest (and least understood) tech skill of 2024.
The brief was simple:
- The application will consist of two screens, an input screen and an article screen, following the simple wireframe above.
- The input screen features a text input field to enter the name of the subject of the article, and a generate article button which navigates to the article page.
- The article screen shows the title of the article, the name of the supposed author of the article and the article text returned by the OpenAI API
Our team opted to make a native MacOS app using Swift UI. In addition, they also used the API to generate images to accompany the articles.
We designated one of our team members as a prompt engineer, building a proxy API to handle requests and responses between our app and the OpenAI API. Prompt engineering straddles art and science; in our experience, cajoling effective responses from LLMs requires a lot of trial and error to get the best results. After some experimentation, we arrived at a formulation that produced consistently good results:
Generate a 250 word {tone} newspaper article written by a named author, about a {age} year old {gender} named {name}, that involves {csvSeparatedMentions} and generate a corresponding image caption, and return the title, author, content, and caption as a json object
as a request sent using curl, it looks like this:
curl https://api.openai.com/v1/chat/completions ^
-H "Content-Type: application/json" ^
-H "Authorization: Bearer OPEN API ACCESS KEY HERE" ^
-d "{ \"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"Generate a 250 word dark comedy newspaper article written by a named author, about a 53 year old female named Jordan, that involves onions, Netflix, and a dinosaur costume and generate a corresponding image caption, and return the title, author, content, and caption as a json object\"}], \"temperature\": 0.7 }"
This could easily be deserialized in our language of choice (in this case, C#). We could then take the caption from the response, and use that to generate an accompanying image – again, very simply:
curl https://api.openai.com/v1/images/generations ^
-H "Content-Type: application/json" ^
-H "Authorization: Bearer OPEN API ACCESS KEY HERE" ^
-d "{ \"prompt\": \"Jordan, dressed in her trusty dinosaur costume, offers an unconventional apology to her bemused neighbour Maggie. Photography, 300mm\", \"n\":1, \"size\":\"512x512\" }"
Combined, these two prompts delivered the results we wanted:
It had only taken a few hours to get to this point – packaging it up in a MacOS app was very straightforward, and leaned on our trusty native Apple development skills.
Designing the Fun Fake News Generator
The design team were given the task of bringing the fun concept into reality, creating UI that brings a playful twist to pranking friends.
The UI allows pranksters to create a personalised fake news article and accompanying image using ChatGPT and DALL-E. The prankster starts by entering the victim’s name, sex, and age. Next, they choose the article’s tone and identify three key details to include, making the article as tailored as possible. Once satisfied with the creation, the prankster can easily share the article with their friend. When the friend reads the article and clicks the “read more” button, they are redirected to a page that reveals the prankster’s identity and offers the option to create their own prank.
Here’s a preview of how the finished UI looked:
The Power of ChatGPT API: Endless Possibilities
The ChatGPT API played a pivotal role in bringing our fun fake news generator to life. Its natural language understanding and generation capabilities allowed us to create a playful and engaging experience for users in no time at all.
As the technology continues to develop at a breakneck pace, we are excited to see where it goes from here – this simple integration barely scratches the surface of what is possible. Having proved it is feasible and straightforward to integrate into mobile and web applications, we can’t wait to use it to build something incredible for our partners.
Looking to develop an ios app for iPhone? Tell us about your project here