Build Your Own ChatGPT-Like App with Streamlit

What is this about?
When GPT-4 was announced on 14 March 2023, I immediately signed up for ChatGPT Plus – a paid tier within the ChatGPT application that offered access to the new model right away. It cost $20 per month and was well worth it in the beginning. However, after a few days, my usage decreased – don't get me wrong: I still use it regularly, I just wasn't sure if I would use it to the extent that it justified the cost. Then, a few days ago, I gained access to GPT-4 via OpenAI's API, and while the new model is much more expensive than its predecessor GPT-3.5, I still think it's probably more economical for me to interact with the API rather than using the ChatGPT app.
But I definitely wanted to keep the chat-like experience when interacting with the model. While there are already quite a few open-source apps out there that provide a slick user experience, I didn't want anything to do with React or similar front-end frameworks – they are great for building amazing web apps, but it's just not what I enjoy doing. Instead, I decided to build my own chat interface with Streamlit, which offers a much more basic UX and has far fewer features – but it was much more fun for me to develop my own UI from scratch (and in Python).