Hi everyone,
Streamlit element disappears from screen while testing chat_messages but messages are not affected, anyone kindly assist. this is my code:
import streamlit as st
#Initiate
if “messages” not in st.session_state:
st.session_state.messages =
#Display
for message in st.session_state.messages:
with st.chat_message(message[“role”]):
st.markdown(message[“content”])
user_message = st.chat_input(“Type your message here…”)
if user_message:
# Display user message in chat message container
with st.chat_message(“user”):
st.markdown(user_message)
# Append user message to session state
st.session_state.messages.append({"role": "user", "content": user_message})
# Display assistant response in chat message container
with st.chat_message("assistant"):
response = user_message
# response = llm.invoke(user_message).content.lower()
placeholder = st.empty()
if "paris" in response:
placeholder.metric(label="Temperature", value="70 °F", delta="1.2 °F")
else:
placeholder.markdown(response)
# Append assistant response to session state
st.session_state.messages.append({"role": "assistant", "content": response})