seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -289,7 +289,6 @@ css = """
|
|
289 |
footer {visibility: hidden;}
|
290 |
"""
|
291 |
|
292 |
-
# Gradio μΈν°νμ΄μ€ μμ
|
293 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as iface:
|
294 |
gr.Markdown("κ²μμ΄λ₯Ό μ
λ ₯νκ³ μνλ κ΅κ°(67κ°κ΅)λ₯Ό μ ννλ©΄, κ²μμ΄μ μΌμΉνλ 24μκ° μ΄λ΄ λ΄μ€λ₯Ό μ΅λ 100κ° μΆλ ₯ν©λλ€.")
|
295 |
gr.Markdown("κ΅κ° μ νν κ²μμ΄μ 'νκΈ'μ μ
λ ₯νλ©΄ νμ§ μΈμ΄λ‘ λ²μλμ΄ κ²μν©λλ€. μ: 'Taiwan' κ΅κ° μ νν 'μΌμ±' μ
λ ₯μ 'δΈζ'μΌλ‘ μλ κ²μ ")
|
@@ -299,7 +298,10 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as
|
|
299 |
query = gr.Textbox(label="κ²μμ΄")
|
300 |
country = gr.Dropdown(MAJOR_COUNTRIES, label="κ΅κ°", value="South Korea")
|
301 |
|
302 |
-
#
|
|
|
|
|
|
|
303 |
translated_query_display = gr.Markdown(visible=False)
|
304 |
|
305 |
search_button = gr.Button("κ²μ", variant="primary")
|
@@ -326,6 +328,9 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as
|
|
326 |
})
|
327 |
|
328 |
def search_and_display(query, country, articles_state, progress=gr.Progress()):
|
|
|
|
|
|
|
329 |
progress(0, desc="κ²μμ΄ λ²μ μ€...")
|
330 |
|
331 |
# κ²μμ΄ λ²μ
|
@@ -336,7 +341,10 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as
|
|
336 |
error_message, articles = serphouse_search(query, country)
|
337 |
progress(0.5, desc="κ²°κ³Ό μ²λ¦¬ μ€...")
|
338 |
|
339 |
-
outputs = [
|
|
|
|
|
|
|
340 |
|
341 |
if error_message:
|
342 |
outputs.append(gr.update(value=error_message, visible=True))
|
@@ -373,9 +381,18 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as
|
|
373 |
progress(1.0, desc="μλ£!")
|
374 |
outputs.append(articles_state)
|
375 |
outputs.append(gr.update(visible=False))
|
|
|
|
|
|
|
|
|
|
|
376 |
return outputs
|
377 |
|
378 |
-
search_outputs = [
|
|
|
|
|
|
|
|
|
379 |
for comp in article_components:
|
380 |
search_outputs.extend([comp['group'], comp['title'], comp['image'],
|
381 |
comp['snippet'], comp['info']])
|
|
|
289 |
footer {visibility: hidden;}
|
290 |
"""
|
291 |
|
|
|
292 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μλΉμ€") as iface:
|
293 |
gr.Markdown("κ²μμ΄λ₯Ό μ
λ ₯νκ³ μνλ κ΅κ°(67κ°κ΅)λ₯Ό μ ννλ©΄, κ²μμ΄μ μΌμΉνλ 24μκ° μ΄λ΄ λ΄μ€λ₯Ό μ΅λ 100κ° μΆλ ₯ν©λλ€.")
|
294 |
gr.Markdown("κ΅κ° μ νν κ²μμ΄μ 'νκΈ'μ μ
λ ₯νλ©΄ νμ§ μΈμ΄λ‘ λ²μλμ΄ κ²μν©λλ€. μ: 'Taiwan' κ΅κ° μ νν 'μΌμ±' μ
λ ₯μ 'δΈζ'μΌλ‘ μλ κ²μ ")
|
|
|
298 |
query = gr.Textbox(label="κ²μμ΄")
|
299 |
country = gr.Dropdown(MAJOR_COUNTRIES, label="κ΅κ°", value="South Korea")
|
300 |
|
301 |
+
# κ²μ μν λ©μμ§ μ»΄ν¬λνΈ μΆκ°
|
302 |
+
search_status = gr.Markdown(visible=False)
|
303 |
+
|
304 |
+
# λ²μ κ²°κ³Όλ₯Ό 보μ¬μ£Όλ μ»΄ν¬λνΈ
|
305 |
translated_query_display = gr.Markdown(visible=False)
|
306 |
|
307 |
search_button = gr.Button("κ²μ", variant="primary")
|
|
|
328 |
})
|
329 |
|
330 |
def search_and_display(query, country, articles_state, progress=gr.Progress()):
|
331 |
+
# κ²μ μμ λ©μμ§ νμ
|
332 |
+
search_status_output = gr.update(value="κ²μμ μ§νμ€μ
λλ€. μ μλ§ κΈ°λ€λ¦¬μΈμ...", visible=True)
|
333 |
+
|
334 |
progress(0, desc="κ²μμ΄ λ²μ μ€...")
|
335 |
|
336 |
# κ²μμ΄ λ²μ
|
|
|
341 |
error_message, articles = serphouse_search(query, country)
|
342 |
progress(0.5, desc="κ²°κ³Ό μ²λ¦¬ μ€...")
|
343 |
|
344 |
+
outputs = [
|
345 |
+
search_status_output, # κ²μ μν λ©μμ§
|
346 |
+
gr.update(value=translated_display, visible=True) # λ²μ κ²°κ³Ό νμ
|
347 |
+
]
|
348 |
|
349 |
if error_message:
|
350 |
outputs.append(gr.update(value=error_message, visible=True))
|
|
|
381 |
progress(1.0, desc="μλ£!")
|
382 |
outputs.append(articles_state)
|
383 |
outputs.append(gr.update(visible=False))
|
384 |
+
|
385 |
+
# κ²μ μλ£ ν μν λ©μμ§ μ¨κΉ
|
386 |
+
search_status_output = gr.update(visible=False)
|
387 |
+
outputs[0] = search_status_output
|
388 |
+
|
389 |
return outputs
|
390 |
|
391 |
+
search_outputs = [
|
392 |
+
search_status, # κ²μ μν λ©μμ§ μΆλ ₯ μΆκ°
|
393 |
+
translated_query_display,
|
394 |
+
gr.Markdown(visible=False)
|
395 |
+
]
|
396 |
for comp in article_components:
|
397 |
search_outputs.extend([comp['group'], comp['title'], comp['image'],
|
398 |
comp['snippet'], comp['info']])
|