MathWizard1729 commited on
Commit
d807663
·
verified ·
1 Parent(s): 39c94a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -24
app.py CHANGED
@@ -18,79 +18,113 @@ bedrock = boto3.client("bedrock-runtime", region_name=AWS_REGION)
18
  # ───────────────────────────────────────────────────────────────────────────────
19
  # Page configuration
20
  st.set_page_config(
21
- page_title="📰 News Summarizer Agent",
22
  page_icon="📰",
23
  layout="wide", # wide layout for more room
24
  initial_sidebar_state="expanded"
25
  )
26
 
27
  # ───────────────────────────────────────────────────────────────────────────────
28
- # Custom CSS for vibrant UI
29
  st.markdown(
30
  """
31
  <style>
32
- /* Change background color of the main area */
33
  .stApp {
34
- background-color: #F7F9FC;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  /* Style for the title */
37
  .app-title {
38
  font-size: 2.5rem;
39
- color: #1E3A8A;
40
  font-weight: 700;
41
  margin-bottom: 0.2rem;
42
  }
43
  /* Style for the subtitle/description */
44
  .app-subtitle {
45
  font-size: 1.1rem;
46
- color: #374151;
47
  margin-bottom: 1.5rem;
48
  }
49
- /* Card container styling */
50
  .news-card {
51
- background-color: #FFFFFF;
52
  border-radius: 10px;
53
  padding: 1rem;
54
  margin-bottom: 1.5rem;
55
- box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.05);
56
  }
57
- /* Header style inside each card */
58
  .news-header {
59
- background-color: #E0F2FE;
60
  border-radius: 8px;
61
  padding: 0.5rem 1rem;
62
  margin-bottom: 0.8rem;
63
  }
64
  .news-header h4 {
65
  margin: 0;
66
- color: #0369A1;
67
  }
68
  /* Article title style */
69
  .article-title {
70
  font-size: 1.2rem;
71
  font-weight: 600;
72
- color: #1F2937;
73
  margin-bottom: 0.5rem;
74
  }
75
  /* Summary text style */
76
  .article-summary {
77
  font-size: 1rem;
78
- color: #4B5563;
79
  margin-bottom: 0.7rem;
80
  }
81
  /* “Read more” link style */
82
  .read-link {
83
  font-size: 0.95rem;
84
- color: #1D4ED8;
85
  text-decoration: none;
86
  font-weight: 500;
87
  }
88
  .read-link:hover {
89
  text-decoration: underline;
90
  }
91
- /* Spinner/loading text */
92
  .stSpinner > div {
93
- background-color: #FFFFFF !important;
 
 
 
 
 
 
 
94
  }
95
  </style>
96
  """,
@@ -103,9 +137,9 @@ with st.sidebar:
103
  st.markdown("## ℹ️ About This App")
104
  st.markdown(
105
  """
106
- - Enter any **topic**, **company name**, or **keywords** above and click **Get News**.
107
- - This app will fetch up to 3 articles from **NewsAPI** and 2 from **Serper**, then summarize them using AWS Bedrock (Claude).
108
- - You need valid `NEWS_API_KEY`, `SERPER_API_KEY`, and AWS credentials / region configured.
109
  """
110
  )
111
  st.markdown("---")
@@ -129,7 +163,7 @@ with st.sidebar:
129
 
130
  # ─────────────────────────────────────────────────────���─────────────────────────
131
  # Main Title / Header
132
- st.markdown('<div class="app-title">📰 News Summarizer Agent</div>', unsafe_allow_html=True)
133
  st.markdown(
134
  '<div class="app-subtitle">Get the top 5 latest news with concise summaries on any topic or company you choose.</div>',
135
  unsafe_allow_html=True
@@ -214,7 +248,7 @@ def summarize_with_bedrock(title: str, content: str) -> str:
214
  if btn and query:
215
  st.info(f"🔍 Searching for news on <b>{query}</b>...", unsafe_allow_html=True)
216
 
217
- # Fetch articles concurrently / sequentially
218
  newsapi_articles = get_newsapi_articles(query)
219
  serper_articles = get_serper_articles(query)
220
 
@@ -261,8 +295,8 @@ if btn and query:
261
  # Footer (optional)
262
  st.markdown(
263
  """
264
- <hr>
265
- <div style="text-align:center; font-size:0.9rem; color:#6B7280; padding-top:1rem;">
266
  Built with ❤️ using Streamlit • Data sources: NewsAPI.org, Serper.dev • Summarization via AWS Bedrock Claude
267
  </div>
268
  """,
 
18
  # ───────────────────────────────────────────────────────────────────────────────
19
  # Page configuration
20
  st.set_page_config(
21
+ page_title="📰 News Summarizer Agent (Dark Mode)",
22
  page_icon="📰",
23
  layout="wide", # wide layout for more room
24
  initial_sidebar_state="expanded"
25
  )
26
 
27
  # ───────────────────────────────────────────────────────────────────────────────
28
+ # Custom CSS for dark UI
29
  st.markdown(
30
  """
31
  <style>
32
+ /* Set dark background for the entire app */
33
  .stApp {
34
+ background-color: #121212;
35
+ color: #E0E0E0;
36
+ }
37
+ /* Sidebar background and text */
38
+ [data-testid="stSidebar"] {
39
+ background-color: #1E1E1E;
40
+ color: #E0E0E0;
41
+ }
42
+ [data-testid="stSidebar"] .stMarkdown,
43
+ [data-testid="stSidebar"] .stText,
44
+ [data-testid="stSidebar"] .stHeader {
45
+ color: #E0E0E0;
46
+ }
47
+ /* Change default input box background/text in dark mode */
48
+ .stTextInput > div > div > input {
49
+ background-color: #2A2A2A;
50
+ color: #E0E0E0;
51
+ border: 1px solid #444444;
52
+ }
53
+ /* Button styling */
54
+ .stButton > button {
55
+ background-color: #0078D7;
56
+ color: #FFFFFF;
57
+ border: none;
58
+ }
59
+ .stButton > button:hover {
60
+ background-color: #005FA1;
61
+ color: #FFFFFF;
62
  }
63
  /* Style for the title */
64
  .app-title {
65
  font-size: 2.5rem;
66
+ color: #BB86FC;
67
  font-weight: 700;
68
  margin-bottom: 0.2rem;
69
  }
70
  /* Style for the subtitle/description */
71
  .app-subtitle {
72
  font-size: 1.1rem;
73
+ color: #CCCCCC;
74
  margin-bottom: 1.5rem;
75
  }
76
+ /* Card container styling (dark card) */
77
  .news-card {
78
+ background-color: #1F1F1F;
79
  border-radius: 10px;
80
  padding: 1rem;
81
  margin-bottom: 1.5rem;
82
+ box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5);
83
  }
84
+ /* Header style inside each card (slightly lighter than card) */
85
  .news-header {
86
+ background-color: #272727;
87
  border-radius: 8px;
88
  padding: 0.5rem 1rem;
89
  margin-bottom: 0.8rem;
90
  }
91
  .news-header h4 {
92
  margin: 0;
93
+ color: #BB86FC;
94
  }
95
  /* Article title style */
96
  .article-title {
97
  font-size: 1.2rem;
98
  font-weight: 600;
99
+ color: #FFFFFF;
100
  margin-bottom: 0.5rem;
101
  }
102
  /* Summary text style */
103
  .article-summary {
104
  font-size: 1rem;
105
+ color: #CCCCCC;
106
  margin-bottom: 0.7rem;
107
  }
108
  /* “Read more” link style */
109
  .read-link {
110
  font-size: 0.95rem;
111
+ color: #BB86FC;
112
  text-decoration: none;
113
  font-weight: 500;
114
  }
115
  .read-link:hover {
116
  text-decoration: underline;
117
  }
118
+ /* Spinner/loading text background override */
119
  .stSpinner > div {
120
+ background-color: #1F1F1F !important;
121
+ }
122
+ /* Footer styling */
123
+ .footer-text {
124
+ text-align: center;
125
+ font-size: 0.9rem;
126
+ color: #888888;
127
+ padding-top: 1rem;
128
  }
129
  </style>
130
  """,
 
137
  st.markdown("## ℹ️ About This App")
138
  st.markdown(
139
  """
140
+ - Enter any **topic**, **company name**, or **keywords** above and click **Get News**.
141
+ - This app will fetch up to 3 articles from **NewsAPI** and 2 from **Serper**, then summarize them using AWS Bedrock (Claude).
142
+ - You need valid `NEWS_API_KEY`, `SERPER_API_KEY`, and AWS credentials / region configured.
143
  """
144
  )
145
  st.markdown("---")
 
163
 
164
  # ─────────────────────────────────────────────────────���─────────────────────────
165
  # Main Title / Header
166
+ st.markdown('<div class="app-title">📰 News Summarizer Agent (Dark Mode)</div>', unsafe_allow_html=True)
167
  st.markdown(
168
  '<div class="app-subtitle">Get the top 5 latest news with concise summaries on any topic or company you choose.</div>',
169
  unsafe_allow_html=True
 
248
  if btn and query:
249
  st.info(f"🔍 Searching for news on <b>{query}</b>...", unsafe_allow_html=True)
250
 
251
+ # Fetch articles
252
  newsapi_articles = get_newsapi_articles(query)
253
  serper_articles = get_serper_articles(query)
254
 
 
295
  # Footer (optional)
296
  st.markdown(
297
  """
298
+ <hr style="border-color: #333333; margin-top: 2rem;">
299
+ <div class="footer-text">
300
  Built with ❤️ using Streamlit • Data sources: NewsAPI.org, Serper.dev • Summarization via AWS Bedrock Claude
301
  </div>
302
  """,