Spaces:
Runtime error
Runtime error
Add markdown2html
Browse files- app.py +8 -1
- requirements.txt +2 -1
app.py
CHANGED
@@ -12,6 +12,10 @@ from api_calls import *
|
|
12 |
ROOT_DIR = Path(__file__).resolve().parents[0]
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
15 |
def export_to_txt(output):
|
16 |
today_dt_str = arrow.now(tz="Asia/Taipei").format("YYYYMMDDTHHmmss")
|
17 |
with open(f"esg_report_summary-{today_dt_str}.txt", "w") as f:
|
@@ -106,6 +110,7 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
106 |
interactive=False,
|
107 |
scale=4,
|
108 |
)
|
|
|
109 |
esgsumm_download_btn = gr.Button("Export Summary")
|
110 |
esgsumm_download_file = gr.File(
|
111 |
label="Download Summary Text", file_types=[".txt"]
|
@@ -158,7 +163,9 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome(neutral_hue="green", primary_
|
|
158 |
|
159 |
# esgsumm
|
160 |
esgsumm_report_gen_button.click(
|
161 |
-
esgsumm_exe, [esgsumm_openai_model_name, esgsumm_year, esgsumm_company_name, esgsumm_report_tone], esgsumm_report_output
|
|
|
|
|
162 |
)
|
163 |
esgsumm_download_btn.click(
|
164 |
fn=export_to_txt,
|
|
|
12 |
ROOT_DIR = Path(__file__).resolve().parents[0]
|
13 |
|
14 |
|
15 |
+
def markdown2html(md: str) -> str:
|
16 |
+
import markdown
|
17 |
+
return markdown.markdown(md)
|
18 |
+
|
19 |
def export_to_txt(output):
|
20 |
today_dt_str = arrow.now(tz="Asia/Taipei").format("YYYYMMDDTHHmmss")
|
21 |
with open(f"esg_report_summary-{today_dt_str}.txt", "w") as f:
|
|
|
110 |
interactive=False,
|
111 |
scale=4,
|
112 |
)
|
113 |
+
esgsumm_report_output_html = gr.HTML()
|
114 |
esgsumm_download_btn = gr.Button("Export Summary")
|
115 |
esgsumm_download_file = gr.File(
|
116 |
label="Download Summary Text", file_types=[".txt"]
|
|
|
163 |
|
164 |
# esgsumm
|
165 |
esgsumm_report_gen_button.click(
|
166 |
+
esgsumm_exe, [esgsumm_openai_model_name, esgsumm_year, esgsumm_company_name, esgsumm_report_tone], [esgsumm_report_output]
|
167 |
+
).then(
|
168 |
+
markdown2html, [esgsumm_report_output], [esgsumm_report_output_html]
|
169 |
)
|
170 |
esgsumm_download_btn.click(
|
171 |
fn=export_to_txt,
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
arrow
|
2 |
pandas
|
3 |
-
requests
|
|
|
|
1 |
arrow
|
2 |
pandas
|
3 |
+
requests
|
4 |
+
markdown
|