jaisun2004 commited on
Commit
970123d
Β·
verified Β·
1 Parent(s): 1cd1007

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -3
app.py CHANGED
@@ -49,7 +49,16 @@ if uploaded_file:
49
  # Summarization
50
  st.info("πŸ“‹ Summarizing conversation...")
51
  summarizer = pipeline("summarization", model="philschmid/bart-large-cnn-samsum")
52
- summary = summarizer(raw_transcript, max_length=256, min_length=60, do_sample=False)
 
 
 
 
 
 
 
 
 
53
 
54
  # Emotion tagging
55
  st.info("🎭 Extracting emotional tones...")
@@ -64,7 +73,17 @@ if uploaded_file:
64
 
65
  with tab2:
66
  st.subheader("πŸ“‹ Contextual Summary")
67
- st.write(summary[0]["summary_text"])
 
 
 
 
 
 
 
 
 
 
68
 
69
  with tab3:
70
  st.subheader("πŸ’¬ Emotional Insights (Overall)")
@@ -153,7 +172,17 @@ with tab1:
153
  with tab2:
154
  st.subheader("πŸ“‹ Contextual Summary")
155
  if 'summary' in locals():
156
- st.write(summary[0]["summary_text"])
 
 
 
 
 
 
 
 
 
 
157
  else:
158
  st.warning("Summary not available.")
159
 
 
49
  # Summarization
50
  st.info("πŸ“‹ Summarizing conversation...")
51
  summarizer = pipeline("summarization", model="philschmid/bart-large-cnn-samsum")
52
+
53
+ # Static Session Context Recall
54
+ st.info("🧠 Referencing prior session context...")
55
+ past_sessions = [
56
+ {"date": "2024-04-15", "coping": "walking", "emotion": "anxiety", "notes": "high workload"},
57
+ {"date": "2024-04-22", "coping": "journaling", "emotion": "stress", "notes": "difficulty sleeping"}
58
+ ]
59
+ rag_context = "\n".join([f"Session {i+1}: {s['coping']}, {s['emotion']}, {s['notes']}" for i, s in enumerate(past_sessions)])
60
+ prompt_input = f"""Previous session context:\n{rag_context}\n\nCurrent session:\n{raw_transcript}"""
61
+ summary = summarizer(prompt_input, max_length=256, min_length=60, do_sample=False)
62
 
63
  # Emotion tagging
64
  st.info("🎭 Extracting emotional tones...")
 
73
 
74
  with tab2:
75
  st.subheader("πŸ“‹ Contextual Summary")
76
+
77
+ # Insight Tracking based on previous sessions
78
+ insights = []
79
+ if "music" in raw_transcript.lower():
80
+ if any("walking" in s["coping"] for s in past_sessions):
81
+ insights.append("Patient previously mentioned walking as a helpful coping mechanism. This time, music is highlighted instead.")
82
+ if "sleep" in raw_transcript.lower():
83
+ insights.append("Sleep continues to be a recurring theme across sessions.")
84
+
85
+ final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
86
+ st.write(final_output)
87
 
88
  with tab3:
89
  st.subheader("πŸ’¬ Emotional Insights (Overall)")
 
172
  with tab2:
173
  st.subheader("πŸ“‹ Contextual Summary")
174
  if 'summary' in locals():
175
+
176
+ # Insight Tracking based on previous sessions
177
+ insights = []
178
+ if "music" in raw_transcript.lower():
179
+ if any("walking" in s["coping"] for s in past_sessions):
180
+ insights.append("Patient previously mentioned walking as a helpful coping mechanism. This time, music is highlighted instead.")
181
+ if "sleep" in raw_transcript.lower():
182
+ insights.append("Sleep continues to be a recurring theme across sessions.")
183
+
184
+ final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
185
+ st.write(final_output)
186
  else:
187
  st.warning("Summary not available.")
188