Joshua Sundance Bailey commited on
Commit Β·
b4d0284
1
Parent(s): 991fc4e
feedback
Browse files- AI_chatbot/app.py +43 -53
AI_chatbot/app.py
CHANGED
|
@@ -138,66 +138,56 @@ if prompt := st.chat_input(placeholder="Ask me a question!"):
|
|
| 138 |
# Simple feedback section
|
| 139 |
# Optionally add a thumbs up/down button for feedback
|
| 140 |
if st.session_state.get("run_id"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
feedback = streamlit_feedback(
|
| 142 |
-
feedback_type="
|
|
|
|
| 143 |
key=f"feedback_{st.session_state.run_id}",
|
| 144 |
)
|
| 145 |
-
scores = {"π": 1, "π": 0}
|
| 146 |
if feedback:
|
| 147 |
score = scores[feedback["score"]]
|
| 148 |
feedback = client.create_feedback(
|
| 149 |
st.session_state.run_id,
|
| 150 |
-
"
|
| 151 |
score=score,
|
|
|
|
| 152 |
)
|
| 153 |
st.session_state.feedback = {"feedback_id": str(feedback.id), "score": score}
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
#
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
#
|
| 187 |
-
# if st.session_state.get("last_run"):
|
| 188 |
-
# run_url = client.read_run(st.session_state.last_run).url
|
| 189 |
-
# st.sidebar.markdown(f"[Latest Trace: π οΈ]({run_url})")
|
| 190 |
-
# feedback = streamlit_feedback(
|
| 191 |
-
# feedback_type="faces",
|
| 192 |
-
# optional_text_label="[Optional] Please provide an explanation",
|
| 193 |
-
# key=f"feedback_{st.session_state.last_run}",
|
| 194 |
-
# )
|
| 195 |
-
# if feedback:
|
| 196 |
-
# scores = {"π": 1, "π": 0.75, "π": 0.5, "π": 0.25, "π": 0}
|
| 197 |
-
# client.create_feedback(
|
| 198 |
-
# st.session_state.last_run,
|
| 199 |
-
# feedback["type"],
|
| 200 |
-
# score=scores[feedback["score"]],
|
| 201 |
-
# comment=feedback.get("text", None),
|
| 202 |
-
# )
|
| 203 |
-
# st.toast("Feedback recorded!", icon="π")
|
|
|
|
| 138 |
# Simple feedback section
|
| 139 |
# Optionally add a thumbs up/down button for feedback
|
| 140 |
if st.session_state.get("run_id"):
|
| 141 |
+
# feedback = streamlit_feedback(
|
| 142 |
+
# feedback_type="thumbs",
|
| 143 |
+
# key=f"feedback_{st.session_state.run_id}",
|
| 144 |
+
# )
|
| 145 |
+
# scores = {"π": 1, "π": 0}
|
| 146 |
+
scores = {"π": 1, "π": 0.75, "π": 0.5, "π": 0.25, "π": 0}
|
| 147 |
feedback = streamlit_feedback(
|
| 148 |
+
feedback_type="faces",
|
| 149 |
+
optional_text_label="[Optional] Please provide an explanation",
|
| 150 |
key=f"feedback_{st.session_state.run_id}",
|
| 151 |
)
|
|
|
|
| 152 |
if feedback:
|
| 153 |
score = scores[feedback["score"]]
|
| 154 |
feedback = client.create_feedback(
|
| 155 |
st.session_state.run_id,
|
| 156 |
+
feedback["type"],
|
| 157 |
score=score,
|
| 158 |
+
comment=feedback.get("text", None),
|
| 159 |
)
|
| 160 |
st.session_state.feedback = {"feedback_id": str(feedback.id), "score": score}
|
| 161 |
+
st.toast("Feedback recorded!", icon="π")
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
# # Prompt for more information, if feedback was submitted
|
| 165 |
+
# if st.session_state.get("feedback"):
|
| 166 |
+
# feedback = st.session_state.get("feedback")
|
| 167 |
+
# feedback_id = feedback["feedback_id"]
|
| 168 |
+
# score = feedback["score"]
|
| 169 |
+
# if score == 0:
|
| 170 |
+
# if correction := st.text_input(
|
| 171 |
+
# label="What would the correct or preferred response have been?",
|
| 172 |
+
# key=f"correction_{feedback_id}",
|
| 173 |
+
# ):
|
| 174 |
+
# st.session_state.feedback_update = {
|
| 175 |
+
# "correction": {"desired": correction},
|
| 176 |
+
# "feedback_id": feedback_id,
|
| 177 |
+
# }
|
| 178 |
+
# elif score == 1:
|
| 179 |
+
# if comment := st.text_input(
|
| 180 |
+
# label="Anything else you'd like to add about this response?",
|
| 181 |
+
# key=f"comment_{feedback_id}",
|
| 182 |
+
# ):
|
| 183 |
+
# st.session_state.feedback_update = {
|
| 184 |
+
# "comment": comment,
|
| 185 |
+
# "feedback_id": feedback_id,
|
| 186 |
+
# }
|
| 187 |
+
# # Update the feedback if additional information was provided
|
| 188 |
+
# if st.session_state.get("feedback_update"):
|
| 189 |
+
# feedback_update = st.session_state.get("feedback_update")
|
| 190 |
+
# feedback_id = feedback_update.pop("feedback_id")
|
| 191 |
+
# client.update_feedback(feedback_id, **feedback_update)
|
| 192 |
+
# # Clear the comment or correction box
|
| 193 |
+
# _reset_feedback()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|