Download app.py from aguyader/stream_it: direct link, hf CLI and curl.
- Browser
- Download file 885 Bytes
-
https://huggingface.co/spaces/aguyader/stream_it/resolve/main/app.py
- Command line
-
hf download hf://spaces/aguyader/stream_it/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aguyader/stream_it/resolve/main/app.py
885 Bytes
| import streamlit as st | |
| import random | |
| # Simple chatbot logic | |
| def chatbot_response(question): | |
| responses = ["Yes", "No", "Maybe", "Absolutely", "Definitely not"] | |
| return random.choice(responses) | |
| # Streamlit App | |
| st.title("Yes/No Question Chatbot") | |
| st.write("Ask me any yes/no question, and I'll give you an answer!") | |
| # Initialize session state for input clearing | |
| if "user_input" not in st.session_state: | |
| st.session_state["user_input"] = "" | |
| # Input box | |
| user_input = st.text_input("Type your question here:", value=st.session_state["user_input"], key="input_box") | |
| if st.button("Ask"): # When the user clicks the "Ask" button | |
| if user_input.strip(): | |
| response = chatbot_response(user_input) | |
| st.write(f"Chatbot: {response}") | |
| else: | |
| st.write("Chatbot: Please ask a valid question!") | |
| st.session_state["user_input"] = "" # Clear the input box | |