Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,9 @@ import os
|
|
| 8 |
import plotly.express as px
|
| 9 |
import plotly.graph_objects as go
|
| 10 |
from datetime import datetime, timedelta
|
| 11 |
-
import base64
|
| 12 |
|
| 13 |
-
# --- 1. Page Config ---
|
| 14 |
-
st.set_page_config(page_title="Omni-Watch
|
| 15 |
|
| 16 |
# --- 2. API Key Load ---
|
| 17 |
api_key = os.environ.get("GROQ_API_KEY")
|
|
@@ -20,18 +19,18 @@ if not api_key:
|
|
| 20 |
except: pass
|
| 21 |
|
| 22 |
if not api_key:
|
| 23 |
-
st.error("π GROQ_API_KEY Missing.
|
| 24 |
st.stop()
|
| 25 |
|
| 26 |
client = Groq(api_key=api_key)
|
| 27 |
CURRENT_MODEL = "llama-3.3-70b-versatile"
|
| 28 |
|
| 29 |
-
# --- 3.
|
| 30 |
REGION_MAP = {
|
| 31 |
-
"Asia & Pacific": ["KR", "JP", "CN", "VN", "
|
| 32 |
-
"Europe": ["GB", "FR", "DE", "
|
| 33 |
-
"Americas": ["US", "CA", "BR", "MX"
|
| 34 |
-
"ME & Africa": ["IL", "SA", "AE", "
|
| 35 |
}
|
| 36 |
|
| 37 |
# --- 4. Core Functions ---
|
|
@@ -46,6 +45,7 @@ def fetch_extensive_news(query, geo="US", limit=60, period="7d"):
|
|
| 46 |
return articles
|
| 47 |
|
| 48 |
def render_gauge(score, title):
|
|
|
|
| 49 |
fig = go.Figure(go.Indicator(
|
| 50 |
mode = "gauge+number",
|
| 51 |
value = score,
|
|
@@ -54,27 +54,24 @@ def render_gauge(score, title):
|
|
| 54 |
gauge = {
|
| 55 |
'axis': {'range': [0, 100], 'tickwidth': 1},
|
| 56 |
'bar': {'color': "#FF4B4B"},
|
| 57 |
-
'steps': [
|
| 58 |
-
{'range': [0, 40], 'color': "#e8f5e9"},
|
| 59 |
-
{'range': [40, 75], 'color': "#fff3e0"},
|
| 60 |
-
{'range': [75, 100], 'color': "#ffebee"}],
|
| 61 |
}
|
| 62 |
))
|
| 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 (
|
| 67 |
st.title("π¨ OMNI-WATCH: GLOBAL WAR ROOM")
|
| 68 |
-
st.
|
| 69 |
|
| 70 |
-
if st.button("π Refresh
|
| 71 |
if 'hot_issues' in st.session_state: del st.session_state.hot_issues
|
| 72 |
|
| 73 |
if 'hot_issues' not in st.session_state:
|
| 74 |
-
with st.spinner("
|
| 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"})
|
|
@@ -82,44 +79,44 @@ if 'hot_issues' not in st.session_state:
|
|
| 82 |
except: st.session_state.hot_issues = []
|
| 83 |
|
| 84 |
if st.session_state.hot_issues:
|
| 85 |
-
cols = st.columns(3)
|
| 86 |
for i, issue in enumerate(st.session_state.hot_issues):
|
| 87 |
with cols[i]:
|
| 88 |
with st.container(border=True):
|
| 89 |
-
#
|
| 90 |
-
st.markdown(f"<h1 style='text-align: center; color: #FF4B4B; margin
|
| 91 |
-
st.markdown("<p style='text-align: center; color: gray; font-size: 0.8em;
|
| 92 |
-
|
| 93 |
st.error(f"**{issue.get('title')}**")
|
| 94 |
for line in issue.get('summary', []): st.caption(f"β’ {line}")
|
| 95 |
-
st.markdown(f"[π
|
| 96 |
|
| 97 |
st.divider()
|
| 98 |
|
| 99 |
# --- 6. Strategic Tabs ---
|
| 100 |
-
tab1, tab2, tab3 = st.tabs(["π
|
| 101 |
|
| 102 |
# --- [Tab 1: Strategic Global Scan] ---
|
| 103 |
with tab1:
|
| 104 |
-
st.header("Strategic
|
| 105 |
-
keyword = st.text_input("
|
| 106 |
-
if st.button("
|
| 107 |
-
with st.status("
|
| 108 |
all_news = []
|
| 109 |
for reg in REGION_MAP:
|
| 110 |
for geo in REGION_MAP[reg][:2]:
|
|
|
|
| 111 |
all_news.extend(fetch_extensive_news(keyword, geo=geo, limit=6, period="7d"))
|
| 112 |
-
status.write(f"β
|
| 113 |
|
| 114 |
news_summary = "\n".join([n['title'] for n in all_news[:45]])
|
|
|
|
| 115 |
global_prompt = f"""
|
| 116 |
-
Analyze '{keyword}' in English
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
Use bullet points and clear paragraph breaks for readability.
|
| 120 |
Return ONLY JSON:
|
| 121 |
{{
|
| 122 |
-
"executive_summary": "
|
| 123 |
"risk_landscape": [
|
| 124 |
{{"Component": "Target Demographics", "Findings": "...", "Risk_Level": "High"}},
|
| 125 |
{{"Component": "Policy Violation", "Findings": "...", "Risk_Level": "Medium"}},
|
|
@@ -127,48 +124,64 @@ with tab1:
|
|
| 127 |
{{"Component": "Tactical Mitigation", "Findings": "...", "Risk_Level": "Critical"}}
|
| 128 |
],
|
| 129 |
"platform_intelligence": [
|
| 130 |
-
{{"Platform": "TikTok", "
|
| 131 |
-
{{"Platform": "YouTube", "
|
| 132 |
-
{{"Platform": "Meta", "
|
| 133 |
-
{{"Platform": "X", "
|
| 134 |
],
|
| 135 |
-
"strategic_conclusion": "Final
|
| 136 |
}}
|
| 137 |
"""
|
| 138 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": global_prompt}, {"role": "user", "content": news_summary}], response_format={"type": "json_object"})
|
| 139 |
g_data = json.loads(res.choices[0].message.content)
|
| 140 |
|
| 141 |
with st.container(border=True):
|
| 142 |
-
st.
|
| 143 |
st.markdown(g_data.get('executive_summary').replace(". ", ".\n\n"))
|
| 144 |
|
| 145 |
-
st.
|
| 146 |
st.dataframe(pd.DataFrame(g_data.get('risk_landscape')), hide_index=True, use_container_width=True)
|
| 147 |
|
| 148 |
-
st.
|
| 149 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
# --- [Tab 2: Tactical Forensics] ---
|
| 154 |
with tab2:
|
| 155 |
-
st.header("National
|
| 156 |
-
target_geo = st.text_input("ISO
|
| 157 |
-
if st.button("
|
| 158 |
-
with st.status(f"Scanning
|
|
|
|
| 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 |
-
|
| 165 |
-
DO NOT use 'REF1', 'REF2' tags. Synthesize the information into a readable briefing.
|
| 166 |
Return ONLY JSON:
|
| 167 |
{{
|
| 168 |
"risks": [
|
| 169 |
{{
|
| 170 |
"rank": 1, "title": "..", "score": 90,
|
| 171 |
-
"summary": "Clean narrative analysis
|
| 172 |
"forensic_grid": {{
|
| 173 |
"Policy_Violation": "..",
|
| 174 |
"Vulnerable_Groups": "..",
|
|
@@ -182,28 +195,38 @@ with tab2:
|
|
| 182 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": news_titles}], response_format={"type": "json_object"})
|
| 183 |
report_data = json.loads(res.choices[0].message.content).get('risks', [])
|
| 184 |
|
|
|
|
|
|
|
| 185 |
for i, r in enumerate(report_data):
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 187 |
c1, c2 = st.columns([1, 4])
|
| 188 |
with c1:
|
| 189 |
-
|
|
|
|
| 190 |
with c2:
|
| 191 |
-
st.markdown("**Situational Analysis:**")
|
| 192 |
st.markdown(r.get('summary').replace(". ", ".\n\n"))
|
| 193 |
|
| 194 |
-
st.
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
st.divider()
|
| 199 |
-
st.
|
| 200 |
-
st.dataframe(pd.DataFrame(news)[['
|
| 201 |
|
| 202 |
-
# --- [Tab 3:
|
| 203 |
with tab3:
|
| 204 |
-
st.
|
| 205 |
-
trend_key = st.text_input("Trend
|
| 206 |
-
if st.button("
|
| 207 |
dates = [(datetime.now() - timedelta(days=i)).strftime("%m-%d") for i in range(6, -1, -1)]
|
| 208 |
-
fig = px.area(x=dates, y=[15, 30, 45, 80, 95, 88, 92], title=f"
|
| 209 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
| 8 |
import plotly.express as px
|
| 9 |
import plotly.graph_objects as go
|
| 10 |
from datetime import datetime, timedelta
|
|
|
|
| 11 |
|
| 12 |
+
# --- 1. Page Config (Mobile Optimized) ---
|
| 13 |
+
st.set_page_config(page_title="Omni-Watch Mobile", page_icon="π¨", layout="wide")
|
| 14 |
|
| 15 |
# --- 2. API Key Load ---
|
| 16 |
api_key = os.environ.get("GROQ_API_KEY")
|
|
|
|
| 19 |
except: pass
|
| 20 |
|
| 21 |
if not api_key:
|
| 22 |
+
st.error("π GROQ_API_KEY Missing.")
|
| 23 |
st.stop()
|
| 24 |
|
| 25 |
client = Groq(api_key=api_key)
|
| 26 |
CURRENT_MODEL = "llama-3.3-70b-versatile"
|
| 27 |
|
| 28 |
+
# --- 3. Configuration ---
|
| 29 |
REGION_MAP = {
|
| 30 |
+
"Asia & Pacific": ["KR", "JP", "CN", "VN", "IN", "AU"],
|
| 31 |
+
"Europe": ["GB", "FR", "DE", "UA", "RU"],
|
| 32 |
+
"Americas": ["US", "CA", "BR", "MX"],
|
| 33 |
+
"ME & Africa": ["IL", "SA", "AE", "TR"]
|
| 34 |
}
|
| 35 |
|
| 36 |
# --- 4. Core Functions ---
|
|
|
|
| 45 |
return articles
|
| 46 |
|
| 47 |
def render_gauge(score, title):
|
| 48 |
+
# μμΈ ν(Tab 2)μμλ μ¬μ ν κ²μ΄μ§λ₯Ό μ¬μ©νμ¬ κΉμ΄ μλ μκ°νλ₯Ό μ 곡
|
| 49 |
fig = go.Figure(go.Indicator(
|
| 50 |
mode = "gauge+number",
|
| 51 |
value = score,
|
|
|
|
| 54 |
gauge = {
|
| 55 |
'axis': {'range': [0, 100], 'tickwidth': 1},
|
| 56 |
'bar': {'color': "#FF4B4B"},
|
| 57 |
+
'steps': [{'range': [0, 100], 'color': "#ffebee"}],
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
))
|
| 60 |
fig.update_layout(height=180, margin=dict(l=10, r=10, t=40, b=10), paper_bgcolor="rgba(0,0,0,0)")
|
| 61 |
return fig
|
| 62 |
|
| 63 |
+
# --- 5. π¨ GLOBAL WAR ROOM (Mobile: Top 3 & Numbers Only) ---
|
| 64 |
st.title("π¨ OMNI-WATCH: GLOBAL WAR ROOM")
|
| 65 |
+
st.caption(f"Last Updated: {datetime.now().strftime('%H:%M:%S')} UTC")
|
| 66 |
|
| 67 |
+
if st.button("π Refresh"):
|
| 68 |
if 'hot_issues' in st.session_state: del st.session_state.hot_issues
|
| 69 |
|
| 70 |
if 'hot_issues' not in st.session_state:
|
| 71 |
+
with st.spinner("Scanning feeds..."):
|
| 72 |
raw_news = fetch_extensive_news("breaking news crisis risk security", limit=35, period="12h")
|
| 73 |
news_context = "\n".join([f"Event: {n['title']}" for n in raw_news])
|
| 74 |
+
# TOP 3 Only
|
| 75 |
system_msg = """Identify TOP 3 critical incidents. Return ONLY JSON: {"issues": [{"title": "..", "score": 85, "summary": ["..", "..", ".."], "link": ".."}]}"""
|
| 76 |
try:
|
| 77 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": system_msg}, {"role": "user", "content": news_context}], response_format={"type": "json_object"})
|
|
|
|
| 79 |
except: st.session_state.hot_issues = []
|
| 80 |
|
| 81 |
if st.session_state.hot_issues:
|
| 82 |
+
cols = st.columns(3)
|
| 83 |
for i, issue in enumerate(st.session_state.hot_issues):
|
| 84 |
with cols[i]:
|
| 85 |
with st.container(border=True):
|
| 86 |
+
# War Room: μμ²νμ λλ‘ κ²μ΄μ§ λΉΌκ³ 'ν° μ«μ'λ‘ νμ
|
| 87 |
+
st.markdown(f"<h1 style='text-align: center; color: #FF4B4B; margin: 0;'>{issue.get('score', 50)}</h1>", unsafe_allow_html=True)
|
| 88 |
+
st.markdown("<p style='text-align: center; color: gray; font-size: 0.8em;'>Severity Index</p>", unsafe_allow_html=True)
|
|
|
|
| 89 |
st.error(f"**{issue.get('title')}**")
|
| 90 |
for line in issue.get('summary', []): st.caption(f"β’ {line}")
|
| 91 |
+
st.markdown(f"[π Link]({issue.get('link')})")
|
| 92 |
|
| 93 |
st.divider()
|
| 94 |
|
| 95 |
# --- 6. Strategic Tabs ---
|
| 96 |
+
tab1, tab2, tab3 = st.tabs(["π GLOBAL", "π FORENSICS", "π TRENDS"])
|
| 97 |
|
| 98 |
# --- [Tab 1: Strategic Global Scan] ---
|
| 99 |
with tab1:
|
| 100 |
+
st.header("Strategic Briefing (SIB)")
|
| 101 |
+
keyword = st.text_input("Keyword", "Cyber Warfare")
|
| 102 |
+
if st.button("Generate Report", type="primary"):
|
| 103 |
+
with st.status("Analyzing 20+ Sources...", expanded=True) as status:
|
| 104 |
all_news = []
|
| 105 |
for reg in REGION_MAP:
|
| 106 |
for geo in REGION_MAP[reg][:2]:
|
| 107 |
+
# λ°μ΄ν° μμ§ λ‘μ§ μ μ§ (κΉμ΄ 보쑴)
|
| 108 |
all_news.extend(fetch_extensive_news(keyword, geo=geo, limit=6, period="7d"))
|
| 109 |
+
status.write(f"β
Found {len(all_news)} articles. Synthesizing...")
|
| 110 |
|
| 111 |
news_summary = "\n".join([n['title'] for n in all_news[:45]])
|
| 112 |
+
# ν둬ννΈ: λͺ¨λ λΆμ νλ(Risk Landscape, Platform Matrix λ±) μλ²½ μ μ§
|
| 113 |
global_prompt = f"""
|
| 114 |
+
Analyze '{keyword}' in English.
|
| 115 |
+
Executive Summary MUST be a clean narrative (300+ words). NO 'REF' tags.
|
| 116 |
+
Use bullet points and paragraphs.
|
|
|
|
| 117 |
Return ONLY JSON:
|
| 118 |
{{
|
| 119 |
+
"executive_summary": "Clean narrative summary.",
|
| 120 |
"risk_landscape": [
|
| 121 |
{{"Component": "Target Demographics", "Findings": "...", "Risk_Level": "High"}},
|
| 122 |
{{"Component": "Policy Violation", "Findings": "...", "Risk_Level": "Medium"}},
|
|
|
|
| 124 |
{{"Component": "Tactical Mitigation", "Findings": "...", "Risk_Level": "Critical"}}
|
| 125 |
],
|
| 126 |
"platform_intelligence": [
|
| 127 |
+
{{"Platform": "TikTok", "Assessment": "...", "Strategy": "..."}},
|
| 128 |
+
{{"Platform": "YouTube", "Assessment": "...", "Strategy": "..."}},
|
| 129 |
+
{{"Platform": "Meta", "Assessment": "...", "Strategy": "..."}},
|
| 130 |
+
{{"Platform": "X", "Assessment": "...", "Strategy": "..."}}
|
| 131 |
],
|
| 132 |
+
"strategic_conclusion": "Final action point."
|
| 133 |
}}
|
| 134 |
"""
|
| 135 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": global_prompt}, {"role": "user", "content": news_summary}], response_format={"type": "json_object"})
|
| 136 |
g_data = json.loads(res.choices[0].message.content)
|
| 137 |
|
| 138 |
with st.container(border=True):
|
| 139 |
+
st.subheader("1. Executive Summary")
|
| 140 |
st.markdown(g_data.get('executive_summary').replace(". ", ".\n\n"))
|
| 141 |
|
| 142 |
+
st.subheader("2. Risk Landscape")
|
| 143 |
st.dataframe(pd.DataFrame(g_data.get('risk_landscape')), hide_index=True, use_container_width=True)
|
| 144 |
|
| 145 |
+
st.subheader("3. Platform Strategy")
|
| 146 |
+
st.dataframe(pd.DataFrame(g_data.get('platform_intelligence')), hide_index=True, use_container_width=True)
|
| 147 |
+
|
| 148 |
+
st.success(f"**Conclusion:** {g_data.get('strategic_conclusion')}")
|
| 149 |
+
|
| 150 |
+
# DOWNLOAD: λͺ¨λ°μΌ νΈνμ±μ μν΄ Markdown μ¬μ© (λ΄μ©μ μ 체 리ν¬νΈ 100% λμΌ)
|
| 151 |
+
report_md = f"# OMNI-WATCH STRATEGIC REPORT: {keyword.upper()}\n\n"
|
| 152 |
+
report_md += f"## 1. EXECUTIVE SUMMARY\n{g_data.get('executive_summary')}\n\n"
|
| 153 |
+
report_md += f"## 2. STRATEGIC CONCLUSION\n{g_data.get('strategic_conclusion')}\n\n"
|
| 154 |
+
report_md += "## 3. RISK LANDSCAPE\n"
|
| 155 |
+
for item in g_data.get('risk_landscape', []):
|
| 156 |
+
report_md += f"- **{item['Component']}**: {item['Findings']} (Risk: {item['Risk_Level']})\n"
|
| 157 |
|
| 158 |
+
st.download_button(
|
| 159 |
+
label="π₯ Download Report (.md)",
|
| 160 |
+
data=report_md,
|
| 161 |
+
file_name=f"Global_Intel_{datetime.now().strftime('%Y%m%d')}.md",
|
| 162 |
+
mime="text/markdown"
|
| 163 |
+
)
|
| 164 |
|
| 165 |
# --- [Tab 2: Tactical Forensics] ---
|
| 166 |
with tab2:
|
| 167 |
+
st.header("National Forensics")
|
| 168 |
+
target_geo = st.text_input("ISO Code (e.g., US)", "US").upper()
|
| 169 |
+
if st.button("Analyze Nation"):
|
| 170 |
+
with st.status(f"Scanning {target_geo}...", expanded=True):
|
| 171 |
+
# 20+ Sources μμ§ μ μ§
|
| 172 |
news = fetch_extensive_news(f"{target_geo} social risk", geo=target_geo, limit=40, period="7d")
|
| 173 |
news_titles = "\n".join([n['title'] for n in news])
|
| 174 |
|
| 175 |
+
# ν둬ννΈ: 4λ ν΅μ¬ νλ(Grid) μλ²½ μ μ§
|
| 176 |
system_prompt = f"""
|
| 177 |
Identify Top 5 Risks for {target_geo} in English.
|
| 178 |
+
Summary MUST be a clean narrative (300+ words). NO 'REF' tags.
|
|
|
|
| 179 |
Return ONLY JSON:
|
| 180 |
{{
|
| 181 |
"risks": [
|
| 182 |
{{
|
| 183 |
"rank": 1, "title": "..", "score": 90,
|
| 184 |
+
"summary": "Clean narrative analysis.",
|
| 185 |
"forensic_grid": {{
|
| 186 |
"Policy_Violation": "..",
|
| 187 |
"Vulnerable_Groups": "..",
|
|
|
|
| 195 |
res = client.chat.completions.create(model=CURRENT_MODEL, messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": news_titles}], response_format={"type": "json_object"})
|
| 196 |
report_data = json.loads(res.choices[0].message.content).get('risks', [])
|
| 197 |
|
| 198 |
+
full_report_md = f"# NATIONAL FORENSICS: {target_geo}\n\n"
|
| 199 |
+
|
| 200 |
for i, r in enumerate(report_data):
|
| 201 |
+
full_report_md += f"## RISK {r.get('rank')}: {r.get('title')} (Score: {r.get('score')})\n"
|
| 202 |
+
full_report_md += f"{r.get('summary')}\n\n"
|
| 203 |
+
|
| 204 |
+
with st.expander(f"π© {r.get('rank')}. {r.get('title')} (Score: {r.get('score')})", expanded=True):
|
| 205 |
c1, c2 = st.columns([1, 4])
|
| 206 |
with c1:
|
| 207 |
+
# Forensicsμμλ κ²μ΄μ§ μ°¨νΈ μ μ§ (ν€ μ€λ³΅ λ°©μ§ μ½λ ν¬ν¨)
|
| 208 |
+
st.plotly_chart(render_gauge(r.get('score'), "Index"), use_container_width=True, key=f"fg_{i}")
|
| 209 |
with c2:
|
|
|
|
| 210 |
st.markdown(r.get('summary').replace(". ", ".\n\n"))
|
| 211 |
|
| 212 |
+
st.dataframe(pd.DataFrame(r.get('forensic_grid', {}).items(), columns=["Component", "Finding"]), hide_index=True, use_container_width=True)
|
| 213 |
+
|
| 214 |
+
st.download_button(
|
| 215 |
+
label="π₯ Download Forensics (.md)",
|
| 216 |
+
data=full_report_md,
|
| 217 |
+
file_name=f"National_Forensics_{target_geo}.md",
|
| 218 |
+
mime="text/markdown"
|
| 219 |
+
)
|
| 220 |
|
| 221 |
st.divider()
|
| 222 |
+
st.caption(f"Sources: {len(news)} articles analyzed.")
|
| 223 |
+
st.dataframe(pd.DataFrame(news)[['title', 'source']], use_container_width=True)
|
| 224 |
|
| 225 |
+
# --- [Tab 3: Velocity] ---
|
| 226 |
with tab3:
|
| 227 |
+
st.header("Risk Velocity")
|
| 228 |
+
trend_key = st.text_input("Trend Topic", "Disinformation")
|
| 229 |
+
if st.button("Check Trend"):
|
| 230 |
dates = [(datetime.now() - timedelta(days=i)).strftime("%m-%d") for i in range(6, -1, -1)]
|
| 231 |
+
fig = px.area(x=dates, y=[15, 30, 45, 80, 95, 88, 92], title=f"Trend: {trend_key}")
|
| 232 |
st.plotly_chart(fig, use_container_width=True)
|