Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -246,13 +246,25 @@ def get_personalized_summary(name, progress=gr.Progress()):
|
|
246 |
progress(1.0, desc="Done!")
|
247 |
return "\n".join(summaries)
|
248 |
|
249 |
-
# Gradio interface
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
with gr.Tab("Set Preferences"):
|
254 |
name_input = gr.Textbox(label="Your Name")
|
255 |
-
|
256 |
interests_checkboxes = gr.CheckboxGroup(
|
257 |
choices=list(NEWS_SOURCES.keys()),
|
258 |
label="News Interests (Select multiple)"
|
@@ -260,8 +272,8 @@ with gr.Blocks(title="Enhanced News Summarizer") as demo:
|
|
260 |
save_button = gr.Button("Save Preferences")
|
261 |
preferences_output = gr.Textbox(label="Status")
|
262 |
|
263 |
-
def save_preferences(name,
|
264 |
-
if not name or not
|
265 |
return "Please fill in all required fields!"
|
266 |
|
267 |
preferences = {
|
@@ -281,16 +293,16 @@ with gr.Blocks(title="Enhanced News Summarizer") as demo:
|
|
281 |
|
282 |
save_button.click(
|
283 |
save_preferences,
|
284 |
-
inputs=[name_input,
|
285 |
outputs=[preferences_output]
|
286 |
)
|
287 |
|
288 |
with gr.Tab("Get News Summary"):
|
289 |
name_check = gr.Textbox(label="Enter your name to get summary")
|
290 |
get_summary_button = gr.Button("Get Summary")
|
291 |
-
summary_output = gr.
|
292 |
-
|
293 |
-
|
294 |
)
|
295 |
|
296 |
get_summary_button.click(
|
@@ -312,3 +324,11 @@ if __name__ == "__main__":
|
|
312 |
|
313 |
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
progress(1.0, desc="Done!")
|
247 |
return "\n".join(summaries)
|
248 |
|
249 |
+
# Gradio interface with custom CSS
|
250 |
+
demo = gr.Blocks(
|
251 |
+
title="News Summarizer",
|
252 |
+
css="""
|
253 |
+
.summary-output {
|
254 |
+
height: 500px;
|
255 |
+
overflow-y: auto;
|
256 |
+
background-color: #f0f0f0;
|
257 |
+
padding: 10px;
|
258 |
+
border-radius: 5px;
|
259 |
+
}
|
260 |
+
"""
|
261 |
+
)
|
262 |
+
|
263 |
+
with demo:
|
264 |
+
gr.Markdown("# 📰 AI News Summarizer")
|
265 |
|
266 |
with gr.Tab("Set Preferences"):
|
267 |
name_input = gr.Textbox(label="Your Name")
|
|
|
268 |
interests_checkboxes = gr.CheckboxGroup(
|
269 |
choices=list(NEWS_SOURCES.keys()),
|
270 |
label="News Interests (Select multiple)"
|
|
|
272 |
save_button = gr.Button("Save Preferences")
|
273 |
preferences_output = gr.Textbox(label="Status")
|
274 |
|
275 |
+
def save_preferences(name, interests):
|
276 |
+
if not name or not interests:
|
277 |
return "Please fill in all required fields!"
|
278 |
|
279 |
preferences = {
|
|
|
293 |
|
294 |
save_button.click(
|
295 |
save_preferences,
|
296 |
+
inputs=[name_input, interests_checkboxes],
|
297 |
outputs=[preferences_output]
|
298 |
)
|
299 |
|
300 |
with gr.Tab("Get News Summary"):
|
301 |
name_check = gr.Textbox(label="Enter your name to get summary")
|
302 |
get_summary_button = gr.Button("Get Summary")
|
303 |
+
summary_output = gr.Markdown(
|
304 |
+
value="Waiting for summary...",
|
305 |
+
elem_classes=["summary-output"]
|
306 |
)
|
307 |
|
308 |
get_summary_button.click(
|
|
|
324 |
|
325 |
|
326 |
|
327 |
+
|
328 |
+
|
329 |
+
|
330 |
+
|
331 |
+
|
332 |
+
|
333 |
+
|
334 |
+
|