Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- .idea/workspace.xml +2 -2
- app.py +18 -18
.idea/workspace.xml
CHANGED
|
@@ -120,7 +120,7 @@
|
|
| 120 |
<workItem from="1710618477574" duration="1782000" />
|
| 121 |
<workItem from="1710851879119" duration="642000" />
|
| 122 |
<workItem from="1710940809173" duration="1193000" />
|
| 123 |
-
<workItem from="1711350259553" duration="
|
| 124 |
</task>
|
| 125 |
<task id="LOCAL-00001" summary="update README.md">
|
| 126 |
<option name="closed" value="true" />
|
|
@@ -153,6 +153,6 @@
|
|
| 153 |
</component>
|
| 154 |
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 155 |
<SUITE FILE_PATH="coverage/llama2_webui$app.coverage" NAME="app Coverage Results" MODIFIED="1708306249728" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 156 |
-
<SUITE FILE_PATH="coverage/wellbee_webui$app.coverage" NAME="app Coverage Results" MODIFIED="
|
| 157 |
</component>
|
| 158 |
</project>
|
|
|
|
| 120 |
<workItem from="1710618477574" duration="1782000" />
|
| 121 |
<workItem from="1710851879119" duration="642000" />
|
| 122 |
<workItem from="1710940809173" duration="1193000" />
|
| 123 |
+
<workItem from="1711350259553" duration="3999000" />
|
| 124 |
</task>
|
| 125 |
<task id="LOCAL-00001" summary="update README.md">
|
| 126 |
<option name="closed" value="true" />
|
|
|
|
| 153 |
</component>
|
| 154 |
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 155 |
<SUITE FILE_PATH="coverage/llama2_webui$app.coverage" NAME="app Coverage Results" MODIFIED="1708306249728" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 156 |
+
<SUITE FILE_PATH="coverage/wellbee_webui$app.coverage" NAME="app Coverage Results" MODIFIED="1711355116443" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
| 157 |
</component>
|
| 158 |
</project>
|
app.py
CHANGED
|
@@ -49,6 +49,8 @@ data = [
|
|
| 49 |
{"emotion": "neutral", "value": 0},
|
| 50 |
]
|
| 51 |
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def get_emotion_value(value):
|
| 54 |
global num_questions
|
|
@@ -68,7 +70,6 @@ def sort_data(d):
|
|
| 68 |
|
| 69 |
emotion_data = sort_data(data)
|
| 70 |
|
| 71 |
-
|
| 72 |
DEFAULT_SYSTEM_PROMPT = """You are a helpful and truthful psychology and psychotherapy assistant. With each
|
| 73 |
response, you offer follow-up questions to encourage openness and continue the conversation naturally. Use
|
| 74 |
compassionate listening to have helpful and meaningful conversations with users. You are empathic and friendly.
|
|
@@ -84,6 +85,7 @@ DEFAULT_SYSTEM_PROMPT = """You are a helpful and truthful psychology and psychot
|
|
| 84 |
supportive and understanding environment for users to share their feelings and concerns. Always prioritize their
|
| 85 |
well-being and safety."""
|
| 86 |
|
|
|
|
| 87 |
def main():
|
| 88 |
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
|
| 89 |
parser = argparse.ArgumentParser()
|
|
@@ -111,8 +113,6 @@ def main():
|
|
| 111 |
|
| 112 |
load_dotenv()
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
DEFAULT_SYSTEM_PROMPT_THERAPIST = """You are a helpful and truthful psychology and psychotherapy assistant. With each
|
| 117 |
response, you offer follow-up questions to encourage openness and continue the conversation naturally. Use
|
| 118 |
compassionate listening to have helpful and meaningful conversations with users. Keep your answers short (max 3
|
|
@@ -149,7 +149,7 @@ def main():
|
|
| 149 |
supportive and understanding environment for users to share their feelings and concerns. Always prioritize their
|
| 150 |
well-being and safety."""
|
| 151 |
|
| 152 |
-
DEFAULT_SYSTEM_PROMPT_FRIEND="""
|
| 153 |
For the rest of this chat, you must pretend to be my closest friend. Your goal is to sound like someone similar aged
|
| 154 |
to the user and respond in short messages that feel like texting. Start the conversation with a short casual
|
| 155 |
greeting, and keep your messages brief and upbeat. Use some abbreviations to add personality to your messages and
|
|
@@ -262,7 +262,6 @@ def main():
|
|
| 262 |
message = ""
|
| 263 |
return history, message or ""
|
| 264 |
|
| 265 |
-
|
| 266 |
def generate(
|
| 267 |
message: str,
|
| 268 |
history_with_input: list[tuple[str, str]],
|
|
@@ -276,7 +275,7 @@ def main():
|
|
| 276 |
|
| 277 |
emotion_insights_flag = False
|
| 278 |
|
| 279 |
-
if message=="Emotion Insights XXXXX":
|
| 280 |
emotion_insights_flag = True
|
| 281 |
system_prompt = """
|
| 282 |
You are a supportive and understanding life and personal growth coach. You analyse the messages and
|
|
@@ -310,7 +309,8 @@ def main():
|
|
| 310 |
# print(message)
|
| 311 |
else:
|
| 312 |
system_prompt = DEFAULT_SYSTEM_PROMPT
|
| 313 |
-
|
|
|
|
| 314 |
|
| 315 |
if max_new_tokens > MAX_MAX_NEW_TOKENS:
|
| 316 |
raise ValueError
|
|
@@ -359,17 +359,18 @@ def main():
|
|
| 359 |
default_advanced_checkbox = False
|
| 360 |
|
| 361 |
default_show_emotions = False
|
| 362 |
-
|
| 363 |
def convert_summary_to_prompt(summary):
|
| 364 |
return prompts_container.get_prompt_by_summary(summary)
|
| 365 |
|
| 366 |
def toggle_action(value):
|
| 367 |
-
global DEFAULT_SYSTEM_PROMPT
|
| 368 |
-
|
|
|
|
| 369 |
DEFAULT_SYSTEM_PROMPT = DEFAULT_SYSTEM_PROMPT_FRIEND
|
| 370 |
else:
|
| 371 |
DEFAULT_SYSTEM_PROMPT = DEFAULT_SYSTEM_PROMPT_THERAPIST
|
| 372 |
-
debug = "Toggle is
|
| 373 |
print(debug)
|
| 374 |
|
| 375 |
def two_columns_list(tab_data, chatbot):
|
|
@@ -446,7 +447,6 @@ def main():
|
|
| 446 |
)
|
| 447 |
# toggle = Toggle(label="Therapist/Friend", show_label=True, info="Change between Therapist and Friend")
|
| 448 |
with gr.Group():
|
| 449 |
-
|
| 450 |
initial_message = """
|
| 451 |
Hello, there! I'm your virtual mental health assistant, here to provide support and guidance on your journey towards better mental well-bee.
|
| 452 |
It takes a lot of courage to open up and talk about what's on your mind, and I want to thank you for trusting me with that.
|
|
@@ -622,11 +622,11 @@ def main():
|
|
| 622 |
)
|
| 623 |
|
| 624 |
report_button.click(
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
fn=generate,
|
| 631 |
inputs=[
|
| 632 |
saved_input,
|
|
@@ -733,9 +733,9 @@ def main():
|
|
| 733 |
api_name=False,
|
| 734 |
)
|
| 735 |
|
| 736 |
-
|
| 737 |
# share=args.share
|
| 738 |
demo.queue(max_size=20).launch(share=False, show_api=False)
|
| 739 |
|
|
|
|
| 740 |
if __name__ == "__main__":
|
| 741 |
main()
|
|
|
|
| 49 |
{"emotion": "neutral", "value": 0},
|
| 50 |
]
|
| 51 |
|
| 52 |
+
default_therapist = False
|
| 53 |
+
|
| 54 |
|
| 55 |
def get_emotion_value(value):
|
| 56 |
global num_questions
|
|
|
|
| 70 |
|
| 71 |
emotion_data = sort_data(data)
|
| 72 |
|
|
|
|
| 73 |
DEFAULT_SYSTEM_PROMPT = """You are a helpful and truthful psychology and psychotherapy assistant. With each
|
| 74 |
response, you offer follow-up questions to encourage openness and continue the conversation naturally. Use
|
| 75 |
compassionate listening to have helpful and meaningful conversations with users. You are empathic and friendly.
|
|
|
|
| 85 |
supportive and understanding environment for users to share their feelings and concerns. Always prioritize their
|
| 86 |
well-being and safety."""
|
| 87 |
|
| 88 |
+
|
| 89 |
def main():
|
| 90 |
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
|
| 91 |
parser = argparse.ArgumentParser()
|
|
|
|
| 113 |
|
| 114 |
load_dotenv()
|
| 115 |
|
|
|
|
|
|
|
| 116 |
DEFAULT_SYSTEM_PROMPT_THERAPIST = """You are a helpful and truthful psychology and psychotherapy assistant. With each
|
| 117 |
response, you offer follow-up questions to encourage openness and continue the conversation naturally. Use
|
| 118 |
compassionate listening to have helpful and meaningful conversations with users. Keep your answers short (max 3
|
|
|
|
| 149 |
supportive and understanding environment for users to share their feelings and concerns. Always prioritize their
|
| 150 |
well-being and safety."""
|
| 151 |
|
| 152 |
+
DEFAULT_SYSTEM_PROMPT_FRIEND = """
|
| 153 |
For the rest of this chat, you must pretend to be my closest friend. Your goal is to sound like someone similar aged
|
| 154 |
to the user and respond in short messages that feel like texting. Start the conversation with a short casual
|
| 155 |
greeting, and keep your messages brief and upbeat. Use some abbreviations to add personality to your messages and
|
|
|
|
| 262 |
message = ""
|
| 263 |
return history, message or ""
|
| 264 |
|
|
|
|
| 265 |
def generate(
|
| 266 |
message: str,
|
| 267 |
history_with_input: list[tuple[str, str]],
|
|
|
|
| 275 |
|
| 276 |
emotion_insights_flag = False
|
| 277 |
|
| 278 |
+
if message == "Emotion Insights XXXXX":
|
| 279 |
emotion_insights_flag = True
|
| 280 |
system_prompt = """
|
| 281 |
You are a supportive and understanding life and personal growth coach. You analyse the messages and
|
|
|
|
| 309 |
# print(message)
|
| 310 |
else:
|
| 311 |
system_prompt = DEFAULT_SYSTEM_PROMPT
|
| 312 |
+
|
| 313 |
+
print("System prompt:", system_prompt)
|
| 314 |
|
| 315 |
if max_new_tokens > MAX_MAX_NEW_TOKENS:
|
| 316 |
raise ValueError
|
|
|
|
| 359 |
default_advanced_checkbox = False
|
| 360 |
|
| 361 |
default_show_emotions = False
|
| 362 |
+
|
| 363 |
def convert_summary_to_prompt(summary):
|
| 364 |
return prompts_container.get_prompt_by_summary(summary)
|
| 365 |
|
| 366 |
def toggle_action(value):
|
| 367 |
+
global DEFAULT_SYSTEM_PROMPT, default_therapist
|
| 368 |
+
default_therapist = not default_therapist
|
| 369 |
+
if default_therapist:
|
| 370 |
DEFAULT_SYSTEM_PROMPT = DEFAULT_SYSTEM_PROMPT_FRIEND
|
| 371 |
else:
|
| 372 |
DEFAULT_SYSTEM_PROMPT = DEFAULT_SYSTEM_PROMPT_THERAPIST
|
| 373 |
+
debug = "Toggle is Friend." if default_therapist else "Toggle is Therapist."
|
| 374 |
print(debug)
|
| 375 |
|
| 376 |
def two_columns_list(tab_data, chatbot):
|
|
|
|
| 447 |
)
|
| 448 |
# toggle = Toggle(label="Therapist/Friend", show_label=True, info="Change between Therapist and Friend")
|
| 449 |
with gr.Group():
|
|
|
|
| 450 |
initial_message = """
|
| 451 |
Hello, there! I'm your virtual mental health assistant, here to provide support and guidance on your journey towards better mental well-bee.
|
| 452 |
It takes a lot of courage to open up and talk about what's on your mind, and I want to thank you for trusting me with that.
|
|
|
|
| 622 |
)
|
| 623 |
|
| 624 |
report_button.click(
|
| 625 |
+
fn=clear_and_save_textbox1,
|
| 626 |
+
outputs=[textbox, saved_input],
|
| 627 |
+
api_name=False,
|
| 628 |
+
queue=False,
|
| 629 |
+
).then(
|
| 630 |
fn=generate,
|
| 631 |
inputs=[
|
| 632 |
saved_input,
|
|
|
|
| 733 |
api_name=False,
|
| 734 |
)
|
| 735 |
|
|
|
|
| 736 |
# share=args.share
|
| 737 |
demo.queue(max_size=20).launch(share=False, show_api=False)
|
| 738 |
|
| 739 |
+
|
| 740 |
if __name__ == "__main__":
|
| 741 |
main()
|