Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from groq import Groq
|
|
5 |
import os
|
6 |
from duckduckgo_search import DDGS
|
7 |
|
8 |
-
# Set page configuration with
|
9 |
st.set_page_config(
|
10 |
page_title="Z-Agent News Analysis",
|
11 |
layout="wide",
|
@@ -13,7 +13,19 @@ st.set_page_config(
|
|
13 |
page_icon="π"
|
14 |
)
|
15 |
|
16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
st.markdown("""
|
18 |
<style>
|
19 |
/* Global font and color scheme */
|
@@ -23,146 +35,329 @@ st.markdown("""
|
|
23 |
font-family: 'Inter', sans-serif;
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
/* Header styling */
|
27 |
h1 {
|
28 |
color: #101010;
|
29 |
font-weight: 700 !important;
|
30 |
margin-bottom: 1rem !important;
|
31 |
letter-spacing: -0.5px;
|
|
|
32 |
}
|
33 |
|
34 |
-
h2
|
35 |
font-weight: 600 !important;
|
36 |
color: #202020;
|
37 |
letter-spacing: -0.3px;
|
|
|
|
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
}
|
46 |
|
47 |
/* Card-like sections */
|
48 |
.card {
|
49 |
background-color: white;
|
50 |
-
border-radius:
|
51 |
-
padding:
|
52 |
-
box-shadow: 0
|
53 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
/* Button styling */
|
57 |
.stButton > button {
|
58 |
-
background
|
59 |
color: white;
|
60 |
border: none;
|
61 |
-
border-radius:
|
62 |
-
padding: 0.
|
63 |
font-weight: 500;
|
64 |
transition: all 0.3s;
|
65 |
width: 100%;
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
|
68 |
.stButton > button:hover {
|
69 |
-
background
|
70 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
/* Input field styling */
|
74 |
-
.stTextInput input
|
75 |
-
border-radius:
|
76 |
-
border:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
|
79 |
-
.
|
80 |
border-color: #1a73e8;
|
81 |
-
box-shadow: 0 0 0
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
/* Analysis result styling */
|
85 |
.analysis-result {
|
86 |
background-color: #F8F9FA;
|
87 |
border-radius: 12px;
|
88 |
-
padding:
|
89 |
-
border-left:
|
|
|
90 |
}
|
91 |
|
92 |
/* Expand/collapse sections */
|
93 |
.streamlit-expanderHeader {
|
94 |
font-weight: 500;
|
95 |
color: #5f6368;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
/* Spinner/progress styling */
|
99 |
.stSpinner > div {
|
100 |
border-color: #1a73e8 transparent transparent !important;
|
|
|
101 |
}
|
102 |
|
103 |
/* Footer styling */
|
104 |
footer {
|
105 |
border-top: 1px solid #F0F0F0;
|
106 |
-
padding-top:
|
107 |
color: #5f6368;
|
108 |
-
font-size: 0.
|
109 |
}
|
110 |
|
111 |
/* Logo and branding */
|
112 |
.logo-text {
|
113 |
-
font-weight:
|
114 |
background: linear-gradient(90deg, #1a73e8, #8ab4f8);
|
115 |
-webkit-background-clip: text;
|
116 |
-webkit-text-fill-color: transparent;
|
117 |
-
font-size: 2.
|
118 |
letter-spacing: -1px;
|
|
|
119 |
}
|
120 |
|
121 |
/* Sections */
|
122 |
.section-header {
|
123 |
-
font-size: 1.
|
124 |
-
font-weight:
|
125 |
-
margin-top:
|
126 |
-
margin-bottom:
|
127 |
color: #202124;
|
|
|
|
|
128 |
}
|
129 |
|
130 |
/* Source links */
|
131 |
a {
|
132 |
color: #1a73e8;
|
133 |
text-decoration: none;
|
|
|
|
|
134 |
}
|
135 |
|
136 |
a:hover {
|
|
|
137 |
text-decoration: underline;
|
138 |
}
|
139 |
|
140 |
/* Tabs for analysis results */
|
141 |
.stTabs [data-baseweb="tab-list"] {
|
142 |
gap: 2px;
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
.stTabs [data-baseweb="tab"] {
|
146 |
background-color: transparent;
|
147 |
-
border-radius:
|
148 |
color: #5f6368;
|
149 |
-
padding: 10px
|
|
|
|
|
150 |
}
|
151 |
|
152 |
.stTabs [aria-selected="true"] {
|
153 |
background-color: white !important;
|
154 |
color: #1a73e8 !important;
|
155 |
-
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
|
158 |
/* Info boxes */
|
159 |
.info-box {
|
160 |
background-color: #E8F0FE;
|
161 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
padding: 1rem;
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
margin-bottom: 1rem;
|
165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
</style>
|
167 |
""", unsafe_allow_html=True)
|
168 |
|
@@ -287,32 +482,39 @@ def log_agent_activity(prompt: str, result: str, agent_name: str):
|
|
287 |
for transparency and debugging purposes.
|
288 |
"""
|
289 |
with st.expander("π View Agent Activity Log"):
|
290 |
-
st.
|
291 |
-
st.
|
|
|
|
|
|
|
292 |
st.code(prompt, language="text")
|
293 |
-
st.
|
|
|
|
|
|
|
294 |
st.code(result, language="text")
|
|
|
295 |
|
296 |
-
#
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
<div style="text-align: center;
|
301 |
-
<svg width="
|
302 |
<path d="M19.5 9.5l-7.5-7.5-7.5 7.5m15 0v8c0 1.1-.9 2-2 2h-11c-1.1 0-2-.9-2-2v-8" stroke="#1a73e8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
303 |
<circle cx="12" cy="12" r="3" stroke="#1a73e8" stroke-width="2"/>
|
304 |
<path d="M12 15v3" stroke="#1a73e8" stroke-width="2" stroke-linecap="round"/>
|
305 |
</svg>
|
306 |
</div>
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
|
317 |
# Main content area
|
318 |
st.markdown('<div class="card">', unsafe_allow_html=True)
|
@@ -323,42 +525,69 @@ try:
|
|
323 |
llm = GroqLLM()
|
324 |
search_tool = DuckDuckGoSearch()
|
325 |
|
326 |
-
# Input section with
|
|
|
|
|
327 |
news_topic = st.text_input(
|
328 |
"What news topic would you like to analyze?",
|
329 |
-
placeholder="E.g., Recent developments in renewable energy, Tech industry layoffs, Global climate agreements..."
|
|
|
330 |
)
|
331 |
|
332 |
# Analysis options in a cleaner layout
|
333 |
-
|
|
|
|
|
|
|
334 |
|
335 |
with col1:
|
|
|
|
|
336 |
search_depth = st.slider(
|
337 |
-
"
|
338 |
min_value=3,
|
339 |
max_value=10,
|
340 |
value=5,
|
341 |
-
help="Number of news sources to analyze"
|
|
|
|
|
342 |
)
|
|
|
|
|
343 |
|
344 |
with col2:
|
|
|
|
|
345 |
analysis_type = st.selectbox(
|
346 |
-
"
|
347 |
["Comprehensive", "Quick Summary", "Technical", "Simplified"],
|
348 |
-
help="Choose the style and depth of analysis"
|
|
|
|
|
349 |
)
|
|
|
|
|
350 |
|
351 |
with col3:
|
|
|
|
|
352 |
time_period = st.selectbox(
|
353 |
-
"
|
354 |
["Last 7 days", "Last 30 days", "Last 24 hours"],
|
355 |
-
help="How recent should the news be"
|
|
|
|
|
356 |
)
|
|
|
|
|
357 |
|
358 |
# Generate analysis button
|
359 |
-
|
|
|
|
|
|
|
360 |
with col2:
|
361 |
-
analyze_button = st.button("
|
362 |
|
363 |
st.markdown('</div>', unsafe_allow_html=True)
|
364 |
|
@@ -366,11 +595,21 @@ try:
|
|
366 |
if analyze_button and news_topic:
|
367 |
with st.spinner(""):
|
368 |
try:
|
369 |
-
# Progress indicators with
|
370 |
progress_container = st.container()
|
371 |
progress_container.markdown('<div class="info-box">', unsafe_allow_html=True)
|
372 |
progress_placeholder = progress_container.empty()
|
373 |
-
progress_placeholder.markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
|
375 |
# Determine time frame from selection
|
376 |
time_map = {
|
@@ -388,7 +627,16 @@ try:
|
|
388 |
|
389 |
if not search_results.startswith(("Search error", "No results")):
|
390 |
# Update progress
|
391 |
-
progress_placeholder.markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
# Create analysis prompt
|
394 |
analysis_prompt = create_analysis_prompt(news_topic, search_results)
|
@@ -411,7 +659,7 @@ try:
|
|
411 |
st.markdown('</div>', unsafe_allow_html=True)
|
412 |
|
413 |
with tab2:
|
414 |
-
st.markdown("
|
415 |
# Parse and display sources in a more structured way
|
416 |
sources = search_results.split("\n\n")
|
417 |
for source in sources:
|
@@ -423,12 +671,21 @@ try:
|
|
423 |
url_line = lines[4].replace(" URL: ", "")
|
424 |
|
425 |
st.markdown(f"""
|
426 |
-
<div
|
427 |
-
<
|
428 |
-
<
|
429 |
-
{source_line}
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
</div>
|
433 |
""", unsafe_allow_html=True)
|
434 |
|
@@ -442,57 +699,151 @@ try:
|
|
442 |
)
|
443 |
else:
|
444 |
progress_container.empty()
|
445 |
-
st.error(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
|
447 |
except Exception as e:
|
448 |
-
st.error(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
elif analyze_button:
|
450 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
-
#
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
with tips_col1:
|
459 |
-
st.markdown("""
|
460 |
-
- **Be specific** with your topic for more focused analysis
|
461 |
-
- Use **keywords** related to recent events for timely information
|
462 |
-
- Include **geographic locations** when relevant (e.g., "Climate policy in Europe")
|
463 |
-
""")
|
464 |
-
|
465 |
-
with tips_col2:
|
466 |
st.markdown("""
|
467 |
-
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
except Exception as e:
|
|
|
475 |
st.error(f"""
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
""")
|
484 |
-
|
485 |
-
# Footer with branding
|
486 |
-
st.markdown("---")
|
487 |
-
st.markdown("""
|
488 |
-
<footer>
|
489 |
-
<div style="display: flex; justify-content: space-between; align-items: center;">
|
490 |
-
<div>
|
491 |
-
Z-Agent News Analysis Tool Β© 2025
|
492 |
-
</div>
|
493 |
-
<div>
|
494 |
-
Created for news analysis and research purposes
|
495 |
-
</div>
|
496 |
</div>
|
497 |
-
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
import os
|
6 |
from duckduckgo_search import DDGS
|
7 |
|
8 |
+
# Set page configuration with fullscreen layout and custom theme
|
9 |
st.set_page_config(
|
10 |
page_title="Z-Agent News Analysis",
|
11 |
layout="wide",
|
|
|
13 |
page_icon="π"
|
14 |
)
|
15 |
|
16 |
+
# Execute JavaScript to make the app fullscreen on load
|
17 |
+
st.markdown("""
|
18 |
+
<script>
|
19 |
+
document.addEventListener('DOMContentLoaded', (event) => {
|
20 |
+
// Request fullscreen on page load
|
21 |
+
document.documentElement.requestFullscreen().catch(e => {
|
22 |
+
console.log("Fullscreen request failed: ", e);
|
23 |
+
});
|
24 |
+
});
|
25 |
+
</script>
|
26 |
+
""", unsafe_allow_html=True)
|
27 |
+
|
28 |
+
# Enhanced CSS for a more beautiful Google DeepMind-inspired styling
|
29 |
st.markdown("""
|
30 |
<style>
|
31 |
/* Global font and color scheme */
|
|
|
35 |
font-family: 'Inter', sans-serif;
|
36 |
}
|
37 |
|
38 |
+
/* Background and main container styling */
|
39 |
+
.main {
|
40 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #ebeff5 100%);
|
41 |
+
padding: 0;
|
42 |
+
}
|
43 |
+
|
44 |
+
.main .block-container {
|
45 |
+
padding-top: 2rem;
|
46 |
+
padding-bottom: 3rem;
|
47 |
+
max-width: 1300px;
|
48 |
+
}
|
49 |
+
|
50 |
/* Header styling */
|
51 |
h1 {
|
52 |
color: #101010;
|
53 |
font-weight: 700 !important;
|
54 |
margin-bottom: 1rem !important;
|
55 |
letter-spacing: -0.5px;
|
56 |
+
font-size: 2.8rem !important;
|
57 |
}
|
58 |
|
59 |
+
h2 {
|
60 |
font-weight: 600 !important;
|
61 |
color: #202020;
|
62 |
letter-spacing: -0.3px;
|
63 |
+
font-size: 1.8rem !important;
|
64 |
+
margin-top: 1.5rem !important;
|
65 |
}
|
66 |
|
67 |
+
h3 {
|
68 |
+
font-weight: 600 !important;
|
69 |
+
color: #303030;
|
70 |
+
letter-spacing: -0.2px;
|
71 |
+
font-size: 1.4rem !important;
|
72 |
}
|
73 |
|
74 |
/* Card-like sections */
|
75 |
.card {
|
76 |
background-color: white;
|
77 |
+
border-radius: 16px;
|
78 |
+
padding: 2rem;
|
79 |
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
80 |
+
margin-bottom: 2rem;
|
81 |
+
border: 1px solid rgba(240, 240, 240, 0.9);
|
82 |
+
transition: all 0.3s ease;
|
83 |
+
}
|
84 |
+
|
85 |
+
.card:hover {
|
86 |
+
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
|
87 |
+
transform: translateY(-3px);
|
88 |
}
|
89 |
|
90 |
/* Button styling */
|
91 |
.stButton > button {
|
92 |
+
background: linear-gradient(90deg, #1a73e8, #0b5cbe);
|
93 |
color: white;
|
94 |
border: none;
|
95 |
+
border-radius: 8px;
|
96 |
+
padding: 0.8rem 1.5rem;
|
97 |
font-weight: 500;
|
98 |
transition: all 0.3s;
|
99 |
width: 100%;
|
100 |
+
text-transform: uppercase;
|
101 |
+
letter-spacing: 0.5px;
|
102 |
+
font-size: 1rem;
|
103 |
+
box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
|
104 |
}
|
105 |
|
106 |
.stButton > button:hover {
|
107 |
+
background: linear-gradient(90deg, #1765cc, #0a51a8);
|
108 |
+
box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
|
109 |
+
transform: translateY(-2px);
|
110 |
+
}
|
111 |
+
|
112 |
+
.stButton > button:active {
|
113 |
+
transform: translateY(1px);
|
114 |
}
|
115 |
|
116 |
/* Input field styling */
|
117 |
+
.stTextInput input {
|
118 |
+
border-radius: 8px;
|
119 |
+
border: 2px solid #E0E0E0;
|
120 |
+
padding: 1rem;
|
121 |
+
font-size: 1rem;
|
122 |
+
transition: all 0.3s;
|
123 |
+
}
|
124 |
+
|
125 |
+
.stTextInput input:focus {
|
126 |
+
border-color: #1a73e8;
|
127 |
+
box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.2);
|
128 |
+
}
|
129 |
+
|
130 |
+
.stSelectbox div[data-baseweb="select"] div {
|
131 |
+
border-radius: 8px;
|
132 |
+
border: 2px solid #E0E0E0;
|
133 |
+
padding: 0.25rem;
|
134 |
}
|
135 |
|
136 |
+
.stSelectbox div[data-baseweb="select"] div:focus {
|
137 |
border-color: #1a73e8;
|
138 |
+
box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.2);
|
139 |
+
}
|
140 |
+
|
141 |
+
.stSlider div[data-baseweb="slider"] {
|
142 |
+
border-radius: 8px;
|
143 |
}
|
144 |
|
145 |
/* Analysis result styling */
|
146 |
.analysis-result {
|
147 |
background-color: #F8F9FA;
|
148 |
border-radius: 12px;
|
149 |
+
padding: 2rem;
|
150 |
+
border-left: 6px solid #1a73e8;
|
151 |
+
line-height: 1.7;
|
152 |
}
|
153 |
|
154 |
/* Expand/collapse sections */
|
155 |
.streamlit-expanderHeader {
|
156 |
font-weight: 500;
|
157 |
color: #5f6368;
|
158 |
+
background-color: #f8f9fa;
|
159 |
+
border-radius: 8px;
|
160 |
+
padding: 0.8rem !important;
|
161 |
+
border: 1px solid #e8eaed;
|
162 |
+
}
|
163 |
+
|
164 |
+
.streamlit-expanderHeader:hover {
|
165 |
+
background-color: #f1f3f4;
|
166 |
}
|
167 |
|
168 |
/* Spinner/progress styling */
|
169 |
.stSpinner > div {
|
170 |
border-color: #1a73e8 transparent transparent !important;
|
171 |
+
border-width: 3px !important;
|
172 |
}
|
173 |
|
174 |
/* Footer styling */
|
175 |
footer {
|
176 |
border-top: 1px solid #F0F0F0;
|
177 |
+
padding-top: 1.5rem;
|
178 |
color: #5f6368;
|
179 |
+
font-size: 0.9rem;
|
180 |
}
|
181 |
|
182 |
/* Logo and branding */
|
183 |
.logo-text {
|
184 |
+
font-weight: 700;
|
185 |
background: linear-gradient(90deg, #1a73e8, #8ab4f8);
|
186 |
-webkit-background-clip: text;
|
187 |
-webkit-text-fill-color: transparent;
|
188 |
+
font-size: 2.8rem;
|
189 |
letter-spacing: -1px;
|
190 |
+
text-shadow: 0px 4px 8px rgba(26, 115, 232, 0.2);
|
191 |
}
|
192 |
|
193 |
/* Sections */
|
194 |
.section-header {
|
195 |
+
font-size: 1.3rem;
|
196 |
+
font-weight: 600;
|
197 |
+
margin-top: 2rem;
|
198 |
+
margin-bottom: 1.2rem;
|
199 |
color: #202124;
|
200 |
+
padding-bottom: 0.5rem;
|
201 |
+
border-bottom: 2px solid #f1f3f4;
|
202 |
}
|
203 |
|
204 |
/* Source links */
|
205 |
a {
|
206 |
color: #1a73e8;
|
207 |
text-decoration: none;
|
208 |
+
transition: all 0.2s;
|
209 |
+
font-weight: 500;
|
210 |
}
|
211 |
|
212 |
a:hover {
|
213 |
+
color: #0b5cbe;
|
214 |
text-decoration: underline;
|
215 |
}
|
216 |
|
217 |
/* Tabs for analysis results */
|
218 |
.stTabs [data-baseweb="tab-list"] {
|
219 |
gap: 2px;
|
220 |
+
border-radius: 12px;
|
221 |
+
background-color: #f8f9fa;
|
222 |
+
padding: 5px;
|
223 |
}
|
224 |
|
225 |
.stTabs [data-baseweb="tab"] {
|
226 |
background-color: transparent;
|
227 |
+
border-radius: 8px;
|
228 |
color: #5f6368;
|
229 |
+
padding: 10px 20px;
|
230 |
+
font-weight: 500;
|
231 |
+
transition: all 0.2s;
|
232 |
}
|
233 |
|
234 |
.stTabs [aria-selected="true"] {
|
235 |
background-color: white !important;
|
236 |
color: #1a73e8 !important;
|
237 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
238 |
+
}
|
239 |
+
|
240 |
+
.stTabs [data-baseweb="tab"]:hover:not([aria-selected="true"]) {
|
241 |
+
background-color: rgba(0, 0, 0, 0.05);
|
242 |
}
|
243 |
|
244 |
/* Info boxes */
|
245 |
.info-box {
|
246 |
background-color: #E8F0FE;
|
247 |
+
border-radius: 12px;
|
248 |
+
padding: 1.2rem;
|
249 |
+
border-left: 6px solid #1a73e8;
|
250 |
+
margin-bottom: 1.5rem;
|
251 |
+
box-shadow: 0 4px 12px rgba(26, 115, 232, 0.15);
|
252 |
+
}
|
253 |
+
|
254 |
+
/* Progress animation */
|
255 |
+
@keyframes pulse {
|
256 |
+
0% { opacity: 0.6; }
|
257 |
+
50% { opacity: 1; }
|
258 |
+
100% { opacity: 0.6; }
|
259 |
+
}
|
260 |
+
|
261 |
+
.pulsing {
|
262 |
+
animation: pulse 1.5s infinite ease-in-out;
|
263 |
+
}
|
264 |
+
|
265 |
+
/* Source item styling */
|
266 |
+
.source-item {
|
267 |
+
margin-bottom: 1.5rem;
|
268 |
+
padding-bottom: 1.5rem;
|
269 |
+
border-bottom: 1px solid #f0f0f0;
|
270 |
+
transition: all 0.3s;
|
271 |
+
}
|
272 |
+
|
273 |
+
.source-item:hover {
|
274 |
+
background-color: #f8f9fa;
|
275 |
padding: 1rem;
|
276 |
+
margin: 0 -1rem 1.5rem -1rem;
|
277 |
+
border-radius: 8px;
|
278 |
+
}
|
279 |
+
|
280 |
+
.source-title {
|
281 |
+
margin-bottom: 0.3rem;
|
282 |
+
font-weight: 600;
|
283 |
+
color: #202124;
|
284 |
+
font-size: 1.1rem;
|
285 |
+
}
|
286 |
+
|
287 |
+
.source-meta {
|
288 |
+
color: #5f6368;
|
289 |
+
margin-bottom: 0.8rem;
|
290 |
+
font-size: 0.9rem;
|
291 |
+
display: flex;
|
292 |
+
align-items: center;
|
293 |
+
gap: 8px;
|
294 |
+
}
|
295 |
+
|
296 |
+
.source-meta-dot {
|
297 |
+
display: inline-block;
|
298 |
+
width: 4px;
|
299 |
+
height: 4px;
|
300 |
+
background-color: #5f6368;
|
301 |
+
border-radius: 50%;
|
302 |
+
}
|
303 |
+
|
304 |
+
.read-link {
|
305 |
+
display: inline-flex;
|
306 |
+
align-items: center;
|
307 |
+
gap: 6px;
|
308 |
+
font-weight: 500;
|
309 |
+
font-size: 0.9rem;
|
310 |
+
}
|
311 |
+
|
312 |
+
/* Status indicators */
|
313 |
+
.status-badge {
|
314 |
+
display: inline-flex;
|
315 |
+
align-items: center;
|
316 |
+
gap: 6px;
|
317 |
+
padding: 0.4rem 0.8rem;
|
318 |
+
border-radius: 16px;
|
319 |
+
font-size: 0.85rem;
|
320 |
+
font-weight: 500;
|
321 |
+
}
|
322 |
+
|
323 |
+
.status-searching {
|
324 |
+
background-color: #e8f0fe;
|
325 |
+
color: #1a73e8;
|
326 |
+
}
|
327 |
+
|
328 |
+
.status-analyzing {
|
329 |
+
background-color: #e6f4ea;
|
330 |
+
color: #137333;
|
331 |
+
}
|
332 |
+
|
333 |
+
/* Header icon animation */
|
334 |
+
@keyframes float {
|
335 |
+
0% { transform: translateY(0px); }
|
336 |
+
50% { transform: translateY(-10px); }
|
337 |
+
100% { transform: translateY(0px); }
|
338 |
+
}
|
339 |
+
|
340 |
+
.float-icon {
|
341 |
+
animation: float 3s ease-in-out infinite;
|
342 |
+
}
|
343 |
+
|
344 |
+
/* Tips section */
|
345 |
+
.tip-item {
|
346 |
+
display: flex;
|
347 |
+
align-items: flex-start;
|
348 |
+
gap: 12px;
|
349 |
margin-bottom: 1rem;
|
350 |
}
|
351 |
+
|
352 |
+
.tip-icon {
|
353 |
+
color: #1a73e8;
|
354 |
+
font-size: 1.2rem;
|
355 |
+
margin-top: 0.2rem;
|
356 |
+
}
|
357 |
+
|
358 |
+
.tip-text {
|
359 |
+
flex: 1;
|
360 |
+
}
|
361 |
</style>
|
362 |
""", unsafe_allow_html=True)
|
363 |
|
|
|
482 |
for transparency and debugging purposes.
|
483 |
"""
|
484 |
with st.expander("π View Agent Activity Log"):
|
485 |
+
st.markdown("<h4>Agent Activity Log</h4>", unsafe_allow_html=True)
|
486 |
+
st.markdown(f"<p><strong>Agent:</strong> {agent_name}</p>", unsafe_allow_html=True)
|
487 |
+
|
488 |
+
st.markdown("<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;'>", unsafe_allow_html=True)
|
489 |
+
st.markdown("<p><strong>Input Prompt:</strong></p>", unsafe_allow_html=True)
|
490 |
st.code(prompt, language="text")
|
491 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
492 |
+
|
493 |
+
st.markdown("<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 8px;'>", unsafe_allow_html=True)
|
494 |
+
st.markdown("<p><strong>Analysis Output:</strong></p>", unsafe_allow_html=True)
|
495 |
st.code(result, language="text")
|
496 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
497 |
|
498 |
+
# Animated header with branded logo and description
|
499 |
+
st.markdown("""
|
500 |
+
<div class="card" style="padding-bottom: 1.5rem;">
|
501 |
+
<div style="display: flex; align-items: center; gap: 1.5rem;">
|
502 |
+
<div class="float-icon" style="text-align: center;">
|
503 |
+
<svg width="70" height="70" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
504 |
<path d="M19.5 9.5l-7.5-7.5-7.5 7.5m15 0v8c0 1.1-.9 2-2 2h-11c-1.1 0-2-.9-2-2v-8" stroke="#1a73e8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
505 |
<circle cx="12" cy="12" r="3" stroke="#1a73e8" stroke-width="2"/>
|
506 |
<path d="M12 15v3" stroke="#1a73e8" stroke-width="2" stroke-linecap="round"/>
|
507 |
</svg>
|
508 |
</div>
|
509 |
+
<div style="flex: 1;">
|
510 |
+
<span class="logo-text">Z-Agent News Analysis</span>
|
511 |
+
<p style="color: #5f6368; font-size: 1.1rem; margin-top: 0.5rem;">
|
512 |
+
Intelligent news analysis powered by AI. Get comprehensive insights and multiple perspectives on any topic.
|
513 |
+
</p>
|
514 |
+
</div>
|
515 |
+
</div>
|
516 |
+
</div>
|
517 |
+
""", unsafe_allow_html=True)
|
518 |
|
519 |
# Main content area
|
520 |
st.markdown('<div class="card">', unsafe_allow_html=True)
|
|
|
525 |
llm = GroqLLM()
|
526 |
search_tool = DuckDuckGoSearch()
|
527 |
|
528 |
+
# Input section with enhanced design
|
529 |
+
st.markdown("<h2 style='margin-top: 0;'>News Topic Analysis</h2>", unsafe_allow_html=True)
|
530 |
+
|
531 |
news_topic = st.text_input(
|
532 |
"What news topic would you like to analyze?",
|
533 |
+
placeholder="E.g., Recent developments in renewable energy, Tech industry layoffs, Global climate agreements...",
|
534 |
+
key="news_topic_input"
|
535 |
)
|
536 |
|
537 |
# Analysis options in a cleaner layout
|
538 |
+
st.markdown("<div style='margin-top: 1.5rem;'></div>", unsafe_allow_html=True)
|
539 |
+
st.markdown("<h3 style='margin-bottom: 1rem;'>Analysis Options</h3>", unsafe_allow_html=True)
|
540 |
+
|
541 |
+
col1, col2, col3 = st.columns([2, 2, 2])
|
542 |
|
543 |
with col1:
|
544 |
+
st.markdown("<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 12px; height: 100%;'>", unsafe_allow_html=True)
|
545 |
+
st.markdown("<p style='font-weight: 600; color: #202124; margin-bottom: 0.5rem;'>Search Depth</p>", unsafe_allow_html=True)
|
546 |
search_depth = st.slider(
|
547 |
+
"##",
|
548 |
min_value=3,
|
549 |
max_value=10,
|
550 |
value=5,
|
551 |
+
help="Number of news sources to analyze",
|
552 |
+
key="search_depth_slider",
|
553 |
+
label_visibility="collapsed"
|
554 |
)
|
555 |
+
st.markdown("<p style='color: #5f6368; font-size: 0.9rem;'>Number of sources: " + str(search_depth) + "</p>", unsafe_allow_html=True)
|
556 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
557 |
|
558 |
with col2:
|
559 |
+
st.markdown("<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 12px; height: 100%;'>", unsafe_allow_html=True)
|
560 |
+
st.markdown("<p style='font-weight: 600; color: #202124; margin-bottom: 0.5rem;'>Analysis Type</p>", unsafe_allow_html=True)
|
561 |
analysis_type = st.selectbox(
|
562 |
+
"##",
|
563 |
["Comprehensive", "Quick Summary", "Technical", "Simplified"],
|
564 |
+
help="Choose the style and depth of analysis",
|
565 |
+
key="analysis_type_select",
|
566 |
+
label_visibility="collapsed"
|
567 |
)
|
568 |
+
st.markdown("<p style='color: #5f6368; font-size: 0.9rem;'>Selected: " + analysis_type + "</p>", unsafe_allow_html=True)
|
569 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
570 |
|
571 |
with col3:
|
572 |
+
st.markdown("<div style='background-color: #f8f9fa; padding: 1rem; border-radius: 12px; height: 100%;'>", unsafe_allow_html=True)
|
573 |
+
st.markdown("<p style='font-weight: 600; color: #202124; margin-bottom: 0.5rem;'>Time Period</p>", unsafe_allow_html=True)
|
574 |
time_period = st.selectbox(
|
575 |
+
"##",
|
576 |
["Last 7 days", "Last 30 days", "Last 24 hours"],
|
577 |
+
help="How recent should the news be",
|
578 |
+
key="time_period_select",
|
579 |
+
label_visibility="collapsed"
|
580 |
)
|
581 |
+
st.markdown("<p style='color: #5f6368; font-size: 0.9rem;'>Selected: " + time_period + "</p>", unsafe_allow_html=True)
|
582 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
583 |
|
584 |
# Generate analysis button
|
585 |
+
st.markdown("<div style='margin-top: 2rem;'></div>", unsafe_allow_html=True)
|
586 |
+
|
587 |
+
col1, col2, col3 = st.columns([2, 2, 2])
|
588 |
+
|
589 |
with col2:
|
590 |
+
analyze_button = st.button("ANALYZE NEWS")
|
591 |
|
592 |
st.markdown('</div>', unsafe_allow_html=True)
|
593 |
|
|
|
595 |
if analyze_button and news_topic:
|
596 |
with st.spinner(""):
|
597 |
try:
|
598 |
+
# Progress indicators with enhanced styling
|
599 |
progress_container = st.container()
|
600 |
progress_container.markdown('<div class="info-box">', unsafe_allow_html=True)
|
601 |
progress_placeholder = progress_container.empty()
|
602 |
+
progress_placeholder.markdown("""
|
603 |
+
<div class="pulsing">
|
604 |
+
<div class="status-badge status-searching">
|
605 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
606 |
+
<circle cx="11" cy="11" r="8"></circle>
|
607 |
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
608 |
+
</svg>
|
609 |
+
<span>Searching for recent news sources...</span>
|
610 |
+
</div>
|
611 |
+
</div>
|
612 |
+
""", unsafe_allow_html=True)
|
613 |
|
614 |
# Determine time frame from selection
|
615 |
time_map = {
|
|
|
627 |
|
628 |
if not search_results.startswith(("Search error", "No results")):
|
629 |
# Update progress
|
630 |
+
progress_placeholder.markdown("""
|
631 |
+
<div class="pulsing">
|
632 |
+
<div class="status-badge status-analyzing">
|
633 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
634 |
+
<path d="M12 3v3m0 12v3m-9-9H3m3-6l2 2M3 12h3m12 0h3m-3-6l-2 2m9 3h-3m-6 6l-2 2m12 0l-2-2"></path>
|
635 |
+
</svg>
|
636 |
+
<span>Analyzing search results and generating insights...</span>
|
637 |
+
</div>
|
638 |
+
</div>
|
639 |
+
""", unsafe_allow_html=True)
|
640 |
|
641 |
# Create analysis prompt
|
642 |
analysis_prompt = create_analysis_prompt(news_topic, search_results)
|
|
|
659 |
st.markdown('</div>', unsafe_allow_html=True)
|
660 |
|
661 |
with tab2:
|
662 |
+
st.markdown("<h3>News Sources Used in Analysis</h3>", unsafe_allow_html=True)
|
663 |
# Parse and display sources in a more structured way
|
664 |
sources = search_results.split("\n\n")
|
665 |
for source in sources:
|
|
|
671 |
url_line = lines[4].replace(" URL: ", "")
|
672 |
|
673 |
st.markdown(f"""
|
674 |
+
<div class="source-item">
|
675 |
+
<p class="source-title">{title_line}</p>
|
676 |
+
<div class="source-meta">
|
677 |
+
<span>{source_line}</span>
|
678 |
+
<span class="source-meta-dot"></span>
|
679 |
+
<span>{date_line}</span>
|
680 |
+
</div>
|
681 |
+
<a href="{url_line}" class="read-link" target="_blank">
|
682 |
+
Read original article
|
683 |
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
684 |
+
<path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>
|
685 |
+
<path d="M15 3h6v6"></path>
|
686 |
+
<path d="M10 14L21 3"></path>
|
687 |
+
</svg>
|
688 |
+
</a>
|
689 |
</div>
|
690 |
""", unsafe_allow_html=True)
|
691 |
|
|
|
699 |
)
|
700 |
else:
|
701 |
progress_container.empty()
|
702 |
+
st.error(f"""
|
703 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
704 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FF5252" stroke-width="2">
|
705 |
+
<circle cx="12" cy="12" r="10"></circle>
|
706 |
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
707 |
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
708 |
+
</svg>
|
709 |
+
<span>{search_results}</span>
|
710 |
+
</div>
|
711 |
+
""", unsafe_allow_html=True)
|
712 |
|
713 |
except Exception as e:
|
714 |
+
st.error(f"""
|
715 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
716 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FF5252" stroke-width="2">
|
717 |
+
<circle cx="12" cy="12" r="10"></circle>
|
718 |
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
719 |
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
720 |
+
</svg>
|
721 |
+
<span>An error occurred during analysis: {str(e)}</span>
|
722 |
+
</div>
|
723 |
+
""", unsafe_allow_html=True)
|
724 |
elif analyze_button:
|
725 |
+
# This handles the case when analyze button is clicked but no topic is entered
|
726 |
+
st.warning("""
|
727 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
728 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FFA726" stroke-width="2">
|
729 |
+
<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"></path>
|
730 |
+
<line x1="12" y1="9" x2="12" y2="13"></line>
|
731 |
+
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
732 |
+
</svg>
|
733 |
+
<span>Please enter a news topic to analyze.</span>
|
734 |
+
</div>
|
735 |
+
""", unsafe_allow_html=True)
|
736 |
|
737 |
+
# Tips and usage guidance section - displayed when no analysis is in progress
|
738 |
+
if not analyze_button or not news_topic:
|
739 |
+
st.markdown('<div class="card">', unsafe_allow_html=True)
|
740 |
+
st.markdown("<h2 style='margin-top: 0;'>Tips for Better Results</h2>", unsafe_allow_html=True)
|
741 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
st.markdown("""
|
743 |
+
<div class="tip-item">
|
744 |
+
<div class="tip-icon">π‘</div>
|
745 |
+
<div class="tip-text">
|
746 |
+
<strong>Be specific with your topic.</strong> Instead of "climate change", try "recent climate legislation in the EU".
|
747 |
+
</div>
|
748 |
+
</div>
|
749 |
+
|
750 |
+
<div class="tip-item">
|
751 |
+
<div class="tip-icon">π</div>
|
752 |
+
<div class="tip-text">
|
753 |
+
<strong>Adjust search depth</strong> to find the right balance between comprehensive coverage and analysis speed.
|
754 |
+
</div>
|
755 |
+
</div>
|
756 |
+
|
757 |
+
<div class="tip-item">
|
758 |
+
<div class="tip-icon">π</div>
|
759 |
+
<div class="tip-text">
|
760 |
+
<strong>Choose the right analysis type</strong> based on your needs:
|
761 |
+
<ul>
|
762 |
+
<li><strong>Comprehensive:</strong> Full analysis with multiple perspectives</li>
|
763 |
+
<li><strong>Quick Summary:</strong> Brief overview of key points</li>
|
764 |
+
<li><strong>Technical:</strong> Detailed analysis with industry-specific terminology</li>
|
765 |
+
<li><strong>Simplified:</strong> Easy-to-understand breakdown of complex topics</li>
|
766 |
+
</ul>
|
767 |
+
</div>
|
768 |
+
</div>
|
769 |
+
|
770 |
+
<div class="tip-item">
|
771 |
+
<div class="tip-icon">β±οΈ</div>
|
772 |
+
<div class="tip-text">
|
773 |
+
<strong>Select an appropriate time period</strong> based on how recent you want the news to be.
|
774 |
+
</div>
|
775 |
+
</div>
|
776 |
+
""", unsafe_allow_html=True)
|
777 |
+
|
778 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
779 |
+
|
780 |
+
# Example topics for quick selection
|
781 |
+
st.markdown('<div class="card">', unsafe_allow_html=True)
|
782 |
+
st.markdown("<h2 style='margin-top: 0;'>Try These Topics</h2>", unsafe_allow_html=True)
|
783 |
+
|
784 |
+
col1, col2, col3 = st.columns(3)
|
785 |
+
|
786 |
+
with col1:
|
787 |
+
if st.button("π Climate Change Policies"):
|
788 |
+
st.session_state.news_topic_input = "Recent climate change policies and agreements"
|
789 |
+
st.experimental_rerun()
|
790 |
+
|
791 |
+
with col2:
|
792 |
+
if st.button("π° Cryptocurrency Trends"):
|
793 |
+
st.session_state.news_topic_input = "Latest developments in cryptocurrency markets"
|
794 |
+
st.experimental_rerun()
|
795 |
+
|
796 |
+
with col3:
|
797 |
+
if st.button("π¬ AI Research Breakthroughs"):
|
798 |
+
st.session_state.news_topic_input = "Recent breakthroughs in artificial intelligence research"
|
799 |
+
st.experimental_rerun()
|
800 |
+
|
801 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
802 |
+
|
803 |
+
# Footer with attribution and version info
|
804 |
+
st.markdown("""
|
805 |
+
<footer>
|
806 |
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
807 |
+
<div>Z-Agent News Analysis v1.0.1</div>
|
808 |
+
<div>Powered by Groq LLM & DuckDuckGo Search</div>
|
809 |
+
</div>
|
810 |
+
</footer>
|
811 |
+
""", unsafe_allow_html=True)
|
812 |
|
813 |
except Exception as e:
|
814 |
+
# Global error handling to catch any unforeseen issues
|
815 |
st.error(f"""
|
816 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
817 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FF5252" stroke-width="2">
|
818 |
+
<circle cx="12" cy="12" r="10"></circle>
|
819 |
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
820 |
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
821 |
+
</svg>
|
822 |
+
<span>Application Error: {str(e)}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
823 |
</div>
|
824 |
+
""", unsafe_allow_html=True)
|
825 |
+
|
826 |
+
st.markdown("""
|
827 |
+
<div style="background-color: #F8F9FA; padding: 1rem; border-radius: 8px; margin-top: 1rem;">
|
828 |
+
<p><strong>Troubleshooting Tips:</strong></p>
|
829 |
+
<ul>
|
830 |
+
<li>Check your API keys for Groq LLM in environment variables</li>
|
831 |
+
<li>Ensure you have internet connection for DuckDuckGo searches</li>
|
832 |
+
<li>Try refreshing the page or restarting the application</li>
|
833 |
+
</ul>
|
834 |
+
</div>
|
835 |
+
""", unsafe_allow_html=True)
|
836 |
+
|
837 |
+
# Add a hidden feature to reset the application state
|
838 |
+
if st.sidebar.button("Reset Application", key="reset_app"):
|
839 |
+
for key in st.session_state.keys():
|
840 |
+
del st.session_state[key]
|
841 |
+
st.experimental_rerun()
|
842 |
+
|
843 |
+
# Optional: Add a feedback mechanism
|
844 |
+
with st.sidebar:
|
845 |
+
st.markdown("### Feedback")
|
846 |
+
feedback = st.text_area("Share your thoughts or report issues", placeholder="Your feedback helps us improve...")
|
847 |
+
if st.button("Submit Feedback"):
|
848 |
+
st.success("Thank you for your feedback!")
|
849 |
+
# In a production app, you would save this feedback to a database
|