Hello Guys i am currently working on a Chatbot for my llm model.
By now i am only trying to write an echo bot and i am hosting it locally.
I want to implement a feedback element with thumbs up and thumbs down and lets the user write explanation to the feedback.
This works so far but now I only want the user to write text to the feedback if the feedback was negative so thumbs down and if the user pressed on thumbs up there should be now text element.
This is my code so far where it shows the explanation label on thumbs up and thumbs down:
import streamlit as st # type: ignore
from streamlit_feedback import streamlit_feedback # type: ignore
st.title("SICBERT - Siemens Support-Bot")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat messages from history on app rerun
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# React to user input
prompt = st.chat_input("What is up?")
if prompt:
# Display user message in chat message container
with st.chat_message("user"):
st.markdown(prompt)
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
response = f"{prompt}"
# Display assistant response in chat message container
with st.chat_message("assistant"):
st.markdown(response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
feedback = streamlit_feedback(
feedback_type="thumbs",
optional_text_label="Please provide an explanation",
)