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