cassandrasestier commited on
Commit
60b5374
Β·
verified Β·
1 Parent(s): 667d4c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -22
app.py CHANGED
@@ -1,7 +1,7 @@
1
  # ================================
2
  # πŸͺž MoodMirror+ β€” Emotion-aware advice
3
  # Tabs: Advice β€’ Emergency numbers β€’ Breathing β€’ Journal
4
- # (No color change, no shredder)
5
  # ================================
6
  import os
7
  import re
@@ -143,20 +143,6 @@ SUGGESTIONS = {
143
  ],
144
  }
145
 
146
- WHY_BY_EMOTION = {
147
- "sadness": "Small sensory and connection cues can ease low mood.",
148
- "fear": "Grounding + longer exhales calm the threat system.",
149
- "anger": "Space + movement lower adrenaline to respond, not react.",
150
- "nervousness": "Slow breathing and micro-actions reduce anxious energy.",
151
- "boredom": "Novelty and small starts re-engage attention.",
152
- "grief": "Rituals and gentle care help carry love and loss.",
153
- "love": "Expressing care strengthens bonds and self-kindness.",
154
- "joy": "Savoring and sharing consolidate positive memories.",
155
- "curiosity": "Small explorations feed learning and perspective.",
156
- "gratitude": "Noticing support shifts attention toward strengths.",
157
- "neutral": "Simple body care keeps your baseline steady.",
158
- }
159
-
160
  # full GoEmotions β†’ bucket
161
  GOEMO_TO_APP = {
162
  "admiration": "gratitude",
@@ -251,7 +237,7 @@ def log_session(country, msg, emotion):
251
  conn.commit()
252
  conn.close()
253
 
254
- # ---- Journal helpers (simple version) ----
255
  def journal_save(title: str, content: str, emotion: str):
256
  title = (title or "").strip()
257
  content = (content or "").strip()
@@ -387,8 +373,8 @@ def pick_advice_from_pool(emotion: str, pool: dict, last_tip: str = ""):
387
  return tip, pool
388
 
389
  def format_reply(emotion: str, tip: str) -> str:
390
- why = WHY_BY_EMOTION.get(emotion, WHY_BY_EMOTION["neutral"])
391
- return f"Try this now:\nβ€’ {tip}\n_(Why it helps: {why})_"
392
 
393
  def crisis_block_en(country):
394
  msg = CRISIS_NUMBERS_EN.get(country, CRISIS_NUMBERS_EN["Other / Not listed"])
@@ -553,9 +539,6 @@ with gr.Blocks(title="πŸͺž MoodMirror+") as demo:
553
  emo_line = f"**Emotion:** {data['emotion'] or 'β€”'} \n**Saved (UTC):** {data['ts']}"
554
  return f"{title_line}\n\n{emo_line}\n\n---\n\n{data['content']}"
555
 
556
- def _clear():
557
- return "", "", "Cleared."
558
-
559
  def _export_all():
560
  path, msg = journal_export_all_zip()
561
  return path, msg
@@ -566,7 +549,6 @@ with gr.Blocks(title="πŸͺž MoodMirror+") as demo:
566
  j_refresh.click(_refresh_entries, inputs=[j_search], outputs=[j_entries, j_table])
567
  j_search.submit(_refresh_entries, inputs=[j_search], outputs=[j_entries, j_table])
568
  j_entries.change(_load_entry, inputs=[j_entries], outputs=[j_view])
569
-
570
  j_export_all_btn.click(_export_all, outputs=[j_export_all_file, j_status])
571
 
572
  if __name__ == "__main__":
 
1
  # ================================
2
  # πŸͺž MoodMirror+ β€” Emotion-aware advice
3
  # Tabs: Advice β€’ Emergency numbers β€’ Breathing β€’ Journal
4
+ #
5
  # ================================
6
  import os
7
  import re
 
143
  ],
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  # full GoEmotions β†’ bucket
147
  GOEMO_TO_APP = {
148
  "admiration": "gratitude",
 
237
  conn.commit()
238
  conn.close()
239
 
240
+ # ---- Journal helpers ----
241
  def journal_save(title: str, content: str, emotion: str):
242
  title = (title or "").strip()
243
  content = (content or "").strip()
 
373
  return tip, pool
374
 
375
  def format_reply(emotion: str, tip: str) -> str:
376
+ # removed "why it helps"
377
+ return f"Try this now:\nβ€’ {tip}"
378
 
379
  def crisis_block_en(country):
380
  msg = CRISIS_NUMBERS_EN.get(country, CRISIS_NUMBERS_EN["Other / Not listed"])
 
539
  emo_line = f"**Emotion:** {data['emotion'] or 'β€”'} \n**Saved (UTC):** {data['ts']}"
540
  return f"{title_line}\n\n{emo_line}\n\n---\n\n{data['content']}"
541
 
 
 
 
542
  def _export_all():
543
  path, msg = journal_export_all_zip()
544
  return path, msg
 
549
  j_refresh.click(_refresh_entries, inputs=[j_search], outputs=[j_entries, j_table])
550
  j_search.submit(_refresh_entries, inputs=[j_search], outputs=[j_entries, j_table])
551
  j_entries.change(_load_entry, inputs=[j_entries], outputs=[j_view])
 
552
  j_export_all_btn.click(_export_all, outputs=[j_export_all_file, j_status])
553
 
554
  if __name__ == "__main__":