Update app.py
Browse files
app.py
CHANGED
@@ -376,7 +376,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
376 |
gr.Markdown("๊ฒ์์ด๋ฅผ ์
๋ ฅํ๋ฉด 67๊ฐ๊ตญ์ 24์๊ฐ ์ด๋ด ๋ด์ค๋ฅผ ์ต๋ 1000๊ฐ ์ถ๋ ฅํฉ๋๋ค.")
|
377 |
|
378 |
with gr.Column():
|
379 |
-
|
380 |
with gr.Column(elem_id="status_area"):
|
381 |
with gr.Row():
|
382 |
query_global = gr.Textbox(label="๊ฒ์์ด")
|
@@ -384,9 +384,8 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
384 |
|
385 |
status_message_global = gr.Markdown("")
|
386 |
translated_query_display_global = gr.Markdown("")
|
387 |
-
progress_global = gr.Progress(track_tqdm=True)
|
388 |
|
389 |
-
|
390 |
with gr.Column(elem_id="results_area"):
|
391 |
articles_state_global = gr.State([])
|
392 |
|
@@ -407,7 +406,6 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
407 |
'index': i,
|
408 |
})
|
409 |
|
410 |
-
|
411 |
def search_and_display(query, country, articles_state, progress=gr.Progress()):
|
412 |
status_msg = "๊ฒ์์ ์งํ์ค์
๋๋ค. ์ ์๋ง ๊ธฐ๋ค๋ฆฌ์ธ์..."
|
413 |
|
@@ -463,13 +461,13 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
463 |
|
464 |
return outputs
|
465 |
|
466 |
-
def search_global(query, articles_state_global
|
467 |
-
status_msg = "์ ์ธ๊ณ ๊ฒ์์
|
468 |
all_results = []
|
469 |
|
470 |
outputs = [
|
471 |
gr.update(value=status_msg, visible=True),
|
472 |
-
gr.update(value="", visible=
|
473 |
]
|
474 |
|
475 |
for _ in global_article_components:
|
@@ -481,10 +479,13 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
481 |
|
482 |
yield outputs
|
483 |
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
try:
|
|
|
|
|
|
|
|
|
488 |
error_message, articles = serphouse_search(query, country)
|
489 |
if not error_message and articles:
|
490 |
for article in articles:
|
@@ -503,12 +504,10 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
503 |
|
504 |
unique_results = unique_results[:1000]
|
505 |
|
506 |
-
outputs = [
|
507 |
-
|
508 |
-
value=f"
|
509 |
-
|
510 |
-
))
|
511 |
-
outputs.append(gr.update(value=f"**๊ฒ์์ด:** {query}", visible=True))
|
512 |
|
513 |
for idx, comp in enumerate(global_article_components):
|
514 |
if idx < len(unique_results):
|
@@ -562,12 +561,11 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
562 |
show_progress=True
|
563 |
)
|
564 |
|
565 |
-
# global_search_outputs ๋ถ๋ถ์ ๋ค์๊ณผ ๊ฐ์ด ์์
|
566 |
global_search_outputs = [
|
567 |
status_message_global,
|
568 |
-
translated_query_display_global,
|
569 |
]
|
570 |
-
|
571 |
for comp in global_article_components:
|
572 |
global_search_outputs.extend([
|
573 |
comp['group'], comp['title'], comp['image'],
|
@@ -578,8 +576,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
578 |
search_button_global.click(
|
579 |
search_global,
|
580 |
inputs=[query_global, articles_state_global],
|
581 |
-
outputs=global_search_outputs
|
582 |
-
show_progress=True
|
583 |
)
|
584 |
|
585 |
iface.launch(auth=("it1","chosun1"))
|
|
|
376 |
gr.Markdown("๊ฒ์์ด๋ฅผ ์
๋ ฅํ๋ฉด 67๊ฐ๊ตญ์ 24์๊ฐ ์ด๋ด ๋ด์ค๋ฅผ ์ต๋ 1000๊ฐ ์ถ๋ ฅํฉ๋๋ค.")
|
377 |
|
378 |
with gr.Column():
|
379 |
+
# ์๋จ ์์ญ
|
380 |
with gr.Column(elem_id="status_area"):
|
381 |
with gr.Row():
|
382 |
query_global = gr.Textbox(label="๊ฒ์์ด")
|
|
|
384 |
|
385 |
status_message_global = gr.Markdown("")
|
386 |
translated_query_display_global = gr.Markdown("")
|
|
|
387 |
|
388 |
+
# ๊ฒฐ๊ณผ ์ถ๋ ฅ ์์ญ
|
389 |
with gr.Column(elem_id="results_area"):
|
390 |
articles_state_global = gr.State([])
|
391 |
|
|
|
406 |
'index': i,
|
407 |
})
|
408 |
|
|
|
409 |
def search_and_display(query, country, articles_state, progress=gr.Progress()):
|
410 |
status_msg = "๊ฒ์์ ์งํ์ค์
๋๋ค. ์ ์๋ง ๊ธฐ๋ค๋ฆฌ์ธ์..."
|
411 |
|
|
|
461 |
|
462 |
return outputs
|
463 |
|
464 |
+
def search_global(query, articles_state_global):
|
465 |
+
status_msg = "์ ์ธ๊ณ ๊ฒ์์ ์์ํฉ๋๋ค..."
|
466 |
all_results = []
|
467 |
|
468 |
outputs = [
|
469 |
gr.update(value=status_msg, visible=True),
|
470 |
+
gr.update(value=f"**๊ฒ์์ด:** {query}", visible=True),
|
471 |
]
|
472 |
|
473 |
for _ in global_article_components:
|
|
|
479 |
|
480 |
yield outputs
|
481 |
|
482 |
+
total_countries = len(COUNTRY_LOCATIONS)
|
483 |
+
for idx, (country, location) in enumerate(COUNTRY_LOCATIONS.items(), 1):
|
|
|
484 |
try:
|
485 |
+
status_msg = f"{country} ๊ฒ์ ์ค... ({idx}/{total_countries} ๊ตญ๊ฐ)"
|
486 |
+
outputs[0] = gr.update(value=status_msg, visible=True)
|
487 |
+
yield outputs
|
488 |
+
|
489 |
error_message, articles = serphouse_search(query, country)
|
490 |
if not error_message and articles:
|
491 |
for article in articles:
|
|
|
504 |
|
505 |
unique_results = unique_results[:1000]
|
506 |
|
507 |
+
outputs = [
|
508 |
+
gr.update(value=f"{idx}/{total_countries} ๊ตญ๊ฐ ๊ฒ์ ์๋ฃ\nํ์ฌ๊น์ง ๋ฐ๊ฒฌ๋ ๋ด์ค: {len(unique_results)}๊ฑด", visible=True),
|
509 |
+
gr.update(value=f"**๊ฒ์์ด:** {query}", visible=True),
|
510 |
+
]
|
|
|
|
|
511 |
|
512 |
for idx, comp in enumerate(global_article_components):
|
513 |
if idx < len(unique_results):
|
|
|
561 |
show_progress=True
|
562 |
)
|
563 |
|
|
|
564 |
global_search_outputs = [
|
565 |
status_message_global,
|
566 |
+
translated_query_display_global,
|
567 |
]
|
568 |
+
|
569 |
for comp in global_article_components:
|
570 |
global_search_outputs.extend([
|
571 |
comp['group'], comp['title'], comp['image'],
|
|
|
576 |
search_button_global.click(
|
577 |
search_global,
|
578 |
inputs=[query_global, articles_state_global],
|
579 |
+
outputs=global_search_outputs
|
|
|
580 |
)
|
581 |
|
582 |
iface.launch(auth=("it1","chosun1"))
|