Spaces:
Sleeping
Sleeping
TTsamurai
commited on
Commit
·
779437a
1
Parent(s):
6306fdf
revise
Browse files
app.py
CHANGED
|
@@ -248,7 +248,13 @@ def add_user_profile_to_system_instruction(
|
|
| 248 |
summ, _ = generate_response_debugging(summarization_instruction)
|
| 249 |
user_preference_elicitation_data["summary_history"] = summ
|
| 250 |
# log_action(user_id, "Prompt", "Preference Elicitation Summarization", summ)
|
| 251 |
-
save_feedback(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
# print(f"Preference Summary:{summ}")
|
| 253 |
system_instruction += f"\nPrevious Conversations with the Customer about the User Profile: {user_preference_elicitation_data['summary_history']}\n"
|
| 254 |
else:
|
|
@@ -671,14 +677,18 @@ def create_demo():
|
|
| 671 |
|
| 672 |
# Log the user message and response
|
| 673 |
save_feedback(
|
| 674 |
-
user_id,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
)
|
| 676 |
save_feedback(
|
| 677 |
user_id,
|
| 678 |
uuid_this_session,
|
| 679 |
"Interaction",
|
| 680 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 681 |
-
feedback_file_interaction
|
| 682 |
)
|
| 683 |
# log_action(user_id, tab_name, "User Message", message)
|
| 684 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
@@ -691,15 +701,14 @@ def create_demo():
|
|
| 691 |
uuid_this_session,
|
| 692 |
"Interaction",
|
| 693 |
{"type": "User_Elicitation", "role": "user", "content": message},
|
| 694 |
-
feedback_file_interaction
|
| 695 |
-
|
| 696 |
)
|
| 697 |
save_feedback(
|
| 698 |
user_id,
|
| 699 |
uuid_this_session,
|
| 700 |
"Interaction",
|
| 701 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 702 |
-
feedback_file_interaction
|
| 703 |
)
|
| 704 |
# log_action(user_id, "User_Elicitation", "User Message", message)
|
| 705 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
|
@@ -752,14 +761,18 @@ def create_demo():
|
|
| 752 |
print(f"Tab: {tab_name}\nHistory: {history}")
|
| 753 |
# Log the user message and response
|
| 754 |
save_feedback(
|
| 755 |
-
user_id,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 756 |
)
|
| 757 |
save_feedback(
|
| 758 |
user_id,
|
| 759 |
uuid_this_session,
|
| 760 |
"Interaction",
|
| 761 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 762 |
-
feedback_file_interaction
|
| 763 |
)
|
| 764 |
# log_action(user_id, tab_name, "User Message", first_message)
|
| 765 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
@@ -772,14 +785,14 @@ def create_demo():
|
|
| 772 |
uuid_this_session,
|
| 773 |
"Interaction",
|
| 774 |
{"type": "User_Elicitation", "role": "user", "content": first_message},
|
| 775 |
-
feedback_file_interaction
|
| 776 |
)
|
| 777 |
save_feedback(
|
| 778 |
user_id,
|
| 779 |
uuid_this_session,
|
| 780 |
"Interaction",
|
| 781 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 782 |
-
feedback_file_interaction
|
| 783 |
)
|
| 784 |
# log_action(user_id, "User_Elicitation", "User Message", first_message)
|
| 785 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
|
@@ -833,14 +846,22 @@ def create_demo():
|
|
| 833 |
history = huggingface_to_gradio_message(history)
|
| 834 |
if tab_name is not None:
|
| 835 |
save_feedback(
|
| 836 |
-
user_id,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 837 |
)
|
| 838 |
save_feedback(
|
| 839 |
user_id,
|
| 840 |
uuid_this_session,
|
| 841 |
"Interaction",
|
| 842 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 843 |
-
feedback_file_interaction
|
| 844 |
)
|
| 845 |
# log_action(user_id, tab_name, "Show More of the Advisor’s Answer", "User continued the conversation")
|
| 846 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
@@ -854,14 +875,14 @@ def create_demo():
|
|
| 854 |
uuid_this_session,
|
| 855 |
"Interaction",
|
| 856 |
{"type": "User_Elicitation", "role": "user", "content": message},
|
| 857 |
-
feedback_file_interaction
|
| 858 |
)
|
| 859 |
save_feedback(
|
| 860 |
user_id,
|
| 861 |
uuid_this_session,
|
| 862 |
"Interaction",
|
| 863 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 864 |
-
feedback_file_interaction
|
| 865 |
)
|
| 866 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
| 867 |
tab_data["history"] = history
|
|
@@ -926,7 +947,7 @@ def create_demo():
|
|
| 926 |
fourth_comp: ranking_fourth_comp,
|
| 927 |
fifth_comp: ranking_fifth_comp,
|
| 928 |
},
|
| 929 |
-
feedback_file_evaluation_and_summarization
|
| 930 |
)
|
| 931 |
# log_action(user_id, "Final_Ranking", first_comp, ranking_first_comp)
|
| 932 |
# log_action(user_id, "Final_Ranking", second_comp, ranking_second_comp)
|
|
|
|
| 248 |
summ, _ = generate_response_debugging(summarization_instruction)
|
| 249 |
user_preference_elicitation_data["summary_history"] = summ
|
| 250 |
# log_action(user_id, "Prompt", "Preference Elicitation Summarization", summ)
|
| 251 |
+
save_feedback(
|
| 252 |
+
user_id,
|
| 253 |
+
uuid_this_session,
|
| 254 |
+
"Preference_Elicitation_Summarization",
|
| 255 |
+
{"summarization": summ},
|
| 256 |
+
feedback_file_evaluation_and_summarization,
|
| 257 |
+
)
|
| 258 |
# print(f"Preference Summary:{summ}")
|
| 259 |
system_instruction += f"\nPrevious Conversations with the Customer about the User Profile: {user_preference_elicitation_data['summary_history']}\n"
|
| 260 |
else:
|
|
|
|
| 677 |
|
| 678 |
# Log the user message and response
|
| 679 |
save_feedback(
|
| 680 |
+
user_id,
|
| 681 |
+
uuid_this_session,
|
| 682 |
+
"Interaction",
|
| 683 |
+
{"type": tab_name, "role": "user", "content": message},
|
| 684 |
+
feedback_file_interaction,
|
| 685 |
)
|
| 686 |
save_feedback(
|
| 687 |
user_id,
|
| 688 |
uuid_this_session,
|
| 689 |
"Interaction",
|
| 690 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 691 |
+
feedback_file_interaction,
|
| 692 |
)
|
| 693 |
# log_action(user_id, tab_name, "User Message", message)
|
| 694 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
|
|
| 701 |
uuid_this_session,
|
| 702 |
"Interaction",
|
| 703 |
{"type": "User_Elicitation", "role": "user", "content": message},
|
| 704 |
+
feedback_file_interaction,
|
|
|
|
| 705 |
)
|
| 706 |
save_feedback(
|
| 707 |
user_id,
|
| 708 |
uuid_this_session,
|
| 709 |
"Interaction",
|
| 710 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 711 |
+
feedback_file_interaction,
|
| 712 |
)
|
| 713 |
# log_action(user_id, "User_Elicitation", "User Message", message)
|
| 714 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
|
|
|
| 761 |
print(f"Tab: {tab_name}\nHistory: {history}")
|
| 762 |
# Log the user message and response
|
| 763 |
save_feedback(
|
| 764 |
+
user_id,
|
| 765 |
+
uuid_this_session,
|
| 766 |
+
"Interaction",
|
| 767 |
+
{"type": tab_name, "role": "user", "content": first_message},
|
| 768 |
+
feedback_file_interaction,
|
| 769 |
)
|
| 770 |
save_feedback(
|
| 771 |
user_id,
|
| 772 |
uuid_this_session,
|
| 773 |
"Interaction",
|
| 774 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 775 |
+
feedback_file_interaction,
|
| 776 |
)
|
| 777 |
# log_action(user_id, tab_name, "User Message", first_message)
|
| 778 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
|
|
| 785 |
uuid_this_session,
|
| 786 |
"Interaction",
|
| 787 |
{"type": "User_Elicitation", "role": "user", "content": first_message},
|
| 788 |
+
feedback_file_interaction,
|
| 789 |
)
|
| 790 |
save_feedback(
|
| 791 |
user_id,
|
| 792 |
uuid_this_session,
|
| 793 |
"Interaction",
|
| 794 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 795 |
+
feedback_file_interaction,
|
| 796 |
)
|
| 797 |
# log_action(user_id, "User_Elicitation", "User Message", first_message)
|
| 798 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
|
|
|
| 846 |
history = huggingface_to_gradio_message(history)
|
| 847 |
if tab_name is not None:
|
| 848 |
save_feedback(
|
| 849 |
+
user_id,
|
| 850 |
+
uuid_this_session,
|
| 851 |
+
"Interaction",
|
| 852 |
+
{
|
| 853 |
+
"type": tab_name,
|
| 854 |
+
"role": "user",
|
| 855 |
+
"content": message,
|
| 856 |
+
},
|
| 857 |
+
feedback_file_interaction,
|
| 858 |
)
|
| 859 |
save_feedback(
|
| 860 |
user_id,
|
| 861 |
uuid_this_session,
|
| 862 |
"Interaction",
|
| 863 |
{"type": tab_name, "role": "assistant", "content": outputs_text},
|
| 864 |
+
feedback_file_interaction,
|
| 865 |
)
|
| 866 |
# log_action(user_id, tab_name, "Show More of the Advisor’s Answer", "User continued the conversation")
|
| 867 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
|
|
|
| 875 |
uuid_this_session,
|
| 876 |
"Interaction",
|
| 877 |
{"type": "User_Elicitation", "role": "user", "content": message},
|
| 878 |
+
feedback_file_interaction,
|
| 879 |
)
|
| 880 |
save_feedback(
|
| 881 |
user_id,
|
| 882 |
uuid_this_session,
|
| 883 |
"Interaction",
|
| 884 |
{"type": "User_Elicitation", "role": "assistant", "content": outputs_text},
|
| 885 |
+
feedback_file_interaction,
|
| 886 |
)
|
| 887 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
| 888 |
tab_data["history"] = history
|
|
|
|
| 947 |
fourth_comp: ranking_fourth_comp,
|
| 948 |
fifth_comp: ranking_fifth_comp,
|
| 949 |
},
|
| 950 |
+
feedback_file_evaluation_and_summarization,
|
| 951 |
)
|
| 952 |
# log_action(user_id, "Final_Ranking", first_comp, ranking_first_comp)
|
| 953 |
# log_action(user_id, "Final_Ranking", second_comp, ranking_second_comp)
|