I am new streamlit user. I am trying to create a form where the first field is a dropdown. Based upon what the user selects in this dropdown, I want other dropdowns to show up or get hidden. Till now, I was able to get it working only when I put these dropdowns outside the forms (as per docs, streamlit forms do not support dynamic content ?). How can I do this ?
question_type = st.selectbox(
"Question Type",
["General", "RAG", "Agent"],
index=0,
key="qa_question_type",
help="Select 'Agent' for AIDA interactions, 'RAG' for Retrieval-Augmented Generation questions without involving an agent."
)
kb_value = None
if question_type == "RAG":
if kb_options:
kb_value = st.selectbox("Knowledge Base", kb_options, index=0, key="qa_kb_value", help="Select the knowledge base for RAG questions.")
else:
st.warning("No knowledge bases found. Please add one in 'Add Agents & KB' page.")
agent_value = None
if question_type == "Agent":
if agent_options:
agent_value = st.selectbox("Agent", agent_options, index=0, key="aida", help="Select the appropriate agent.")
else:
st.warning("No agents found. Please add one in 'Add Agents & KB' page.")
with st.form("add_qa_form", clear_on_submit=True):
question = st.text_area("Question", value=st.session_state["question_input"], key="question_input")
groundtruth = st.text_area("Ground Truth Answer", value=st.session_state["groundtruth_input"], key="groundtruth_input")