gabrielyang Hyeonseo commited on
Commit
1780316
1 Parent(s): 836aaa3

feat: add update news data (button) (#5)

Browse files

- feat: add update news data (button) (370b54b6cf0450592b6155cfd3c505d89b412ade)


Co-authored-by: Hyeonseo Yun <Hyeonseo@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -78,13 +78,14 @@ class news_collector:
78
 
79
 
80
 
81
- def collect_news():
82
- news = news_collector()
83
- news.update_news_examples()
84
- return news.examples_text
85
-
86
-
87
 
 
 
 
 
 
 
88
 
89
  title = "균형잡힌 뉴스 읽기 (Balanced News Reading)"
90
 
@@ -115,9 +116,12 @@ with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
115
  # gr.load("models/Hyeonseo/ko-finance_news_classifier",
116
  inputs = Link_TXT)
117
  Link_URL = gr.Textbox(label="뉴스 URL")
118
-
 
 
 
119
  gr.Examples(
120
- collect_news(),
121
  [Link_TXT, Link_URL],
122
  )
123
 
 
78
 
79
 
80
 
81
+ news_data = []
 
 
 
 
 
82
 
83
+ def update_news_data():
84
+ global news_data
85
+ news_data = news_collector().update_news_examples()
86
+ print("뉴스 데이터 업데이트 완료")
87
+
88
+ update_news_data()
89
 
90
  title = "균형잡힌 뉴스 읽기 (Balanced News Reading)"
91
 
 
116
  # gr.load("models/Hyeonseo/ko-finance_news_classifier",
117
  inputs = Link_TXT)
118
  Link_URL = gr.Textbox(label="뉴스 URL")
119
+
120
+ update_button = gr.Button(value="뉴스 데이터 업데이트")
121
+ update_button.click(fn=update_news_data, inputs=None, outputs=None)
122
+
123
  gr.Examples(
124
+ news_data,
125
  [Link_TXT, Link_URL],
126
  )
127