Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,7 @@ def render_gauge(score, title):
|
|
| 63 |
fig.update_layout(height=180, margin=dict(l=10, r=10, t=40, b=10), paper_bgcolor="rgba(0,0,0,0)")
|
| 64 |
return fig
|
| 65 |
|
| 66 |
-
# --- 5. π¨ GLOBAL WAR ROOM (12h Window - Fixed
|
| 67 |
st.title("π¨ OMNI-WATCH: GLOBAL WAR ROOM")
|
| 68 |
st.markdown(f"**Emergency Intelligence Feed (12h Window):** `{datetime.now().strftime('%H:%M:%S')} UTC`")
|
| 69 |
|
|
@@ -74,18 +74,22 @@ if 'hot_issues' not in st.session_state:
|
|
| 74 |
with st.spinner("Analyzing high-priority 12h feeds..."):
|
| 75 |
raw_news = fetch_extensive_news("breaking news crisis risk security", limit=35, period="12h")
|
| 76 |
news_context = "\n".join([f"Event: {n['title']}" for n in raw_news])
|
| 77 |
-
|
|
|
|
| 78 |
try:
|
| 79 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": system_msg}, {"role": "user", "content": news_context}], response_format={"type": "json_object"})
|
| 80 |
-
st.session_state.hot_issues = json.loads(res.choices[0].message.content).get('issues', [])[:
|
| 81 |
except: st.session_state.hot_issues = []
|
| 82 |
|
| 83 |
if st.session_state.hot_issues:
|
| 84 |
-
cols = st.columns(
|
| 85 |
for i, issue in enumerate(st.session_state.hot_issues):
|
| 86 |
with cols[i]:
|
| 87 |
with st.container(border=True):
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
| 89 |
st.error(f"**{issue.get('title')}**")
|
| 90 |
for line in issue.get('summary', []): st.caption(f"β’ {line}")
|
| 91 |
st.markdown(f"[π Source]({issue.get('link')})")
|
|
@@ -108,7 +112,6 @@ with tab1:
|
|
| 108 |
status.write(f"β
Gathered {len(all_news)} articles. Synthesizing Narrative...")
|
| 109 |
|
| 110 |
news_summary = "\n".join([n['title'] for n in all_news[:45]])
|
| 111 |
-
# π‘οΈ UPDATED PROMPT: Narrative synthesis without clunky REF tags
|
| 112 |
global_prompt = f"""
|
| 113 |
Analyze '{keyword}' in English based on the provided news headlines.
|
| 114 |
IMPORTANT: The 'executive_summary' MUST be a clean, professional narrative summary of the actual events and risks.
|
|
@@ -156,7 +159,6 @@ with tab2:
|
|
| 156 |
news = fetch_extensive_news(f"{target_geo} social risk", geo=target_geo, limit=40, period="7d")
|
| 157 |
news_titles = "\n".join([n['title'] for n in news])
|
| 158 |
|
| 159 |
-
# π‘οΈ UPDATED PROMPT: Narrative synthesis without clunky REF tags
|
| 160 |
system_prompt = f"""
|
| 161 |
Identify Top 5 Risks for {target_geo} in English.
|
| 162 |
The 'summary' MUST be a clean, 300+ word narrative of the issue.
|
|
|
|
| 63 |
fig.update_layout(height=180, margin=dict(l=10, r=10, t=40, b=10), paper_bgcolor="rgba(0,0,0,0)")
|
| 64 |
return fig
|
| 65 |
|
| 66 |
+
# --- 5. π¨ GLOBAL WAR ROOM (12h Window - Fixed 3 Issues & Numeric Display) ---
|
| 67 |
st.title("π¨ OMNI-WATCH: GLOBAL WAR ROOM")
|
| 68 |
st.markdown(f"**Emergency Intelligence Feed (12h Window):** `{datetime.now().strftime('%H:%M:%S')} UTC`")
|
| 69 |
|
|
|
|
| 74 |
with st.spinner("Analyzing high-priority 12h feeds..."):
|
| 75 |
raw_news = fetch_extensive_news("breaking news crisis risk security", limit=35, period="12h")
|
| 76 |
news_context = "\n".join([f"Event: {n['title']}" for n in raw_news])
|
| 77 |
+
# TOP 3 μ΄μλ§ μΆμΆνλλ‘ μμ
|
| 78 |
+
system_msg = """Identify TOP 3 critical incidents. Return ONLY JSON: {"issues": [{"title": "..", "score": 85, "summary": ["..", "..", ".."], "link": ".."}]}"""
|
| 79 |
try:
|
| 80 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": system_msg}, {"role": "user", "content": news_context}], response_format={"type": "json_object"})
|
| 81 |
+
st.session_state.hot_issues = json.loads(res.choices[0].message.content).get('issues', [])[:3]
|
| 82 |
except: st.session_state.hot_issues = []
|
| 83 |
|
| 84 |
if st.session_state.hot_issues:
|
| 85 |
+
cols = st.columns(3) # TOP 3μ λ§μΆ° μ»¬λΌ 3κ°λ‘ λ³κ²½
|
| 86 |
for i, issue in enumerate(st.session_state.hot_issues):
|
| 87 |
with cols[i]:
|
| 88 |
with st.container(border=True):
|
| 89 |
+
# FIXED: κ²μ΄μ§ μμ νκ³ μ«μλ‘ ν¬κ² νμ
|
| 90 |
+
st.markdown(f"<h1 style='text-align: center; color: #FF4B4B; margin-bottom: 0;'>{issue.get('score', 50)}</h1>", unsafe_allow_html=True)
|
| 91 |
+
st.markdown("<p style='text-align: center; color: gray; font-size: 0.8em; margin-top: 0;'>Severity Index</p>", unsafe_allow_html=True)
|
| 92 |
+
|
| 93 |
st.error(f"**{issue.get('title')}**")
|
| 94 |
for line in issue.get('summary', []): st.caption(f"β’ {line}")
|
| 95 |
st.markdown(f"[π Source]({issue.get('link')})")
|
|
|
|
| 112 |
status.write(f"β
Gathered {len(all_news)} articles. Synthesizing Narrative...")
|
| 113 |
|
| 114 |
news_summary = "\n".join([n['title'] for n in all_news[:45]])
|
|
|
|
| 115 |
global_prompt = f"""
|
| 116 |
Analyze '{keyword}' in English based on the provided news headlines.
|
| 117 |
IMPORTANT: The 'executive_summary' MUST be a clean, professional narrative summary of the actual events and risks.
|
|
|
|
| 159 |
news = fetch_extensive_news(f"{target_geo} social risk", geo=target_geo, limit=40, period="7d")
|
| 160 |
news_titles = "\n".join([n['title'] for n in news])
|
| 161 |
|
|
|
|
| 162 |
system_prompt = f"""
|
| 163 |
Identify Top 5 Risks for {target_geo} in English.
|
| 164 |
The 'summary' MUST be a clean, 300+ word narrative of the issue.
|