IJ-Reynolds HF Staff commited on
Commit
4a51ea8
Β·
verified Β·
1 Parent(s): c2159e4

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +15 -10
streamlit_app.py CHANGED
@@ -39,7 +39,8 @@ def apply_retention_policy(df):
39
  # 1. Retention Filtering
40
  leg_df = df[df['type'] == 'Legislation']
41
 
42
- news_types = ['News/Media', 'Federal/Exec Action']
 
43
  news_mask = (df['type'].isin(news_types)) & ((df['event_date'] >= today - pd.Timedelta(days=30)) | df['event_date'].isna())
44
  news_df = df[news_mask]
45
 
@@ -88,7 +89,7 @@ start_background_scheduler()
88
  st.set_page_config(page_title="PolicyPilot Intel", layout="wide")
89
  st.title("AI Policy and News Dashboard - ALPHA Version")
90
 
91
- # Onboarding Text
92
  st.markdown("""
93
  Welcome to the **AI Policy and News Dashboard**, an automated platform tracking technology policy developments, legislative movement, and media coverage.
94
 
@@ -105,11 +106,12 @@ To help you scan the chronological timeline quickly, entries are color-coded:
105
  * 🟒 **Federal / Exec Action** (Agencies, White House)
106
  * πŸ”΅ **News / Media** (Press Coverage)
107
  * 🟠 **Schedule / Hearing** (Committee Meetings, Markups)
 
108
 
109
  To generate a high-level summary of the most recent data entries, click the **"Generate Briefing"** button below.
110
  """)
111
 
