[Streamlit](https://streamlit.io/) is an open-source [[Python]] framework for data scientists and AI/ML engineers to deliver interactive data apps - in only a few lines of code. # Install Install Streamlit and [Watchdog](https://python-watchdog.readthedocs.io/), to observe file changes. ```sh poetry add streamlit watchdog ``` # Snippets Chat text input box. ```python import streamlit as st st.text_input("Your name", key="name") # You can access the value at any point with: st.session_state.name ``` Show/hide chat controls, like seed, etc. ```python import streamlit as st import numpy as np import pandas as pd if st.checkbox('Show dataframe'): chart_data = pd.DataFrame( np.random.randn(20, 3), columns=['a', 'b', 'c']) chart_data ``` Advanced: Show/hide chat controls ```python import streamlit as st # Add a selectbox to the sidebar: add_selectbox = st.sidebar.selectbox( 'How would you like to be contacted?', ('Email', 'Home phone', 'Mobile phone') ) # Add a slider to the sidebar: add_slider = st.sidebar.slider( 'Select a range of values', 0.0, 100.0, (25.0, 75.0) ) ``` Use `st.cache_resource`  to cache global resources like ML models and database connections. # Caching limitations 1. Streamlit will only check for changes within the **current working directory**. If you upgrade a Python library, Streamlit's cache will only notice this if that library is installed inside your working directory. 2. If your function is not **deterministic** (that is, its output depends on random numbers), or if it pulls data from an external time-varying source (for example, a live stock market ticker service) the cached value will be none-the-wiser. 3. Lastly, you should **avoid mutating** the output of a function cached with `st.cache_data` since cached values are stored by reference. # Themes - [Community themes](https://github.com/pgarrett-scripps/StreamlitThemes) - [Streamlit shadcn UI](https://github.com/ObservedObserver/streamlit-shadcn-ui) # Resources - [Streamlit bridges Python and React](https://streamlit-components-tutorial.netlify.app/introduction/streamlit-react-python)