openfree commited on
Commit
ee898d1
ยท
verified ยท
1 Parent(s): 98c0e57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -20
app.py CHANGED
@@ -601,16 +601,30 @@ def generate_report(title, info, progress=gr.Progress()):
601
 
602
  progress(1.0, desc="์™„๋ฃŒ!")
603
 
604
- return response, gr.update(visible=True)
605
-
 
 
 
 
 
 
 
 
 
606
  except Exception as e:
607
  print(f"Report generation error: {str(e)}")
608
- return "๋ฆฌํฌํŒ… ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.", gr.update(visible=True)
 
 
 
609
 
610
- def toggle_report(report_content):
611
  """๋ฆฌํฌํŠธ ํ‘œ์‹œ/์ˆจ๊น€ ํ† ๊ธ€"""
612
- is_visible = report_content.visible
613
- return gr.update(visible=not is_visible)
 
 
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=[comp['report_content']],
985
- outputs=[comp['report_content']]
 
 
 
 
 
 
986
  )
987
-
988
- hn_outputs = [status_message_hn]
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,