Comments (5)
The component returns None
if the app is rerun without interacting with the component. I tried your code on my side and everything seems to work correctly to me?
from streamlit-feedback.
Thanks @jeffkayne for looking into it and answering it. In addition to it I am able to get return multiple value when user interacts with thumbs. one another challenge I am finding is , we are unable to return 2 values from the function given in below function and give key value error or even we reply user_response that's look like complete dictionary that doesn't work like key value function and gets key error
def _submit_feedback(user_response, emoji=None):
st.toast(f"Feedback submitted: {user_response}", icon=emoji)
print(user_response)
print(user_response["text"])
return user_response["score"], user_response["text"]
One more query how to identify the which thumbs has been clicked from series of thumbs that is available chat app so we can record the corresponding message to that thumbs reaction. How do we use feedback_key in this .
from streamlit-feedback.
the on_submit=
funcion shouldn't return anything. It is a handler function that can do some action (e.g. save the response to a db) after submitting. To get the user_response, you should simply use the return variable of the component. In your example, that is the test
variable
from streamlit-feedback.
Thanks @jeffkayne for looking into my query, to clarify more detail what I am trying to achieve. I am trying to record multiple data points example , score and text.
Below is the example when I am passing the function
def _submit_feedback(user_response, emoji=None):
st.toast(f"Feedback submitted: {user_response}", icon=emoji)
-
return user_response["score"]
I am able to get the response ๐
this works fine.
- At the same time when we are trying to get the two variable response back
def _submit_feedback(user_response, emoji=None):
st.toast(f"Feedback submitted: {user_response}", icon=emoji)
return user_response["score"], user_response["text"]
and modifying the function
reply1,reply2=streamlit_feedback(
feedback_type="thumbs",
optional_text_label="Please provide extra information",
on_submit=_submit_feedback,
key=feedback_key,
)
reply1,reply2=streamlit_feedback(
TypeError: cannot unpack non-iterable NoneType object
- Also tried another way where send back the complete dictionary but its not allowing to parse it
def _submit_feedback(user_response, emoji=None):
st.toast(f"Feedback submitted: {user_response}", icon=emoji)
return user_response
reply1=streamlit_feedback(
feedback_type="thumbs",
optional_text_label="Please provide extra information",
on_submit=_submit_feedback,
key=feedback_key,
)
print(reply1["score"])
We get the error print(reply1["score"])
TypeError: 'NoneType' object is not subscriptable
As I was looking to record the multiple data points I was facing this challenge as well . I found there might some code changes required in base library or I need to do correct things
from streamlit-feedback.
To store multiple data points, you need to reset your feedback component by using a dynamic key.
Here is some code that stores multiple feedback results in a session state variable:
import streamlit as st
from streamlit_feedback import streamlit_feedback
def handle_feedback(user_response):
st.toast("โ๏ธ Feedback received!")
if "feedback" not in st.session_state:
st.session_state.feedback = []
if "feedback_key" not in st.session_state:
st.session_state.feedback_key = 0
if st.button("Refresh feedback component"):
st.session_state.feedback_key += 1 # overwrite feedback component
result = streamlit_feedback(
feedback_type="thumbs",
align="flex-start",
on_submit=handle_feedback,
key=f"feedback_{st.session_state.feedback_key}",
)
if result:
st.session_state.feedback.append(result)
# view session state
st.session_state.feedback
from streamlit-feedback.
Related Issues (20)
- Changing BG Color of the Streamlit Feedback Component? HOT 1
- Permanent None feedback HOT 2
- How can I set a default value for the thumbs in streamlit-feedback? HOT 1
- component_value in __init__.py is always None HOT 1
- Why do i have to login on Trubrics? HOT 3
- Is there any way to modify the one-line textbox to a multi-line text area? HOT 2
- Streamlit doesn't persist the feedback submission as highlighted thumbs up/thumbs down
- submit feedback on "Enter"
- Streamlit feedback component is not visible on iOS devices. HOT 1
- Thumb buttons aren't visible with streamlit==1.32.2 HOT 1
- Saving user response and prompt into different tables based on the feedback HOT 3
- streamlit_feedback disappears within expander HOT 3
- On submit is not working (it is not calling handle_feedback method) HOT 2
- Who is maintaining version 0.1.3? HOT 2
- The feedback gives "Your app is having trouble loading the streamlit_feedback.streamlit_feedback component." HOT 1
- The feedback gives "Your app is having trouble loading the streamlit_feedback.streamlit_feedback component." inconsistancy HOT 3
- When using submit button ! Streamlit chat bot is not showing success message HOT 1
- file_uploader return 400 after user submit feedback
- ๅ้ฆๆ้ฎๅจๅค็จๆท้ฎ็ญๆถ๏ผๅ้ฎ็ญๆ ๆณๆพ็คบๅ้ฆๆ้ฎๅนถๆฅ้ Bad 'setIn' index
- Release package contains built JavaScript code from previous versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streamlit-feedback.