Created
June 13, 2024 07:51
-
-
Save GTimothee/06e661c319bf3604999715a7efc34579 to your computer and use it in GitHub Desktop.
basic feedback collection snippet with streamlit_feedback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
from streamlit_feedback import streamlit_feedback | |
import logging | |
import uuid | |
logging.basicConfig(level=logging.INFO) | |
def reset_key(): | |
st.session_state['ss_key'] = str(uuid.uuid4()) | |
if not 'ss_key' in st.session_state: | |
reset_key() | |
def clicked(): | |
st.toast("clicked!") | |
feedback = streamlit_feedback( | |
feedback_type="thumbs", | |
optional_text_label="[Optional] Please provide an explanation", | |
align="flex-start", | |
key=st.session_state['ss_key'] | |
) | |
if feedback: | |
clicked() | |
if st.button('refresh'): | |
reset_key() | |
st.rerun() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment