Hi
I’ve created a chat app using the the streamlit chat elements. I insert sources into the assistant’s response as follows:
# Generate a response from the LLM
response = QA_CHAIN(inputs)
msg = response["text"]
st.session_state.messages.append({"role": "assistant", "content": msg})
with st.chat_message("assistant", avatar="./data/bot_avatar.jpg"):
st.write(msg)
with st.expander("Sources"):
for i, doc in enumerate(docs):
st.write(f"**Source {i+1}:** {doc.metadata['SourceFile']}")
st.write(f"**Date:** {doc.metadata['ModDate']}")
st.write(f"**Content:** {doc.page_content}")
st.write("---")
This is what it looks like
When the user asks a subsequent question, the expander component (sources) end up in the user’s dialogue box, instead of staying the assistant’s dialogue box:
Can I please get some help with this?