Wikifiction.ai Case Study - Pt 1
Transitioning from idea to implementation: developing the initial functionality to input prompts and publish articles on MediaWiki.
Table of Contents:
Introduction:
?????????????? December 20th, 2023 was a normal day in every sense except for a persistent idea that formed late in the evening. I had recently subscribed to ChatGPT Plus and had been experimenting with how I could use it for productivity, satiating random questions that pop up in my mind, and seeing what responses it gave for silly questions. At some point I also started playing with the built-in DALL-E image generator. One thing led to another and soon I was having it generate images of weird fantasy creatures, and elements from some of my favorite books and video games of the past. Seeing the images made me want to explore the characters more deeply and know their backstory. These thoughts and ideas marinated until they were ready for cooking, and that happened on the evening of December 20th. As I was getting ready for bed it hit me. The idea was simple yet ambitious: to create a wiki site powered by AI, making it easy for anyone to generate and share fictional content.
?????????????? The first thing I did, as is my habit when I get a random urge to create something, was to start thinking of domain names. As luck would have it, my first idea of a domain name was available not only as a .ai Top-Level Domain (TLD) as I wanted but also as a .com TLD. Within a couple of hours, I had purchased not only wikifiction.ai and wikifictionai.com, but also purchased a basic webhosting plan from Hostinger. The following several hours were spent pretending to try to sleep but actually brainstorming all the different directions this idea could go. Around 2 AM I finally took a brief video memo so I had a way to vent the thoughts in hopes of allowing myself to sleep. It worked, I freed myself from the burdens of the unexplored and crashed.
Challenges:
?????????????? The biggest challenge of this phase was the unknown. As a project manager without a background in software development, I faced a steep learning curve. I knew there were a lot of things I didn't know, but I didn't know the full scope of the gap. My first goal was to have a frontend that accepts a prompt and results in an article being published to a MediaWiki page. To accomplish this, I would need a backend, a frontend, and a MediaWiki installation. These components all needed to be connected by some sort of pipeline. To build these pieces, I would need to learn at least one programming language to work with, and along with that I'd need to set up an Integrated Development Environment (IDE). I would also need to figure out how and where to host the various components of the project. Finally, I'd need to figure out how to connect to generative AI via API instead of using web interfaces.
Decisions:
?????????????? In this earliest phase, I had a lot of decisions to make. A few of them were very simple based on my experiences thus far. As for which AI generation models to use, I would stick with ChatGPT and DALL-E since they were the only ones I had experience with. My programming language of choice would be Python since it offers the most versatility for future projects. For hosting anything outside of the MediaWiki installation itself, Microsoft Azure was my first choice just based on my previous experience working with it. That only left a few questions that I needed to research: namely what architecture to use for the backend and frontend, which IDE to use, and how I wanted users to interact with MediaWiki itself. ChatGPT suggested a few different frameworks to simplify the frontend and backend experience. After researching the options, I chose to go with Flask due to numerous tutorials available for both building and deploying solutions. A friend in my shared office space (Hello Jacob Silva from RegulatedCloud !) suggested JetBrains PyCharm as an IDE. I went with it instinctively because, in the past, I've had so many issues setting up IDEs. I was thrilled to take the advice and help when offered. Finally, as far as how users would interact with the MediaWiki site itself, I opted to have all alterations (creating, modifying, and removing articles) done via an automated process. This meant users didn’t need accounts on the MediaWiki site, simplifying things so all users are considered anonymous from MediaWiki's perspective.
Solutions:
?????????????? To tackle these challenges, I started with the classic Hello World app, then moved on to the most basic API calls to talk with ChatGPT. Once I felt comfortable with the basics of Python, I began planning the cloud architecture.
I quickly realized that simply deploying to Azure App Service alone was going to leave me with a URL that ends with ‘azurewebsites.net’ unless I upgraded out of the free tier, which would have cost $13/month. My alternatives were to host everything on a Virtual Private Server (VPS), use iframes to run Azure App Service within my domain name, set up a reverse proxy, or migrate to another service. For a few days I went with iframes, which allowed me to continue developing the backend while looking for a better solution.
领英推荐
At some point I found an open-source tool called Zappa that I could use to deploy Flask directly to Amazon Web Services (AWS) Lambda functions, a serverless service for running scripts with a pay-per-use pricing model. Using Lambda would also allow me to directly use Route 53 to solve my domain name problem by adding a subdomain for the user interface. Armed with this knowledge I set out to migrate the app to AWS. This was quite scary as I had made a lot of progress with Azure, and this meant starting over to rebuild with AWS.
?????????????? With the migration to AWS underway, there was a major issue with the script timing out. Generative API calls are not fast (at least they weren't in December 2023), and my script was constantly hitting a time-out limit while waiting for the response from ChatGPT. I needed to move from synchronous calls to asynchronous calls so that Flask itself wasn’t stuck waiting for too long. To do this I implemented a dashboard, just a simple site that users could sit on while waiting for the API calls to complete. From the user's perspective this would eventually be the same page as the input prompt, but building the polling method for the frontend to know the status from the backend was a bit more complex. My first attempt at this was to set up AWS Simple Notification Service (SNS), a pub/sub messaging service. When a user submitted a creation, an SNS topic was created, the main script (Flask) was subscribed to it so that the scripts responsible for talking to generative AI could update Flask on progress, which then got displayed on the dashboard.
?????????????? Around this time I also started using the most basic functions of AWS Cognito, an authentication and user management service. This would eventually prove to be my biggest challenge so far, but at this stage, to just authenticate a single manually-created user, it worked like a charm. Finally, there was the MediaWiki piece of the puzzle. The backend needed to authenticate a MediaWiki bot account to interface with the MediaWiki site, which then had permissions to upload the newly-generated articles.
?????????????? I managed to celebrate New Years Eve with the first articles being created from a subdomain frontend and programmatically published to MediaWiki. This can be seen at https://wikifiction.ai/wiki/Fred_the_Octopus.
?
Tools Used:
Reflections:
?????????????? This phase of the project was like drinking from a firehose. I went from very little experience in most of these technologies to putting them together cohesively to form a functioning service. The days were long, my implementations were fraught with bugs and spaghetti code, but the fire was lit, and I had something functioning. A key takeaway from this phase was the value of project management and having an organized task backlog when dealing with so many separate components. This was also just the start of seeing how easy it is to let quality slip as you push forward with big wins, winding up with a large backlog of bugs in the process.
Conclusion:
?????????????? By the end of December, I had a functioning prototype that could generate and upload content to a wiki format. This was a huge milestone that was reached just in time to go see some New Year’s Eve fireworks. It also set the stage for the battle of authentication - how to implement user accounts when a service provider refuses you service.
Next Article: wikifiction.ai case study - Part 2: MVP Development