Summary
I am using the streamlit_feedback
GitHub link to create thumps up/down buttons for my conversational chat application. However, the spacing between the chat text last line and the thumps up/down icons are quite large.
I contacted the creator of the streamlit_feedback
program and he said: "I’m not familiar with this interface in streamlit. Unfortunately though there is not much more I can do with the spacing inside the component, it looks like the spacing imposed by streamlit. "
My question to the streamlit
community is how can I minimize this spacing effectively? Please let me know if there are any solution.
Steps to reproduce
Code snippet:
I have included the streamlit_feedback
related code only. Please check out the chatbot_thumbs_app()
example here for the complete program.
# Feedback callback
def _submit_feedback(user_response, emoji=None):
"""_summary_
_submit_feedback:
"""
st.toast(f"Feedback submitted: {user_response}", icon=emoji)
return user_response.update({"some metadata": 123})
# Feedback args
feedback_kwargs = {
"feedback_type": "thumbs",
"optional_text_label": "Please provide extra information",
"on_submit": _submit_feedback,
}
# Display chat messages from history on app rerun
for n, message in enumerate(st.session_state.messages):
if message["role"] == "user":
avatar = "images/human.png"
else:
avatar = "images/chatbot.png"
with st.chat_message(message["role"], avatar=avatar):
st.markdown(message["content"])
if message["role"] == "assistant" and n > 1:
feedback_key = f"feedback_{int(n/2)}"
if feedback_key not in st.session_state:
st.session_state[feedback_key] = None
streamlit_feedback(
**feedback_kwargs,
key=feedback_key,
)
Actual behavior:
As you can see, the spacing is quite large (red double-head arrows):
Debug info
- Streamlit version: (get it with
$ streamlit version
) – 1.27.0 - Python version: (get it with
$ python --version
) – 3.10 - Using Conda? PipEnv? PyEnv? Pex? – Conda
- OS version: macOS 13.6
- Browser version: Chrome 117.0