Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
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 |
-
"
|
53 |
-
"
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)")
|