Creating chatbots with Streamlit
I create two chatbots, one using ChatGPT and the OpenAI API and another that is a tribute to Eliza, the psychologist chatbot from the 1960s
Do you remember Eliza, the psychologist chatbot? No, of course, you don't, that was around half a century ago.
Eliza was an experiment in Natural Language Processing that gave the impression of being intelligent by answering questions in a 'consultation' in the style of the psychologist Carl Rogers. Rogers' technique was essentially to reformulate a patient's questions and reflect them back to them. Eliza did the same thing and while its author, Joseph Weizenbaum, was very clear that Eliza was a simulation, users would take the program seriously.
Anyway, I was looking for a simple way of demonstrating Streamlit's new chat elements st.chat_message()
and st.chat_input()
(v 1.24.0) and found a neat Python implementation for Eliza by Wade Brainerd (wadetb on GitHub). You only need to use two files from the repo to construct a fully working Eliza look-a-like.
So I did that and write an article about it on Medium (see below). You can also see a demonstrator in the Streamlit Cloud here.
Using Streamlit’s Chat Elements: the Doctor is in.
The second chatbot also uses Streamlit but is developed in the Databutton environment. If you are unfamiliar with Databutton, it is fundamentally an online Streamlit development environment that incorporates some really useful features such as data storage, job scheduling, built-in deployment (no more messing around with GitHub) and an integrated AI assistant. I wrote an introduction to it here: Databutton: An AI-Powered Streamlit Development Space.
This chatbot uses the OpenAI API to create a ChatGPT bot. I begin with explaining Databutton’s example chabot bot JokeGPT and then go on to develop another one that suggests recipes and menus based on the ingredients that you have in your store cupboard.
Create a ChatGPT App with Streamlit and Databutton
You might also be interested in a couple of programming notes that I published recently:
Session State in Streamlit
Dataclasses in Python
For more stuff like this visit my webpage and, if you haven’t do so already subscribe to this newsletter.