Integrating st.selectbox inside st.chat_message

with st.chat_message(“assistant”):
------other code above here exist----
page_options = [‘Email’, ‘Home phone’, ‘Mobile phone’]
option = st.selectbox(‘How would you like to be contacted?:’,page_options)
st.write(option)

     st.session_state.chat_history.append({"role": "user", "content": option})

-I have this code as above. I am trying to incorporate selectbox inside st.chat_message. The problem is it’s not displaying the chosen option. Instead, when I tried to debug by just print(option), I found out that the option is already pre-filled by the first option in the list.
-Is there a way to incorporate selectbox inside the chat or is this impossible at the moment?

Welcome to the community, @Rainer! :hugs:

As far as I know, this feature isn’t available natively yet, but I’ll share your feedback with our dev team for a potential future implementation! :pray:

Thank you,
Charly

Charly thank you so much for the info.

I do have another question if you don’t mind. Somehow related to the previous question I had.

with st.chat_message(“assistant”):
st.write(“Assistant\n\n”)
with st.spinner(“In progress…”):

   if response == str('Good').lower() :
            result = lanchchainFunction.function()
            st.write(result)
            st.session_state.chat_history.append({"role": "assistant", "content": result})
  elif response == str('Bad').lower() :
            result = lanchchainFunction.function()
            st.write(result)
            st.session_state.chat_history.append({"role": "assistant", "content": result})
   if response == str('Revise').lower() :
            result = lanchchainFunction.function()
            st.write(result)
            st.session_state.chat_history.append({"role": "assistant", "content": result})

-I have this streamlit code with several elif. My issue with this is after the third elif, it seems that it is no longer writing the result or calling the function. I don’t know what went wrong with this.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.