Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ from datetime import datetime
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
LOG_FILE = "/tmp/log.jsonl"
|
| 8 |
-
|
| 9 |
if not os.path.exists(LOG_FILE):
|
| 10 |
with open(LOG_FILE, "w"): pass
|
| 11 |
|
|
@@ -33,7 +32,8 @@ def log_interaction(input_text, prediction):
|
|
| 33 |
def predict_and_log(text):
|
| 34 |
result = model(text)
|
| 35 |
log_interaction(text, result)
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown("## Biomedical Abbreviation Identifier")
|
|
@@ -46,7 +46,7 @@ with gr.Blocks() as demo:
|
|
| 46 |
submit_btn.click(
|
| 47 |
fn=predict_and_log,
|
| 48 |
inputs=input_box,
|
| 49 |
-
outputs=[output_box, download_file]
|
| 50 |
)
|
| 51 |
|
| 52 |
demo.launch()
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
LOG_FILE = "/tmp/log.jsonl"
|
|
|
|
| 8 |
if not os.path.exists(LOG_FILE):
|
| 9 |
with open(LOG_FILE, "w"): pass
|
| 10 |
|
|
|
|
| 32 |
def predict_and_log(text):
|
| 33 |
result = model(text)
|
| 34 |
log_interaction(text, result)
|
| 35 |
+
# Update the file component's value
|
| 36 |
+
return result, download_file.update(value=LOG_FILE) # Note: download_file instance here
|
| 37 |
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown("## Biomedical Abbreviation Identifier")
|
|
|
|
| 46 |
submit_btn.click(
|
| 47 |
fn=predict_and_log,
|
| 48 |
inputs=input_box,
|
| 49 |
+
outputs=[output_box, download_file] # outputs must correspond to returned tuple
|
| 50 |
)
|
| 51 |
|
| 52 |
demo.launch()
|