Spaces:
Runtime error
Runtime error
feat: add update news data (button)
Browse files- UI: ๋ด์ค ๋ฐ์ดํฐ ์
๋ฐ์ดํธ ๋ฒํผ(update_button) ์ถ๊ฐ
- Event: update_button ํด๋ฆญ ์ด๋ฒคํธ -> update_news_data() ์คํํ๋๋ก ์ค์
* ์ต๊ทผ ๋ด์ค ๋ฐ์ดํฐ๋ก ์
๋ฐ์ดํธ๋ ์ํ์์ ๋ค์ ํด๋ฆญ -> ๊ฐ์ ๋ด์ค ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์์ ๋ด์ฉ์ด ๋์ผํ ์ ์์ต๋๋ค.
app.py
CHANGED
|
@@ -66,13 +66,14 @@ class news_collector:
|
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
-
|
| 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 |
-
|
| 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 |
|