Spaces:
Sleeping
Sleeping
Download app.py from ajaykumar0712/Streamlit-Testing: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/ajaykumar0712/Streamlit-Testing/resolve/f5237b341eec0f9a4bb5c1917dfea4de9b66a1ea/app.py
- Command line
-
hf download hf://spaces/ajaykumar0712/Streamlit-Testing@f5237b341eec0f9a4bb5c1917dfea4de9b66a1ea/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ajaykumar0712/Streamlit-Testing/resolve/f5237b341eec0f9a4bb5c1917dfea4de9b66a1ea/app.py
1.26 kB
| import streamlit as st | |
| st.set_page_config(page_title="Hello Chat App", layout="wide") | |
| # --- Sidebar --- | |
| st.sidebar.title("Controls") | |
| theme = st.sidebar.selectbox("Theme (demo)", ["Light", "Dark"]) | |
| st.sidebar.info("This is the sidebar area.") | |
| # --- Main layout panels --- | |
| st.title("Streamlit Chat Input Demo") | |
| left, right = st.columns([2, 1]) | |
| with left: | |
| st.subheader("Chat Panel") | |
| # session state to store messages | |
| if "messages" not in st.session_state: | |
| st.session_state.messages = [ | |
| {"role": "assistant", "content": "Hi! Type anything — I always say hello."} | |
| ] | |
| # display chat history | |
| for msg in st.session_state.messages: | |
| with st.chat_message(msg["role"]): | |
| st.write(msg["content"]) | |
| # chat input | |
| user_text = st.chat_input("Enter free text here...") | |
| if user_text: | |
| st.session_state.messages.append({"role": "user", "content": user_text}) | |
| st.session_state.messages.append({"role": "assistant", "content": "hello"}) | |
| # re-render | |
| st.rerun() | |
| with right: | |
| st.subheader("Info Panel") | |
| st.write("Sidebar selection:", theme) | |
| st.write("Messages so far:", len(st.session_state.messages)) | |
| st.success("Bot response is always: hello ✅") |