TTsamurai
commited on
Commit
·
64289c0
1
Parent(s):
fe473a7
change evaluation
Browse files
app.py
CHANGED
@@ -307,7 +307,7 @@ def create_demo():
|
|
307 |
)
|
308 |
reason = gr.Textbox(
|
309 |
scale=1,
|
310 |
-
label="Reason for Your Choice (Explain Your Reasoning & Highlight Useful Parts of Conversation)",
|
311 |
lines=5,
|
312 |
)
|
313 |
with gr.Row():
|
@@ -319,7 +319,13 @@ def create_demo():
|
|
319 |
label="Confidence in Your Decision (1 = Very Low, 7 = Very High)",
|
320 |
show_label=True,
|
321 |
)
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
return {
|
324 |
"comp": comp,
|
325 |
"system_instruction_context": context,
|
@@ -335,6 +341,7 @@ def create_demo():
|
|
335 |
"evaluation_send_button": evaluation_send_button,
|
336 |
"general_instruction": general_instruction,
|
337 |
"round_instruction": round_instruction,
|
|
|
338 |
}
|
339 |
|
340 |
def tab_creation_preference_stage():
|
@@ -460,6 +467,7 @@ def create_demo():
|
|
460 |
likelihood,
|
461 |
confidence,
|
462 |
evaluation_send_button,
|
|
|
463 |
) = (
|
464 |
tabs["comp"],
|
465 |
tabs["system_instruction_context"],
|
@@ -473,6 +481,7 @@ def create_demo():
|
|
473 |
tabs["likelihood"],
|
474 |
tabs["confidence"],
|
475 |
tabs["evaluation_send_button"],
|
|
|
476 |
)
|
477 |
system_instruction = ""
|
478 |
start_conversation.click(
|
@@ -544,7 +553,7 @@ def create_demo():
|
|
544 |
[tab_session, chatbot],
|
545 |
)
|
546 |
evaluation_send_button.click(
|
547 |
-
lambda user_id, comp, tab_session, dropdown, reason, likelihood, confidence, evaluation_send_button: respond_evaluation(
|
548 |
user_id,
|
549 |
tab_session,
|
550 |
{
|
@@ -555,6 +564,7 @@ def create_demo():
|
|
555 |
},
|
556 |
comp,
|
557 |
evaluation_send_button,
|
|
|
558 |
),
|
559 |
[
|
560 |
user_id,
|
@@ -565,8 +575,9 @@ def create_demo():
|
|
565 |
likelihood,
|
566 |
confidence,
|
567 |
evaluation_send_button,
|
|
|
568 |
],
|
569 |
-
[tab_session, dropdown, reason, likelihood, confidence, evaluation_send_button],
|
570 |
)
|
571 |
|
572 |
def click_control_preference_stage(tabs, user_id, user_preference_elicitation_session):
|
@@ -997,14 +1008,22 @@ def create_demo():
|
|
997 |
# log_action(user_id, "Session", "History", history)
|
998 |
return tab_data, history
|
999 |
|
1000 |
-
def respond_evaluation(user_id, tab_data, evals, tab_name, evaluation_send_button):
|
1001 |
|
1002 |
# dropdown, readon_button, multi-evaluator
|
1003 |
print(f"Tab: {tab_name}\nEvaluation: {evals}")
|
1004 |
if evals["selection"] is None or evals["likelihood"] is None or evals["confidence"] is None:
|
1005 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1006 |
<strong>Please make sure that you answer all the questions.</strong>
|
1007 |
-
</div>"""
|
|
|
1008 |
else:
|
1009 |
save_feedback(
|
1010 |
user_id,
|
@@ -1028,6 +1047,9 @@ def create_demo():
|
|
1028 |
evals["likelihood"],
|
1029 |
evals["confidence"],
|
1030 |
evaluation_send_button,
|
|
|
|
|
|
|
1031 |
)
|
1032 |
|
1033 |
def respond_final_ranking(
|
|
|
307 |
)
|
308 |
reason = gr.Textbox(
|
309 |
scale=1,
|
310 |
+
label="Reason for Your Choice (Explain Your Reasoning & Highlight Useful Parts of Conversation)[Optional]",
|
311 |
lines=5,
|
312 |
)
|
313 |
with gr.Row():
|
|
|
319 |
label="Confidence in Your Decision (1 = Very Low, 7 = Very High)",
|
320 |
show_label=True,
|
321 |
)
|
322 |
+
with gr.Row():
|
323 |
+
textbox = gr.HTML(
|
324 |
+
"""<div style="background-color: #f8d7da; color: #721c24; padding: 15px; border: 1px solid #f5c6cb; border-radius: 5px; margin-bottom: 20px;">
|
325 |
+
Make sure to answer all the questions.
|
326 |
+
</div>"""
|
327 |
+
)
|
328 |
+
evaluation_send_button = gr.Button(value="Send: Evaluation")
|
329 |
return {
|
330 |
"comp": comp,
|
331 |
"system_instruction_context": context,
|
|
|
341 |
"evaluation_send_button": evaluation_send_button,
|
342 |
"general_instruction": general_instruction,
|
343 |
"round_instruction": round_instruction,
|
344 |
+
"textbox": textbox,
|
345 |
}
|
346 |
|
347 |
def tab_creation_preference_stage():
|
|
|
467 |
likelihood,
|
468 |
confidence,
|
469 |
evaluation_send_button,
|
470 |
+
textbox,
|
471 |
) = (
|
472 |
tabs["comp"],
|
473 |
tabs["system_instruction_context"],
|
|
|
481 |
tabs["likelihood"],
|
482 |
tabs["confidence"],
|
483 |
tabs["evaluation_send_button"],
|
484 |
+
tabs["textbox"],
|
485 |
)
|
486 |
system_instruction = ""
|
487 |
start_conversation.click(
|
|
|
553 |
[tab_session, chatbot],
|
554 |
)
|
555 |
evaluation_send_button.click(
|
556 |
+
lambda user_id, comp, tab_session, dropdown, reason, likelihood, confidence, evaluation_send_button, textbox: respond_evaluation(
|
557 |
user_id,
|
558 |
tab_session,
|
559 |
{
|
|
|
564 |
},
|
565 |
comp,
|
566 |
evaluation_send_button,
|
567 |
+
textbox,
|
568 |
),
|
569 |
[
|
570 |
user_id,
|
|
|
575 |
likelihood,
|
576 |
confidence,
|
577 |
evaluation_send_button,
|
578 |
+
textbox,
|
579 |
],
|
580 |
+
[tab_session, dropdown, reason, likelihood, confidence, evaluation_send_button, textbox],
|
581 |
)
|
582 |
|
583 |
def click_control_preference_stage(tabs, user_id, user_preference_elicitation_session):
|
|
|
1008 |
# log_action(user_id, "Session", "History", history)
|
1009 |
return tab_data, history
|
1010 |
|
1011 |
+
def respond_evaluation(user_id, tab_data, evals, tab_name, evaluation_send_button, textbox):
|
1012 |
|
1013 |
# dropdown, readon_button, multi-evaluator
|
1014 |
print(f"Tab: {tab_name}\nEvaluation: {evals}")
|
1015 |
if evals["selection"] is None or evals["likelihood"] is None or evals["confidence"] is None:
|
1016 |
+
return (
|
1017 |
+
tab_data,
|
1018 |
+
evals["selection"],
|
1019 |
+
evals["reason"],
|
1020 |
+
evals["likelihood"],
|
1021 |
+
evals["confidence"],
|
1022 |
+
evaluation_send_button,
|
1023 |
+
"""<div style="background-color: #f8d7da; color: #721c24; padding: 15px; border: 1px solid #f5c6cb; border-radius: 5px; margin-bottom: 20px;">
|
1024 |
<strong>Please make sure that you answer all the questions.</strong>
|
1025 |
+
</div>""",
|
1026 |
+
)
|
1027 |
else:
|
1028 |
save_feedback(
|
1029 |
user_id,
|
|
|
1047 |
evals["likelihood"],
|
1048 |
evals["confidence"],
|
1049 |
evaluation_send_button,
|
1050 |
+
"""<div style="background-color: #d4edda; color: #155724; padding: 15px; border: 1px solid #c3e6cb; border-radius: 5px; margin-bottom: 20px;">
|
1051 |
+
<strong>Evaluation received. You may now go to the next tab.</strong>
|
1052 |
+
</div>""",
|
1053 |
)
|
1054 |
|
1055 |
def respond_final_ranking(
|