Spaces:
Runtime error
Runtime error
Adjust layout
Browse files
app.py
CHANGED
@@ -10,8 +10,18 @@ from tqdm import tqdm
|
|
10 |
from api_calls import *
|
11 |
|
12 |
ROOT_DIR = Path(__file__).resolve().parents[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
def markdown2html(md: str) -> str:
|
16 |
import markdown
|
17 |
return markdown.markdown(md)
|
@@ -80,20 +90,25 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
80 |
with gr.Group():
|
81 |
gr.Markdown("### Configuration", elem_id="center")
|
82 |
esgsumm_report_tone = gr.Dropdown(
|
|
|
83 |
label="Tone",
|
84 |
choices=["富有創意", "中庸", "精確"])
|
85 |
esgsumm_openai_model_name = gr.Dropdown(
|
|
|
86 |
label="OpenAI Model",
|
87 |
choices=["gpt-4-turbo-preview", "gpt-3.5-turbo"])
|
88 |
esgsumm_year = gr.Dropdown(
|
|
|
89 |
label="Year",
|
90 |
choices=["111", "110", "109"]
|
91 |
)
|
92 |
esgsumm_target_type = gr.Dropdown(
|
|
|
93 |
label="Target Type",
|
94 |
-
choices=["company_name", "industry"]
|
95 |
)
|
96 |
esgsumm_target_value = gr.Dropdown(
|
|
|
97 |
label="Target Value",
|
98 |
choices=["台泥", "聯電", "裕融", "大同", "台積電", "鴻海", "中鋼", "中華電信"]
|
99 |
)
|
@@ -127,17 +142,21 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
127 |
with gr.Group():
|
128 |
gr.Markdown("### Configuration", elem_id="center")
|
129 |
esgqa_openai_model_name = gr.Dropdown(
|
|
|
130 |
label="OpenAI Model",
|
131 |
choices=["gpt-4-turbo-preview", "gpt-3.5-turbo"])
|
132 |
esgqa_year = gr.Dropdown(
|
|
|
133 |
label="Year",
|
134 |
choices=["111", "110", "109"]
|
135 |
)
|
136 |
esgqa_target_type = gr.Dropdown(
|
|
|
137 |
label="Target Type",
|
138 |
-
choices=["company_name", "industry"]
|
139 |
)
|
140 |
esgqa_target_value = gr.Dropdown(
|
|
|
141 |
label="Target Value",
|
142 |
choices=["台泥", "聯電", "裕融", "大同", "台積電", "鴻海", "中鋼", "中華電信"]
|
143 |
)
|
@@ -170,6 +189,9 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
170 |
|
171 |
|
172 |
# esgsumm
|
|
|
|
|
|
|
173 |
esgsumm_report_gen_button.click(
|
174 |
esgsumm_exe, [esgsumm_openai_model_name, esgsumm_year, esgsumm_target_type, esgsumm_target_value, esgsumm_report_tone], [esgsumm_report_output]
|
175 |
).then(
|
@@ -182,6 +204,9 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
182 |
)
|
183 |
|
184 |
# esgqa
|
|
|
|
|
|
|
185 |
esgqa_chatbot_input.submit(
|
186 |
add_text, [esgqa_chatbot, esgqa_chatbot_input], [esgqa_chatbot, esgqa_chatbot_input], queue=False
|
187 |
).then(
|
|
|
10 |
from api_calls import *
|
11 |
|
12 |
ROOT_DIR = Path(__file__).resolve().parents[0]
|
13 |
+
default_co_ids = ["2330", "2317", "1301", "2303", "1101", "2311", "2002", "2412"]
|
14 |
+
default_company_names = ["台泥", "聯電", "裕融", "大同", "台積電", "鴻海", "中鋼", "中華電信"]
|
15 |
+
default_industries = ["半導體業", "水泥工業", "電子零組件業", "電子通路業", "電腦及週邊設備業", "其他電子業", "金融保險業", "文化創意業", "鋼鐵工業", "通信網路業", "電子商務業"]
|
16 |
+
|
17 |
+
def load_default_filter_data(filter_type):
|
18 |
+
d = {
|
19 |
+
"co_id": default_co_ids,
|
20 |
+
"company_name": default_company_names,
|
21 |
+
"industry": default_industries,
|
22 |
+
}[filter_type]
|
23 |
+
return gr.Dropdown.update(choices=d)
|
24 |
|
|
|
25 |
def markdown2html(md: str) -> str:
|
26 |
import markdown
|
27 |
return markdown.markdown(md)
|
|
|
90 |
with gr.Group():
|
91 |
gr.Markdown("### Configuration", elem_id="center")
|
92 |
esgsumm_report_tone = gr.Dropdown(
|
93 |
+
value="精確",
|
94 |
label="Tone",
|
95 |
choices=["富有創意", "中庸", "精確"])
|
96 |
esgsumm_openai_model_name = gr.Dropdown(
|
97 |
+
value="gpt-4-turbo-preview",
|
98 |
label="OpenAI Model",
|
99 |
choices=["gpt-4-turbo-preview", "gpt-3.5-turbo"])
|
100 |
esgsumm_year = gr.Dropdown(
|
101 |
+
value="111",
|
102 |
label="Year",
|
103 |
choices=["111", "110", "109"]
|
104 |
)
|
105 |
esgsumm_target_type = gr.Dropdown(
|
106 |
+
value="company_name",
|
107 |
label="Target Type",
|
108 |
+
choices=["company_name", "industry", "co_id"]
|
109 |
)
|
110 |
esgsumm_target_value = gr.Dropdown(
|
111 |
+
value="台積電",
|
112 |
label="Target Value",
|
113 |
choices=["台泥", "聯電", "裕融", "大同", "台積電", "鴻海", "中鋼", "中華電信"]
|
114 |
)
|
|
|
142 |
with gr.Group():
|
143 |
gr.Markdown("### Configuration", elem_id="center")
|
144 |
esgqa_openai_model_name = gr.Dropdown(
|
145 |
+
value="gpt-4-turbo-preview",
|
146 |
label="OpenAI Model",
|
147 |
choices=["gpt-4-turbo-preview", "gpt-3.5-turbo"])
|
148 |
esgqa_year = gr.Dropdown(
|
149 |
+
value="111",
|
150 |
label="Year",
|
151 |
choices=["111", "110", "109"]
|
152 |
)
|
153 |
esgqa_target_type = gr.Dropdown(
|
154 |
+
value="company_name",
|
155 |
label="Target Type",
|
156 |
+
choices=["company_name", "industry", "co_id"]
|
157 |
)
|
158 |
esgqa_target_value = gr.Dropdown(
|
159 |
+
value="台積電",
|
160 |
label="Target Value",
|
161 |
choices=["台泥", "聯電", "裕融", "大同", "台積電", "鴻海", "中鋼", "中華電信"]
|
162 |
)
|
|
|
189 |
|
190 |
|
191 |
# esgsumm
|
192 |
+
esgsumm_target_type.change(
|
193 |
+
load_default_filter_data, [esgsumm_target_type], [esgsumm_target_value]
|
194 |
+
)
|
195 |
esgsumm_report_gen_button.click(
|
196 |
esgsumm_exe, [esgsumm_openai_model_name, esgsumm_year, esgsumm_target_type, esgsumm_target_value, esgsumm_report_tone], [esgsumm_report_output]
|
197 |
).then(
|
|
|
204 |
)
|
205 |
|
206 |
# esgqa
|
207 |
+
esgqa_target_type.change(
|
208 |
+
load_default_filter_data, [esgqa_target_type], [esgqa_target_value]
|
209 |
+
)
|
210 |
esgqa_chatbot_input.submit(
|
211 |
add_text, [esgqa_chatbot, esgqa_chatbot_input], [esgqa_chatbot, esgqa_chatbot_input], queue=False
|
212 |
).then(
|