jaisun2004 commited on
Commit
92ed364
Β·
verified Β·
1 Parent(s): 01296a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -6
app.py CHANGED
@@ -49,11 +49,10 @@ if uploaded_file:
49
  # Static Session Context Recall
50
  st.info("πŸ” Loading previous session context...")
51
  past_sessions = [
52
- "Session 1: Patient shared ongoing stress due to work deadlines. High anxiety noted.",
53
- "Session 2: Therapist suggested breathing exercises. Patient reported partial improvement.",
54
- "Session 3: Discussion around sleep disturbance and journaling as a method to track mood."
55
  ]
56
- rag_context = "\n".join(past_sessions)
57
 
58
  prompt_input = f"""Previous session context:\n{rag_context}\n\nCurrent session:\n{raw_transcript}"""
59
 
@@ -68,7 +67,29 @@ if uploaded_file:
68
  emotion_scores = emotion_model(raw_transcript)
69
 
70
  # Layout with Tabs
71
- tab1, tab2, tab3 = st.tabs(["πŸ“ Transcript", "πŸ“‹ Summary", "πŸ’¬ Emotions"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  with tab1:
74
  st.subheader("πŸ“ Speaker-Simulated Transcript")
@@ -76,7 +97,17 @@ if uploaded_file:
76
 
77
  with tab2:
78
  st.subheader("πŸ“‹ Contextual Summary")
79
- st.write(summary[0]["summary_text"])
 
 
 
 
 
 
 
 
 
 
80
 
81
  with tab3:
82
  st.subheader("πŸ’¬ Emotional Insights (Overall)")
 
49
  # Static Session Context Recall
50
  st.info("πŸ” Loading previous session context...")
51
  past_sessions = [
52
+ {"date": "2024-04-15", "coping": "walking", "emotion": "anxiety", "notes": "high workload"},
53
+ {"date": "2024-04-22", "coping": "journaling", "emotion": "stress", "notes": "difficulty sleeping"}
 
54
  ]
55
+ rag_context = "\n".join([f"Session {i+1}: {s['coping']}, {s['emotion']}, {s['notes']}" for i, s in enumerate(past_sessions)])
56
 
57
  prompt_input = f"""Previous session context:\n{rag_context}\n\nCurrent session:\n{raw_transcript}"""
58
 
 
67
  emotion_scores = emotion_model(raw_transcript)
68
 
69
  # Layout with Tabs
70
+
71
+ import matplotlib.pyplot as plt
72
+
73
+ # Add trends tab to UI
74
+ tab1, tab2, tab3, tab4 = st.tabs(["πŸ“ Transcript", "πŸ“‹ Summary", "πŸ’¬ Emotions", "πŸ“ˆ Trends"])
75
+
76
+ # Plot session trend (static mock data)
77
+ with tab4:
78
+ st.subheader("πŸ“ˆ Emotional Trends Over Time")
79
+
80
+ session_dates = ["2024-04-01", "2024-04-08", "2024-04-15", "2024-04-22"]
81
+ anxiety_scores = [70, 65, 55, 40]
82
+ sadness_scores = [30, 20, 25, 15]
83
+
84
+ fig, ax = plt.subplots()
85
+ ax.plot(session_dates, anxiety_scores, label='Anxiety', marker='o')
86
+ ax.plot(session_dates, sadness_scores, label='Sadness', marker='o')
87
+ ax.set_title("Emotional Trends Over Time")
88
+ ax.set_ylabel("Score (%)")
89
+ ax.set_xlabel("Session Date")
90
+ ax.legend()
91
+ st.pyplot(fig)
92
+
93
 
94
  with tab1:
95
  st.subheader("πŸ“ Speaker-Simulated Transcript")
 
97
 
98
  with tab2:
99
  st.subheader("πŸ“‹ Contextual Summary")
100
+
101
+ # Insight Tracking based on previous sessions
102
+ insights = []
103
+ if "music" in raw_transcript.lower():
104
+ if any("walking" in s["coping"] for s in past_sessions):
105
+ insights.append("Patient previously mentioned walking as a helpful coping mechanism. This time, music is highlighted instead.")
106
+ if "sleep" in raw_transcript.lower():
107
+ insights.append("Sleep continues to be a recurring theme across sessions.")
108
+ final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
109
+ st.write(final_output)
110
+
111
 
112
  with tab3:
113
  st.subheader("πŸ’¬ Emotional Insights (Overall)")