Spaces:
Sleeping
Sleeping
Add downloadable template files for File Upload Mode
Browse files- Create CSV template with 20 example test messages (exports/template_test_messages.csv)
- Add gr.DownloadButton for CSV template download
- Add gr.DownloadButton for XLSX template generation and download
- Template includes examples of green, yellow, and red classifications
- Users can now easily download templates to understand the required format
exports/template_test_messages.csv
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
message,expected_classification
|
| 2 |
+
"I feel hopeless and don't see any point in living anymore",red
|
| 3 |
+
"I've been having thoughts about ending my life",red
|
| 4 |
+
"Nobody would miss me if I was gone",red
|
| 5 |
+
"I can't go on like this anymore",red
|
| 6 |
+
"I'm feeling stressed about work lately",yellow
|
| 7 |
+
"I've been having trouble sleeping and feel anxious",yellow
|
| 8 |
+
"I'm not sure what to believe anymore about my faith",yellow
|
| 9 |
+
"I feel disconnected from my spiritual community",yellow
|
| 10 |
+
"I'm worried about my upcoming surgery",yellow
|
| 11 |
+
"Thank you for your help today, I really appreciate it",green
|
| 12 |
+
"I'm feeling much better after our last conversation",green
|
| 13 |
+
"My family has been very supportive during my recovery",green
|
| 14 |
+
"I'm looking forward to getting back to my normal routine",green
|
| 15 |
+
"The medication seems to be working well",green
|
| 16 |
+
"I've been feeling overwhelmed with everything going on",yellow
|
| 17 |
+
"Sometimes I wonder if there's any meaning to all this suffering",yellow
|
| 18 |
+
"I miss my spouse who passed away last year",yellow
|
| 19 |
+
"I feel so alone in the hospital",yellow
|
| 20 |
+
"Everything feels pointless right now",red
|
| 21 |
+
"I just want the pain to stop",red
|
src/interface/file_upload_interface.py
CHANGED
|
@@ -617,8 +617,27 @@ def create_file_upload_interface() -> gr.Blocks:
|
|
| 617 |
gr.Markdown("Download template files to see the required format:")
|
| 618 |
|
| 619 |
with gr.Column():
|
| 620 |
-
|
| 621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 622 |
|
| 623 |
gr.Markdown("### π Format Requirements")
|
| 624 |
gr.Markdown("""
|
|
|
|
| 617 |
gr.Markdown("Download template files to see the required format:")
|
| 618 |
|
| 619 |
with gr.Column():
|
| 620 |
+
# Use DownloadButton for direct file download
|
| 621 |
+
download_csv_template_btn = gr.DownloadButton(
|
| 622 |
+
"π Download CSV Template",
|
| 623 |
+
value="exports/template_test_messages.csv",
|
| 624 |
+
size="sm"
|
| 625 |
+
)
|
| 626 |
+
|
| 627 |
+
# Generate XLSX template on demand
|
| 628 |
+
def generate_xlsx_template_file():
|
| 629 |
+
"""Generate XLSX template and return file path."""
|
| 630 |
+
xlsx_content = controller.file_processor.generate_xlsx_template()
|
| 631 |
+
temp_path = os.path.join(tempfile.gettempdir(), "template_test_messages.xlsx")
|
| 632 |
+
with open(temp_path, "wb") as f:
|
| 633 |
+
f.write(xlsx_content)
|
| 634 |
+
return temp_path
|
| 635 |
+
|
| 636 |
+
download_xlsx_template_btn = gr.DownloadButton(
|
| 637 |
+
"π Download XLSX Template",
|
| 638 |
+
value=generate_xlsx_template_file,
|
| 639 |
+
size="sm"
|
| 640 |
+
)
|
| 641 |
|
| 642 |
gr.Markdown("### π Format Requirements")
|
| 643 |
gr.Markdown("""
|