112
- # Warning Notes
113
  st.markdown("""
114
  ---
115
  ### Notes for Users
@@ -117,7 +119,7 @@ st.markdown("""
117
  2. **Work in Progress:** This is an alpha version. Improvements in coverage and AI logic will be made regularly.
118
  """)
119
 
120
- # Expanded Architecture Notes
121
  with st.expander("πŸ› οΈ Technical Details & Architecture"):
122
  st.markdown("""
123
  * **AI Engine:** Summaries and keyword extraction are powered by **Meta-Llama-3.1-8B-Instruct**.
@@ -140,6 +142,7 @@ with st.sidebar:
140
  last_sync_str = "Pending First Run"
141
  if df is not None and not df.empty and 'date_collected' in df.columns:
142
  last_sync_dt = pd.to_datetime(df['date_collected']).max()
 
143
  last_sync_str = last_sync_dt.strftime('%b %d, %I:%M %p UTC')
144
  st.info(f"**Auto-Pilot:** Active (12h Cycle)\n\n**Last Sync:** {last_sync_str}")
145
 
@@ -160,7 +163,7 @@ with st.sidebar:
160
  with data_lock: csv_data = active_df.to_csv(index=False).encode('utf-8')
161
  st.download_button(label="Download Historical Archive (CSV)", data=csv_data, file_name=f"policy_pilot_archive_{pd.Timestamp.now().strftime('%Y-%m-%d')}.csv", mime="text/csv", use_container_width=True)
162
 
163
- # --- BRIEFING ---
164
  if active_df is not None and not active_df.empty:
165
  st.subheader("Executive Intel Briefing")
166
  if 'exec_briefing' not in st.session_state:
@@ -173,7 +176,7 @@ if active_df is not None and not active_df.empty:
173
  top_items = active_df.head(10)
174
  context = "\n".join([f"- {row['title']} (Source: {row['source']})" for _, row in top_items.iterrows()])
175
 
176
- # AI Prompt forcing policy prioritization
177
  messages = [
178
  {"role": "system", "content": "You are an objective AI intelligence analyst. Summarize the following data into 3 concise, actionable bullets. Prioritize legislation and federal/executive actions over general news. Cite sources inline."},
179
  {"role": "user", "content": f"Summarize these updates:\n\n{context}"}
@@ -192,13 +195,14 @@ def render_event_cards(display_df):
192
  st.info("No items match these filters.")
193
  return
194
 
195
- # Visual Mapping for rapid scanning
196
  type_icons = {
197
  "Legislation": "🟣",
198
  "Federal/Exec Action": "🟒",
199
  "News/Media": "πŸ”΅",
200
  "Schedule/Hearing": "🟠",
201
- "Hearing/Markup": "🟠"
 
202
  }
203
 
204
  color_map = {
@@ -206,7 +210,8 @@ def render_event_cards(display_df):
206
  "Federal/Exec Action": "green",
207
  "Legislation": "violet",
208
  "Schedule/Hearing": "orange",
209
- "Hearing/Markup": "orange"
 
210
  }
211
 
212
  for _, row in display_df.iterrows():
@@ -221,7 +226,7 @@ def render_event_cards(display_df):
221
  raw_title = str(row['title'])
222
  display_title = raw_title[:75] + ("..." if len(raw_title) > 75 else "")
223
 
224
- # UPDATED: Injected {source} directly into the UI header
225
  with st.expander(f"{icon} {dt_str} | {card_type} | {source} | {display_title}"):
226
  col1, col2 = st.columns([3, 1])
227
  with col1:
 
39
  # 1. Retention Filtering
40
  leg_df = df[df['type'] == 'Legislation']
41
 
42
+ # UPDATED: Added 'Legislative Office Press Release' to the 30-day retention bucket
43
+ news_types = ['News/Media', 'Federal/Exec Action', 'Legislative Office Press Release']
44
  news_mask = (df['type'].isin(news_types)) & ((df['event_date'] >= today - pd.Timedelta(days=30)) | df['event_date'].isna())
45
  news_df = df[news_mask]
46
 
 
89
  st.set_page_config(page_title="PolicyPilot Intel", layout="wide")
90
  st.title("AI Policy and News Dashboard - ALPHA Version")
91
 
92
+ # RESTORED: Original Onboarding Text with new category
93
  st.markdown("""
94
  Welcome to the **AI Policy and News Dashboard**, an automated platform tracking technology policy developments, legislative movement, and media coverage.
95
 
 
106
  * 🟒 **Federal / Exec Action** (Agencies, White House)
107
  * πŸ”΅ **News / Media** (Press Coverage)
108
  * 🟠 **Schedule / Hearing** (Committee Meetings, Markups)
109
+ * πŸ“£ **Legislative Office Press Release** (Lawmaker Announcements)
110
 
111
  To generate a high-level summary of the most recent data entries, click the **"Generate Briefing"** button below.
112
  """)
113
 
114
+ # RESTORED: Warning Notes
115
  st.markdown("""
116
  ---
117
  ### Notes for Users
 
119
  2. **Work in Progress:** This is an alpha version. Improvements in coverage and AI logic will be made regularly.
120
  """)
121
 
122
+ # RESTORED: Expanded Architecture Notes
123
  with st.expander("πŸ› οΈ Technical Details & Architecture"):
124
  st.markdown("""
125
  * **AI Engine:** Summaries and keyword extraction are powered by **Meta-Llama-3.1-8B-Instruct**.
 
142
  last_sync_str = "Pending First Run"
143
  if df is not None and not df.empty and 'date_collected' in df.columns:
144
  last_sync_dt = pd.to_datetime(df['date_collected']).max()
145
+ # UTC indicator maintained for accurate server time context
146
  last_sync_str = last_sync_dt.strftime('%b %d, %I:%M %p UTC')
147
  st.info(f"**Auto-Pilot:** Active (12h Cycle)\n\n**Last Sync:** {last_sync_str}")
148
 
 
163
  with data_lock: csv_data = active_df.to_csv(index=False).encode('utf-8')
164
  st.download_button(label="Download Historical Archive (CSV)", data=csv_data, file_name=f"policy_pilot_archive_{pd.Timestamp.now().strftime('%Y-%m-%d')}.csv", mime="text/csv", use_container_width=True)
165
 
166
+ # --- EXECUTIVE BRIEFING ---
167
  if active_df is not None and not active_df.empty:
168
  st.subheader("Executive Intel Briefing")
169
  if 'exec_briefing' not in st.session_state:
 
176
  top_items = active_df.head(10)
177
  context = "\n".join([f"- {row['title']} (Source: {row['source']})" for _, row in top_items.iterrows()])
178
 
179
+ # UPDATED: Objective Prompt with Legislation/Action Priority
180
  messages = [
181
  {"role": "system", "content": "You are an objective AI intelligence analyst. Summarize the following data into 3 concise, actionable bullets. Prioritize legislation and federal/executive actions over general news. Cite sources inline."},
182
  {"role": "user", "content": f"Summarize these updates:\n\n{context}"}
 
195
  st.info("No items match these filters.")
196
  return
197
 
198
+ # Visual Mapping for rapid scanning (Updated with Megaphone)
199
  type_icons = {
200
  "Legislation": "🟣",
201
  "Federal/Exec Action": "🟒",
202
  "News/Media": "πŸ”΅",
203
  "Schedule/Hearing": "🟠",
204
+ "Hearing/Markup": "🟠",
205
+ "Legislative Office Press Release": "πŸ“£"
206
  }
207
 
208
  color_map = {
 
210
  "Federal/Exec Action": "green",
211
  "Legislation": "violet",
212
  "Schedule/Hearing": "orange",
213
+ "Hearing/Markup": "orange",
214
+ "Legislative Office Press Release": "red"
215
  }
216
 
217
  for _, row in display_df.iterrows():
 
226
  raw_title = str(row['title'])
227
  display_title = raw_title[:75] + ("..." if len(raw_title) > 75 else "")
228
 
229
+ # Injected {source} directly into the UI header
230
  with st.expander(f"{icon} {dt_str} | {card_type} | {source} | {display_title}"):
231
  col1, col2 = st.columns([3, 1])
232
  with col1: