Hello all!
I’m creating a RAG/ChatBot app and, when response is being generated by model, I would like to display a “loading” message, that I want to be deleted after execution.
I’ve achieved an almost desired result by using st.status(), just like this:
def generate_fake_response(question):
# This function simulates model generating response
with st.status('Generating response...', expanded=False) as status:
time.sleep(5)
fake_answer = 'Response Generated After Model Processing'
status.update(
label='Response Generated!', state='complete', expanded=None
)
status.empty() # I've tried this to delete StatusContainer but without success
for word in fake_answer.split():
yield word + " "
time.sleep(0.05)
# Reacting to user input (question)
if question := st.chat_input(placeholder='Ex: "Sample Question"', max_chars=2000):
with st.chat_message(name='assistant', avatar='🕵️♂️'):
result = st.write_stream(generate_fake_response(question))
This is how my app works:
1- Generating Response
2- After Response is Generated, StatusContainer are still visible:
Any ideas on how to delete this container after function execution??
Thank you in advance!