Spaces:
Sleeping
Sleeping
TTsamurai
commited on
Commit
·
57ae6d8
1
Parent(s):
88924d0
delete save_feedback
Browse files
app.py
CHANGED
@@ -68,28 +68,28 @@ feedback_file_final_survey = feedback_dir / f"final_survey_{uuid_this_session}_{
|
|
68 |
feedback_folder = feedback_file_interaction.parent
|
69 |
feedback_folder.mkdir(parents=True, exist_ok=True) # Ensure the directory exists
|
70 |
|
71 |
-
scheduler = CommitScheduler(
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
)
|
79 |
|
80 |
|
81 |
# Function to save user feedback
|
82 |
-
def save_feedback(user_id: str, uuid: str, type: str, value, feedback_file) -> None:
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
|
95 |
# Load the required static content from files
|
@@ -281,14 +281,14 @@ def add_user_profile_to_system_instruction(
|
|
281 |
else:
|
282 |
summ, _ = generate_response_debugging(summarization_instruction)
|
283 |
user_preference_elicitation_data["summary_history"] = summ
|
284 |
-
# log_action(user_id, "Prompt", "Preference Elicitation Summarization", summ)
|
285 |
-
save_feedback(
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
)
|
292 |
system_instruction += f"\nUser Profile collected in the previous conversations: {user_preference_elicitation_data['summary_history']}\n"
|
293 |
else:
|
294 |
system_instruction += (
|
@@ -644,39 +644,39 @@ def create_demo():
|
|
644 |
history = huggingface_to_gradio_message(history)
|
645 |
if tab_name is not None:
|
646 |
# Log the user message and response
|
647 |
-
save_feedback(
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
)
|
654 |
-
save_feedback(
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
)
|
661 |
# log_action(user_id, tab_name, "User Message", message)
|
662 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
663 |
# Store the updated history for this tab
|
664 |
tab_data["history"] = history
|
665 |
if user_elicitation:
|
666 |
-
save_feedback(
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
)
|
673 |
-
save_feedback(
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
)
|
680 |
# log_action(user_id, "User_Elicitation", "User Message", message)
|
681 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
682 |
tab_data["history"] = history
|
@@ -726,36 +726,36 @@ def create_demo():
|
|
726 |
history = huggingface_to_gradio_message(history)
|
727 |
if tab_name is not None:
|
728 |
# Log the user message and response
|
729 |
-
save_feedback(
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
)
|
736 |
-
save_feedback(
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
)
|
743 |
tab_data["history"] = history
|
744 |
if user_elicitation:
|
745 |
-
save_feedback(
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
)
|
752 |
-
save_feedback(
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
)
|
759 |
tab_data["history"] = history
|
760 |
return (
|
761 |
tab_data,
|
@@ -803,42 +803,42 @@ def create_demo():
|
|
803 |
outputs_text, history = generate_response_debugging(history_with_user_utterance)
|
804 |
history = huggingface_to_gradio_message(history)
|
805 |
if tab_name is not None:
|
806 |
-
save_feedback(
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
)
|
817 |
-
save_feedback(
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
)
|
824 |
|
825 |
# Update history for this tab
|
826 |
tab_data["history"] = history
|
827 |
if user_elicitation:
|
828 |
-
save_feedback(
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
)
|
835 |
-
save_feedback(
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
)
|
842 |
tab_data["history"] = history
|
843 |
return tab_data, history
|
844 |
|
|
|
68 |
feedback_folder = feedback_file_interaction.parent
|
69 |
feedback_folder.mkdir(parents=True, exist_ok=True) # Ensure the directory exists
|
70 |
|
71 |
+
# scheduler = CommitScheduler(
|
72 |
+
# repo_id=os.getenv("LOGGING_FILE"),
|
73 |
+
# repo_type="dataset",
|
74 |
+
# folder_path=feedback_folder,
|
75 |
+
# path_in_repo="data",
|
76 |
+
# token=os.getenv("HUGGINGFACE_HUB_TOKEN"),
|
77 |
+
# every=1,
|
78 |
+
# )
|
79 |
|
80 |
|
81 |
# Function to save user feedback
|
82 |
+
# def save_feedback(user_id: str, uuid: str, type: str, value, feedback_file) -> None:
|
83 |
+
# """
|
84 |
+
# Append input/outputs and user feedback to a JSON Lines file using a thread lock to avoid concurrent writes from different users.
|
85 |
+
# """
|
86 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
87 |
+
# with scheduler.lock:
|
88 |
+
# with feedback_file.open("a") as f:
|
89 |
+
# f.write(
|
90 |
+
# json.dumps({"user_id": user_id, "uuid": uuid, "timestamp": timestamp, "type": type, "value": value})
|
91 |
+
# )
|
92 |
+
# f.write("\n")
|
93 |
|
94 |
|
95 |
# Load the required static content from files
|
|
|
281 |
else:
|
282 |
summ, _ = generate_response_debugging(summarization_instruction)
|
283 |
user_preference_elicitation_data["summary_history"] = summ
|
284 |
+
# # log_action(user_id, "Prompt", "Preference Elicitation Summarization", summ)
|
285 |
+
# save_feedback(
|
286 |
+
# user_id,
|
287 |
+
# uuid_this_session,
|
288 |
+
# "preference_elicitation_summarization",
|
289 |
+
# {"summarization": summ},
|
290 |
+
# feedback_file_summarization,
|
291 |
+
# )
|
292 |
system_instruction += f"\nUser Profile collected in the previous conversations: {user_preference_elicitation_data['summary_history']}\n"
|
293 |
else:
|
294 |
system_instruction += (
|
|
|
644 |
history = huggingface_to_gradio_message(history)
|
645 |
if tab_name is not None:
|
646 |
# Log the user message and response
|
647 |
+
# save_feedback(
|
648 |
+
# user_id,
|
649 |
+
# uuid_this_session,
|
650 |
+
# "interaction",
|
651 |
+
# {"type": tab_name, "role": "user", "content": message},
|
652 |
+
# feedback_file_interaction,
|
653 |
+
# )
|
654 |
+
# save_feedback(
|
655 |
+
# user_id,
|
656 |
+
# uuid_this_session,
|
657 |
+
# "interaction",
|
658 |
+
# {"type": tab_name, "role": "assistant", "content": outputs_text},
|
659 |
+
# feedback_file_interaction,
|
660 |
+
# )
|
661 |
# log_action(user_id, tab_name, "User Message", message)
|
662 |
# log_action(user_id, tab_name, "Response", outputs_text)
|
663 |
# Store the updated history for this tab
|
664 |
tab_data["history"] = history
|
665 |
if user_elicitation:
|
666 |
+
# save_feedback(
|
667 |
+
# user_id,
|
668 |
+
# uuid_this_session,
|
669 |
+
# "Interaction",
|
670 |
+
# {"type": "user_elicitation", "role": "user", "content": message},
|
671 |
+
# feedback_file_interaction,
|
672 |
+
# )
|
673 |
+
# save_feedback(
|
674 |
+
# user_id,
|
675 |
+
# uuid_this_session,
|
676 |
+
# "Interaction",
|
677 |
+
# {"type": "user_elicitation", "role": "assistant", "content": outputs_text},
|
678 |
+
# feedback_file_interaction,
|
679 |
+
# )
|
680 |
# log_action(user_id, "User_Elicitation", "User Message", message)
|
681 |
# log_action(user_id, "User_Elicitation", "Response", outputs_text)
|
682 |
tab_data["history"] = history
|
|
|
726 |
history = huggingface_to_gradio_message(history)
|
727 |
if tab_name is not None:
|
728 |
# Log the user message and response
|
729 |
+
# save_feedback(
|
730 |
+
# user_id,
|
731 |
+
# uuid_this_session,
|
732 |
+
# "interaction",
|
733 |
+
# {"type": tab_name, "role": "user", "content": first_message},
|
734 |
+
# feedback_file_interaction,
|
735 |
+
# )
|
736 |
+
# save_feedback(
|
737 |
+
# user_id,
|
738 |
+
# uuid_this_session,
|
739 |
+
# "interaction",
|
740 |
+
# {"type": tab_name, "role": "assistant", "content": outputs_text},
|
741 |
+
# feedback_file_interaction,
|
742 |
+
# )
|
743 |
tab_data["history"] = history
|
744 |
if user_elicitation:
|
745 |
+
# save_feedback(
|
746 |
+
# user_id,
|
747 |
+
# uuid_this_session,
|
748 |
+
# "interaction",
|
749 |
+
# {"type": "user_elicitation", "role": "user", "content": first_message},
|
750 |
+
# feedback_file_interaction,
|
751 |
+
# )
|
752 |
+
# save_feedback(
|
753 |
+
# user_id,
|
754 |
+
# uuid_this_session,
|
755 |
+
# "Interaction",
|
756 |
+
# {"type": "user_elicitation", "role": "assistant", "content": outputs_text},
|
757 |
+
# feedback_file_interaction,
|
758 |
+
# )
|
759 |
tab_data["history"] = history
|
760 |
return (
|
761 |
tab_data,
|
|
|
803 |
outputs_text, history = generate_response_debugging(history_with_user_utterance)
|
804 |
history = huggingface_to_gradio_message(history)
|
805 |
if tab_name is not None:
|
806 |
+
# save_feedback(
|
807 |
+
# user_id,
|
808 |
+
# uuid_this_session,
|
809 |
+
# "interaction",
|
810 |
+
# {
|
811 |
+
# "type": tab_name,
|
812 |
+
# "role": "user",
|
813 |
+
# "content": message,
|
814 |
+
# },
|
815 |
+
# feedback_file_interaction,
|
816 |
+
# )
|
817 |
+
# save_feedback(
|
818 |
+
# user_id,
|
819 |
+
# uuid_this_session,
|
820 |
+
# "interaction",
|
821 |
+
# {"type": tab_name, "role": "assistant", "content": outputs_text},
|
822 |
+
# feedback_file_interaction,
|
823 |
+
# )
|
824 |
|
825 |
# Update history for this tab
|
826 |
tab_data["history"] = history
|
827 |
if user_elicitation:
|
828 |
+
# save_feedback(
|
829 |
+
# user_id,
|
830 |
+
# uuid_this_session,
|
831 |
+
# "interaction",
|
832 |
+
# {"type": "user_elicitation", "role": "user", "content": message},
|
833 |
+
# feedback_file_interaction,
|
834 |
+
# )
|
835 |
+
# save_feedback(
|
836 |
+
# user_id,
|
837 |
+
# uuid_this_session,
|
838 |
+
# "interaction",
|
839 |
+
# {"type": "user_elicitation", "role": "assistant", "content": outputs_text},
|
840 |
+
# feedback_file_interaction,
|
841 |
+
# )
|
842 |
tab_data["history"] = history
|
843 |
return tab_data, history
|
844 |
|