Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
Β·
6467922
1
Parent(s):
1acff41
put feedback at bottom, nest container, and rework logic
Browse files
app.py
CHANGED
|
@@ -71,26 +71,6 @@ def clear_chat_history():
|
|
| 71 |
|
| 72 |
st.button('Clear Chat', on_click=clear_chat_history)
|
| 73 |
|
| 74 |
-
def feedback():
|
| 75 |
-
# with st.container():
|
| 76 |
-
sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
|
| 77 |
-
rating = st.feedback()
|
| 78 |
-
# feedback = ""
|
| 79 |
-
review = {}
|
| 80 |
-
if rating is not None:
|
| 81 |
-
# st.markdown(f"You selected: {sentiment_mapping[rating]}")
|
| 82 |
-
feedback = st.text_input(f"Please detail your rationale for choosing {sentiment_mapping[rating]}: ", "")
|
| 83 |
-
# rating = st.radio("Rate your experience:", ["π", "Neutral", "π"])
|
| 84 |
-
review = {"rating": {rating}, "feedback": {feedback}}
|
| 85 |
-
|
| 86 |
-
st.markdown(review)
|
| 87 |
-
time.sleep(5)
|
| 88 |
-
# # Save the feedback data
|
| 89 |
-
# if st.button("Submit"):
|
| 90 |
-
# with open("feedback.json", "a") as f:
|
| 91 |
-
# f.write()
|
| 92 |
-
# st.write("Thank you for your feedback!")
|
| 93 |
-
|
| 94 |
# build our chain outside the working body so that its only instantiated once - simply pass it the chat history for chat completion
|
| 95 |
chain = ChainBuilder().build_chain()
|
| 96 |
|
|
@@ -232,6 +212,27 @@ def handle_user_input(user_input):
|
|
| 232 |
|
| 233 |
st.session_state["messages"].append({"role": "assistant", "content": response, "warning": stream_warning, "error": stream_error})
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
main = st.container()
|
| 236 |
with main:
|
| 237 |
history = st.container(height=400)
|
|
|
|
| 71 |
|
| 72 |
st.button('Clear Chat', on_click=clear_chat_history)
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# build our chain outside the working body so that its only instantiated once - simply pass it the chat history for chat completion
|
| 75 |
chain = ChainBuilder().build_chain()
|
| 76 |
|
|
|
|
| 212 |
|
| 213 |
st.session_state["messages"].append({"role": "assistant", "content": response, "warning": stream_warning, "error": stream_error})
|
| 214 |
|
| 215 |
+
def feedback():
|
| 216 |
+
with st.container():
|
| 217 |
+
st.title("Feedback Interface")
|
| 218 |
+
sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
|
| 219 |
+
rating = st.feedback()
|
| 220 |
+
feedback = st.text_input(f"Please detail your rationale for choosing {sentiment_mapping[rating]}: ", "")
|
| 221 |
+
# feedback = ""
|
| 222 |
+
# review = {}
|
| 223 |
+
# if rating is not None:
|
| 224 |
+
# # st.markdown(f"You selected: {sentiment_mapping[rating]}")
|
| 225 |
+
# # rating = st.radio("Rate your experience:", ["π", "Neutral", "π"])
|
| 226 |
+
review = {"rating": {rating}, "feedback": {feedback}}
|
| 227 |
+
|
| 228 |
+
st.markdown(review)
|
| 229 |
+
time.sleep(5)
|
| 230 |
+
# # Save the feedback data
|
| 231 |
+
# if st.button("Submit"):
|
| 232 |
+
# with open("feedback.json", "a") as f:
|
| 233 |
+
# f.write()
|
| 234 |
+
# st.write("Thank you for your feedback!")
|
| 235 |
+
|
| 236 |
main = st.container()
|
| 237 |
with main:
|
| 238 |
history = st.container(height=400)
|