Update app.py
Browse files
app.py
CHANGED
@@ -802,15 +802,27 @@ def setup_interface():
|
|
802 |
gr.Markdown("Quick mode for faster analysis. Detailed mode for sentence-level analysis.",
|
803 |
elem_classes=["description-text"])
|
804 |
|
805 |
-
#
|
806 |
-
with gr.Row(elem_id="
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
|
813 |
-
#
|
814 |
with gr.Row(elem_id="button-row"):
|
815 |
clear_btn = gr.Button("Clear", elem_id="clear-btn")
|
816 |
analyze_btn = gr.Button("Analyze Text", elem_id="analyze-btn")
|
@@ -821,22 +833,6 @@ def setup_interface():
|
|
821 |
output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
822 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
823 |
|
824 |
-
# Custom file upload area for paperclip
|
825 |
-
gr.HTML("""
|
826 |
-
<div id="paperclip-wrapper">
|
827 |
-
<label for="paperclip-input" id="paperclip-label">π</label>
|
828 |
-
<input type="file" id="paperclip-input" style="display:none;">
|
829 |
-
</div>
|
830 |
-
""")
|
831 |
-
|
832 |
-
# Add hidden file upload that we'll control with custom JS
|
833 |
-
file_upload = gr.File(
|
834 |
-
file_types=["image", "pdf", "doc", "docx"],
|
835 |
-
type="binary",
|
836 |
-
visible=False,
|
837 |
-
elem_id="hidden-file-upload"
|
838 |
-
)
|
839 |
-
|
840 |
# Connect the components
|
841 |
analyze_btn.click(
|
842 |
analyze_text_wrapper,
|
@@ -856,10 +852,10 @@ def setup_interface():
|
|
856 |
outputs=[output_html, output_sentences, output_result]
|
857 |
)
|
858 |
|
859 |
-
# Add custom CSS
|
860 |
gr.HTML("""
|
861 |
<style>
|
862 |
-
/* Button styling
|
863 |
#analyze-btn {
|
864 |
background-color: #FF8C00 !important;
|
865 |
border-color: #FF8C00 !important;
|
@@ -875,29 +871,65 @@ def setup_interface():
|
|
875 |
|
876 |
#button-row {
|
877 |
gap: 10px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
878 |
}
|
879 |
|
880 |
-
|
881 |
-
|
882 |
-
|
|
|
|
|
|
|
|
|
|
|
883 |
}
|
884 |
|
885 |
-
|
886 |
-
|
887 |
-
position: absolute;
|
888 |
-
top: 334px;
|
889 |
-
left: 160px;
|
890 |
-
z-index: 100;
|
891 |
}
|
892 |
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
|
|
|
|
|
|
897 |
}
|
898 |
|
899 |
-
|
900 |
-
|
|
|
|
|
|
|
|
|
901 |
}
|
902 |
|
903 |
/* Description text styling */
|
@@ -908,18 +940,6 @@ def setup_interface():
|
|
908 |
margin-bottom: 5px !important;
|
909 |
}
|
910 |
</style>
|
911 |
-
|
912 |
-
<script>
|
913 |
-
// Connect custom paperclip to the hidden file input
|
914 |
-
document.addEventListener('DOMContentLoaded', function() {
|
915 |
-
const paperclipLabel = document.getElementById('paperclip-label');
|
916 |
-
const hiddenFileInput = document.querySelector('#hidden-file-upload input[type="file"]');
|
917 |
-
|
918 |
-
paperclipLabel.addEventListener('click', function() {
|
919 |
-
hiddenFileInput.click();
|
920 |
-
});
|
921 |
-
});
|
922 |
-
</script>
|
923 |
""")
|
924 |
|
925 |
return demo
|
|
|
802 |
gr.Markdown("Quick mode for faster analysis. Detailed mode for sentence-level analysis.",
|
803 |
elem_classes=["description-text"])
|
804 |
|
805 |
+
# Radio buttons with inline file upload
|
806 |
+
with gr.Row(elem_id="control-row"):
|
807 |
+
# First column for radio buttons
|
808 |
+
with gr.Column(scale=10):
|
809 |
+
mode_selection = gr.Radio(
|
810 |
+
choices=["quick", "detailed"],
|
811 |
+
value="quick",
|
812 |
+
label=""
|
813 |
+
)
|
814 |
+
|
815 |
+
# Second column for tiny paperclip button
|
816 |
+
with gr.Column(scale=1, elem_id="paperclip-column"):
|
817 |
+
file_upload = gr.File(
|
818 |
+
file_types=["image", "pdf", "doc", "docx"],
|
819 |
+
type="binary",
|
820 |
+
label="π",
|
821 |
+
elem_id="paperclip-upload",
|
822 |
+
elem_classes=["paperclip-button"]
|
823 |
+
)
|
824 |
|
825 |
+
# Action buttons row
|
826 |
with gr.Row(elem_id="button-row"):
|
827 |
clear_btn = gr.Button("Clear", elem_id="clear-btn")
|
828 |
analyze_btn = gr.Button("Analyze Text", elem_id="analyze-btn")
|
|
|
833 |
output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
834 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
835 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
# Connect the components
|
837 |
analyze_btn.click(
|
838 |
analyze_text_wrapper,
|
|
|
852 |
outputs=[output_html, output_sentences, output_result]
|
853 |
)
|
854 |
|
855 |
+
# Add custom CSS to style everything correctly
|
856 |
gr.HTML("""
|
857 |
<style>
|
858 |
+
/* Button styling */
|
859 |
#analyze-btn {
|
860 |
background-color: #FF8C00 !important;
|
861 |
border-color: #FF8C00 !important;
|
|
|
871 |
|
872 |
#button-row {
|
873 |
gap: 10px !important;
|
874 |
+
margin-top: 10px !important;
|
875 |
+
}
|
876 |
+
|
877 |
+
/* Paperclip styling - make it tiny and minimal */
|
878 |
+
#paperclip-column {
|
879 |
+
min-width: 30px !important;
|
880 |
+
width: 30px !important;
|
881 |
+
padding: 0 !important;
|
882 |
+
margin-left: -15px !important;
|
883 |
+
margin-top: 8px !important;
|
884 |
+
}
|
885 |
+
|
886 |
+
/* Hide virtually everything in the file upload except the emoji */
|
887 |
+
.paperclip-button .wrap {
|
888 |
+
border: none !important;
|
889 |
+
background: none !important;
|
890 |
+
padding: 0 !important;
|
891 |
+
margin: 0 !important;
|
892 |
+
height: 30px !important;
|
893 |
+
min-height: 0 !important;
|
894 |
+
}
|
895 |
+
|
896 |
+
.paperclip-button .file-preview {
|
897 |
+
display: none !important;
|
898 |
+
}
|
899 |
+
|
900 |
+
.paperclip-button label {
|
901 |
+
display: none !important;
|
902 |
}
|
903 |
|
904 |
+
.paperclip-button .upload-button {
|
905 |
+
background: none !important;
|
906 |
+
border: none !important;
|
907 |
+
padding: 0 !important;
|
908 |
+
margin: 0 !important;
|
909 |
+
width: 25px !important;
|
910 |
+
height: 25px !important;
|
911 |
+
opacity: 0.6 !important;
|
912 |
}
|
913 |
|
914 |
+
.paperclip-button .upload-button:hover {
|
915 |
+
opacity: 1 !important;
|
|
|
|
|
|
|
|
|
916 |
}
|
917 |
|
918 |
+
/* Fix file upload icon to be paperclip only */
|
919 |
+
.paperclip-button .upload-button::before {
|
920 |
+
content: "π" !important;
|
921 |
+
font-size: 18px !important;
|
922 |
+
position: absolute !important;
|
923 |
+
left: 3px !important;
|
924 |
+
top: 2px !important;
|
925 |
}
|
926 |
|
927 |
+
.paperclip-button .upload-button .icon {
|
928 |
+
display: none !important;
|
929 |
+
}
|
930 |
+
|
931 |
+
.paperclip-button .upload-button .text-button {
|
932 |
+
display: none !important;
|
933 |
}
|
934 |
|
935 |
/* Description text styling */
|
|
|
940 |
margin-bottom: 5px !important;
|
941 |
}
|
942 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
""")
|
944 |
|
945 |
return demo
|