Streamlit notes

Using Streamlit’s Chat Elements: the Doctor is in.

We use Streamlit’s chat elements to reproduce the famous 1960s Rogerian-psychologist-bot ELIZA.

Alan Jones
Data Visualization, Data Science and Python
5 min readJul 12, 2023

--

A not entirely satisfactory consultation — a screenshot of the Eliza Bot

If you want to create a chatbot using Streamlit, then you’ll probably want to use Streamlit’s new chat elements st.chat_message and st.chat_input.

While not essential, they are very convenient as they are quite attractive UI elements and nicely distinguish between the user and assistant roles that are used by bots like ChatGPT.

You also may want to utilise Streamlit’s session state features to remember your conversation. This is pretty much essential if you are going to use something like the OpenAI API (see Create a ChatGPT App with Streamlit and Databutton).

Using these elements, we are going to build a chatbot that is based on the famous NLP experiment from the 1960s, ELIZA. And later in the article, you will have a chance to interact with the chatbot live from within this page!

Here’s a very quick introduction to ELIZA.

ELIZA — the Rogerian pyschologist

ELIZA is an early natural language processing computer program created from 1964 to 1966 at MIT by Joseph Weizenbaum.

--

--