trubrics / streamlit-feedback

Collect user feedback from within your Streamlit app
MIT License
118 stars 12 forks source link

The feedback gives "Your app is having trouble loading the streamlit_feedback.streamlit_feedback component." inconsistancy #38

Open Bryson14 opened 2 months ago

Bryson14 commented 2 months ago

I've noticed that the feedback item has been giving intermittent errors. Sometimes they work great, but other times they give errors with no apparent changes.

Sometimes some will load and other will flash as the placeholder is loading: image Notive how the top message has loaded the feedback component correctly and the other two have loading placeholder.

then after a few seconds (about 10 seconds), those placeholders will turn into these warning: image

Other times the feedback doesn't show up at all.. This is the code that takes the messages and loads them into the UI. this function is called at the main.py script and called every time that script is reloaded:

def show_chat_messages() -> None:
    """
    Displays the session_state.messages containing the dialog between the user and assistant.
    Assumes that the session has already loaded in messages
    TODO add more metadata to the messages
    """
    for idx, message in enumerate(st.session_state[SessionKeys.MESSAGES.value]):
        with st.chat_message(message.role):
            if message.is_redacted:
                st.write("_content not saved_")
            else:
                st.write(message.content)

        # show feedback for every assistant message
        if message.role == "assistant":
            # send feedback
            if st.session_state[SessionKeys.MESSAGES.value]:
                feedback = streamlit_feedback(
                    feedback_type="faces",
                    optional_text_label="(Optional) Please provide any feedback you have",
                    key=f"feedback-msg-{idx}",
                )
                submit_feedback(
                    feedback,
                    st.session_state.get(SessionKeys.USER_ID.value),
                    st.session_state.get(SessionKeys.CONVERSATION.value),
                    message.message_id,
                )

Am I just overloading the app with too many calls to feedback?

davidsouza-protex commented 2 months ago

We're encountering the same recurring issue. We've tried to diagnose considering potential causes like nginx traffic, Streamlit reloading, or ECS container management, yet we've been unable to determine the root cause. While it functions correctly most of the time, it frequently breaks in production, without error logs, exhibiting the same error message and behavior as described above.

Bryson14 commented 2 months ago

I've noticed that another function we have is doing another stste_session update after the feedback. It seems to be working. It like REACT where the state session updates might be happening in a batch or one after another. But its upto the framework when to actually do the state updates..