Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -771,11 +771,20 @@ def new_chat_input(user_input, chat_history, user_state, *args, **kwargs):
|
|
| 771 |
user_state["standardized_data"][f'Initial Relevance Rating'] = int(relevance_rating)
|
| 772 |
|
| 773 |
if int(relevance_rating) < 5:
|
| 774 |
-
#
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 779 |
chat_history[-1] = (user_input, response)
|
| 780 |
return chat_history, user_state, ""
|
| 781 |
|
|
@@ -852,12 +861,15 @@ def new_chat_input(user_input, chat_history, user_state, *args, **kwargs):
|
|
| 852 |
user_state["user_responses"].append({'user_state["stage"]': 'additional_info', 'response': additional_info})
|
| 853 |
# [CONDITION 2] Decide to regenerate vignette based on type
|
| 854 |
vignette_type = user_state["standardized_data"].get("Vignette Type", "custom")
|
| 855 |
-
if vignette_type =
|
| 856 |
-
#
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
|
|
|
| 860 |
)
|
|
|
|
|
|
|
| 861 |
else:
|
| 862 |
# For custom, regenerate with personalization
|
| 863 |
vignette, tone = generate_custom_vignette(
|
|
|
|
| 771 |
user_state["standardized_data"][f'Initial Relevance Rating'] = int(relevance_rating)
|
| 772 |
|
| 773 |
if int(relevance_rating) < 5:
|
| 774 |
+
# Check if the vignette is custom
|
| 775 |
+
vignette_type = user_state["standardized_data"].get("Vignette Type", "custom")
|
| 776 |
+
if vignette_type == "custom":
|
| 777 |
+
# Trigger regeneration only for custom vignettes
|
| 778 |
+
user_state["stage"] = "vignette_regeneration"
|
| 779 |
+
response = "I'm sorry to hear that the scenario wasn't quite fitting. I might have misunderstood some of your responses.\n\nCould you please briefly clarify why the scenario felt off, so we can come up with a better one?"
|
| 780 |
+
else:
|
| 781 |
+
# For generic vignettes, skip regeneration and proceed
|
| 782 |
+
user_state["stage"] = "emotional_relevance"
|
| 783 |
+
response = (
|
| 784 |
+
"Thank you for your feedback. Since this is a general scenario, we will proceed without regeneration.\n\n"
|
| 785 |
+
"How strongly did you feel any emotions while imagining this scenario? (0 = No emotional reaction, 10 = Very strong emotional reaction)"
|
| 786 |
+
)
|
| 787 |
+
|
| 788 |
chat_history[-1] = (user_input, response)
|
| 789 |
return chat_history, user_state, ""
|
| 790 |
|
|
|
|
| 861 |
user_state["user_responses"].append({'user_state["stage"]': 'additional_info', 'response': additional_info})
|
| 862 |
# [CONDITION 2] Decide to regenerate vignette based on type
|
| 863 |
vignette_type = user_state["standardized_data"].get("Vignette Type", "custom")
|
| 864 |
+
if vignette_type != "custom":
|
| 865 |
+
# If vignette is generic, skip regeneration
|
| 866 |
+
user_state["stage"] = "emotional_relevance"
|
| 867 |
+
response = (
|
| 868 |
+
"Thank you for your feedback. Since this is a general scenario, we will proceed without regeneration.\n\n"
|
| 869 |
+
"How strongly did you feel any emotions while imagining this scenario? (0 = No emotional reaction, 10 = Very strong emotional reaction)"
|
| 870 |
)
|
| 871 |
+
chat_history[-1] = (user_input, response)
|
| 872 |
+
return chat_history, user_state, ""
|
| 873 |
else:
|
| 874 |
# For custom, regenerate with personalization
|
| 875 |
vignette, tone = generate_custom_vignette(
|