x = st.empty() messages = st.container(height=300) if prompt := x.chat_input("Say something"): x.empty() x.chat_input("Say something", disabled=True) time.sleep(2) messages.chat_message("user").write(prompt) messages.chat_message("assistant").write(f"Echo: {prompt}") I’m trying to disable the chat_input when the bot is thinking. Based on the code snippet provided, create a simple streamlit app that takes a chat_input but disables the input when the chat response is thinking for a response.
To upload files, please first save the app
import streamlit as st
import time
x = st.empty()
messages = st.container()
if prompt := x.chat_input("Say something"):
x.empty()
x.chat_input("Say something", disabled=True)
time.sleep(2) # Simulate thinking time
messages.chat_message("user").write(prompt)
messages.chat_message("assistant").write(f"Echo: {prompt}")
x.empty()
x.chat_input("Say something")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?