79533458

Date: 2025-03-25 11:12:58
Score: 0.5
Natty:
Report link

When you click enter after you have typed in the chat name streamlit generally refreshes the page to load the new input of the text but now the edit_chat_name function is not called you should put the text_input outside and then store it in st.session_state and then use that in edit_chat_name if you want to not show the input_box when you are not editing the chat name you can write an if statement with the button and write the text_input inside the if and then have a nested if for that (which would get called if they enter the text_input) and then finally save the text in st.session_state and call the edit_chat_name function, Example code:-

with st.sidebar:
    ....
    ....
    if st.button('Edit Chat Name'):
        if text := st.text_input('New Chat Name'):
            st.session_state.chat_names[st.session_state.current_chat_id] = text
    ....
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: Sanjay Muthu