Hyeonseo commited on
Commit
370b54b
β€’
1 Parent(s): 462b854

feat: add update news data (button)

Browse files

- UI: λ‰΄μŠ€ 데이터 μ—…λ°μ΄νŠΈ λ²„νŠΌ(update_button) μΆ”κ°€
- Event: update_button 클릭 이벀트 -> update_news_data() μ‹€ν–‰ν•˜λ„λ‘ μ„€μ •
* 졜근 λ‰΄μŠ€ λ°μ΄ν„°λ‘œ μ—…λ°μ΄νŠΈλœ μƒνƒœμ—μ„œ λ‹€μ‹œ 클릭 -> 같은 λ‰΄μŠ€ 데이터λ₯Ό λΆˆλŸ¬μ™€μ„œ λ‚΄μš©μ΄ 동일할 수 μžˆμŠ΅λ‹ˆλ‹€.

Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -66,13 +66,14 @@ class news_collector:
66
 
67
 
68
 
69
- def collect_news():
70
- news = news_collector()
71
- news.update_news_examples()
72
- return news.examples_text
73
-
74
-
75
 
 
 
 
 
 
 
76
 
77
  title = "κ· ν˜•μž‘νžŒ λ‰΄μŠ€ 읽기 (Balanced News Reading)"
78
 
@@ -102,9 +103,12 @@ with gr.Blocks(theme='pseudolab/huggingface-korea-theme') as demo:
102
  gr.load("models/gabrielyang/finance_news_classifier-KR_v7",
103
  inputs = Link_TXT)
104
  Link_URL = gr.Textbox(label="λ‰΄μŠ€ URL")
105
-
 
 
 
106
  gr.Examples(
107
- collect_news(),
108
  [Link_TXT, Link_URL],
109
  )
110
 
 
66
 
67
 
68
 
69
+ news_data = []
 
 
 
 
 
70
 
71
+ def update_news_data():
72
+ global news_data
73
+ news_data = news_collector().update_news_examples()
74
+ print("λ‰΄μŠ€ 데이터 μ—…λ°μ΄νŠΈ μ™„λ£Œ")
75
+
76
+ update_news_data()
77
 
78
  title = "κ· ν˜•μž‘νžŒ λ‰΄μŠ€ 읽기 (Balanced News Reading)"
79
 
 
103
  gr.load("models/gabrielyang/finance_news_classifier-KR_v7",
104
  inputs = Link_TXT)
105
  Link_URL = gr.Textbox(label="λ‰΄μŠ€ URL")
106
+
107
+ update_button = gr.Button(value="λ‰΄μŠ€ 데이터 μ—…λ°μ΄νŠΈ")
108
+ update_button.click(fn=update_news_data, inputs=None, outputs=None)
109
+
110
  gr.Examples(
111
+ news_data,
112
  [Link_TXT, Link_URL],
113
  )
114