Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -246,17 +246,17 @@ def get_personalized_summary(name, progress=gr.Progress()):
|
|
246 |
progress(1.0, desc="Done!")
|
247 |
return "\n".join(summaries)
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
)
|
254 |
-
|
255 |
-
with demo:
|
256 |
-
gr.Markdown("# 📰 AI News Summarizer")
|
257 |
|
258 |
with gr.Tab("Set Preferences"):
|
259 |
name_input = gr.Textbox(label="Your Name")
|
|
|
|
|
|
|
|
|
|
|
260 |
interests_checkboxes = gr.CheckboxGroup(
|
261 |
choices=list(NEWS_SOURCES.keys()),
|
262 |
label="News Interests (Select multiple)"
|
@@ -264,12 +264,13 @@ with demo:
|
|
264 |
save_button = gr.Button("Save Preferences")
|
265 |
preferences_output = gr.Textbox(label="Status")
|
266 |
|
267 |
-
def save_preferences(name, interests):
|
268 |
-
if not name or not interests:
|
269 |
return "Please fill in all required fields!"
|
270 |
|
271 |
preferences = {
|
272 |
"name": name,
|
|
|
273 |
"interests": interests,
|
274 |
"last_updated": datetime.now().isoformat()
|
275 |
}
|
@@ -285,16 +286,16 @@ with demo:
|
|
285 |
|
286 |
save_button.click(
|
287 |
save_preferences,
|
288 |
-
inputs=[name_input, interests_checkboxes],
|
289 |
outputs=[preferences_output]
|
290 |
)
|
291 |
|
292 |
with gr.Tab("Get News Summary"):
|
293 |
name_check = gr.Textbox(label="Enter your name to get summary")
|
294 |
get_summary_button = gr.Button("Get Summary")
|
295 |
-
summary_output = gr.
|
296 |
-
|
297 |
-
|
298 |
)
|
299 |
|
300 |
get_summary_button.click(
|
|
|
246 |
progress(1.0, desc="Done!")
|
247 |
return "\n".join(summaries)
|
248 |
|
249 |
+
# Gradio interface
|
250 |
+
with gr.Blocks(title="Enhanced News Summarizer") as demo:
|
251 |
+
gr.Markdown("# 📰 Enhanced AI News Summarizer")
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
with gr.Tab("Set Preferences"):
|
254 |
name_input = gr.Textbox(label="Your Name")
|
255 |
+
language_dropdown = gr.Dropdown(
|
256 |
+
choices=list(LANGUAGE_CODES.keys()),
|
257 |
+
label="Preferred Language",
|
258 |
+
value="English"
|
259 |
+
)
|
260 |
interests_checkboxes = gr.CheckboxGroup(
|
261 |
choices=list(NEWS_SOURCES.keys()),
|
262 |
label="News Interests (Select multiple)"
|
|
|
264 |
save_button = gr.Button("Save Preferences")
|
265 |
preferences_output = gr.Textbox(label="Status")
|
266 |
|
267 |
+
def save_preferences(name, language, interests):
|
268 |
+
if not name or not language or not interests:
|
269 |
return "Please fill in all required fields!"
|
270 |
|
271 |
preferences = {
|
272 |
"name": name,
|
273 |
+
"language": language,
|
274 |
"interests": interests,
|
275 |
"last_updated": datetime.now().isoformat()
|
276 |
}
|
|
|
286 |
|
287 |
save_button.click(
|
288 |
save_preferences,
|
289 |
+
inputs=[name_input, language_dropdown, interests_checkboxes],
|
290 |
outputs=[preferences_output]
|
291 |
)
|
292 |
|
293 |
with gr.Tab("Get News Summary"):
|
294 |
name_check = gr.Textbox(label="Enter your name to get summary")
|
295 |
get_summary_button = gr.Button("Get Summary")
|
296 |
+
summary_output = gr.Textbox(
|
297 |
+
label="Your Personalized News Summary",
|
298 |
+
lines=20
|
299 |
)
|
300 |
|
301 |
get_summary_button.click(
|