Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -601,16 +601,30 @@ def generate_report(title, info, progress=gr.Progress()):
|
|
601 |
|
602 |
progress(1.0, desc="์๋ฃ!")
|
603 |
|
604 |
-
|
605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
except Exception as e:
|
607 |
print(f"Report generation error: {str(e)}")
|
608 |
-
return
|
|
|
|
|
|
|
609 |
|
610 |
-
def toggle_report(report_content):
|
611 |
"""๋ฆฌํฌํธ ํ์/์จ๊น ํ ๊ธ"""
|
612 |
-
|
613 |
-
|
|
|
|
|
614 |
|
615 |
css = """
|
616 |
footer {visibility: hidden;}
|
@@ -688,6 +702,26 @@ footer {visibility: hidden;}
|
|
688 |
border-top: 1px solid #eee;
|
689 |
background: #f9f9f9;
|
690 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
"""
|
692 |
|
693 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as iface:
|
@@ -964,7 +998,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
964 |
]
|
965 |
|
966 |
|
967 |
-
# AI ๋ฆฌํฌํฐ
|
968 |
for comp in hn_article_components:
|
969 |
comp['report_button'].click(
|
970 |
fn=generate_report,
|
@@ -981,20 +1015,17 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as
|
|
981 |
|
982 |
comp['show_report'].click(
|
983 |
fn=toggle_report,
|
984 |
-
inputs=[
|
985 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
986 |
)
|
987 |
-
|
988 |
-
|
989 |
-
for comp in hn_article_components:
|
990 |
-
hn_outputs.extend([
|
991 |
-
comp['group'],
|
992 |
-
comp['title'],
|
993 |
-
comp['info'],
|
994 |
-
comp['report_button'],
|
995 |
-
comp['report_content'],
|
996 |
-
comp['show_report']
|
997 |
-
])
|
998 |
|
999 |
refresh_button.click(
|
1000 |
fn=refresh_hn_stories,
|
|
|
601 |
|
602 |
progress(1.0, desc="์๋ฃ!")
|
603 |
|
604 |
+
if response:
|
605 |
+
return [
|
606 |
+
gr.update(value=response, visible=True), # report_content
|
607 |
+
gr.update(value="์ ๊ธฐ", visible=True) # show_report
|
608 |
+
]
|
609 |
+
else:
|
610 |
+
return [
|
611 |
+
gr.update(value="๋ฆฌํฌํ
์์ฑ์ ์คํจํ์ต๋๋ค.", visible=True),
|
612 |
+
gr.update(value="์ ๊ธฐ", visible=True)
|
613 |
+
]
|
614 |
+
|
615 |
except Exception as e:
|
616 |
print(f"Report generation error: {str(e)}")
|
617 |
+
return [
|
618 |
+
gr.update(value="๋ฆฌํฌํ
์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.", visible=True),
|
619 |
+
gr.update(value="์ ๊ธฐ", visible=True)
|
620 |
+
]
|
621 |
|
622 |
+
def toggle_report(report_content, show_report):
|
623 |
"""๋ฆฌํฌํธ ํ์/์จ๊น ํ ๊ธ"""
|
624 |
+
return [
|
625 |
+
gr.update(visible=not show_report.visible), # report_content
|
626 |
+
gr.update(value="์ ๊ธฐ" if not show_report.visible else "ํผ์ณ ๋ณด๊ธฐ") # show_report
|
627 |
+
]
|
628 |
|
629 |
css = """
|
630 |
footer {visibility: hidden;}
|
|
|
702 |
border-top: 1px solid #eee;
|
703 |
background: #f9f9f9;
|
704 |
}
|
705 |
+
|
706 |
+
.progress-bar {
|
707 |
+
position: fixed;
|
708 |
+
top: 0;
|
709 |
+
left: 0;
|
710 |
+
width: 100%;
|
711 |
+
height: 4px;
|
712 |
+
background: #1f77b4;
|
713 |
+
z-index: 1000;
|
714 |
+
}
|
715 |
+
.hn-article-group .report-content {
|
716 |
+
display: none;
|
717 |
+
margin-top: 15px;
|
718 |
+
padding: 15px;
|
719 |
+
border-top: 1px solid #eee;
|
720 |
+
background: #f9f9f9;
|
721 |
+
}
|
722 |
+
.hn-article-group .report-content.visible {
|
723 |
+
display: block;
|
724 |
+
}
|
725 |
"""
|
726 |
|
727 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI ์๋น์ค") as iface:
|
|
|
998 |
]
|
999 |
|
1000 |
|
1001 |
+
# AI ๋ฆฌํฌํฐ ํญ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
1002 |
for comp in hn_article_components:
|
1003 |
comp['report_button'].click(
|
1004 |
fn=generate_report,
|
|
|
1015 |
|
1016 |
comp['show_report'].click(
|
1017 |
fn=toggle_report,
|
1018 |
+
inputs=[
|
1019 |
+
comp['report_content'],
|
1020 |
+
comp['show_report']
|
1021 |
+
],
|
1022 |
+
outputs=[
|
1023 |
+
comp['report_content'],
|
1024 |
+
comp['show_report']
|
1025 |
+
]
|
1026 |
)
|
1027 |
+
|
1028 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1029 |
|
1030 |
refresh_button.click(
|
1031 |
fn=refresh_hn_stories,
|