Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,11 @@ print("Loading the transformer model...")
|
|
| 38 |
# Initialize the transformer vectorizer
|
| 39 |
transformer_vectorizer = TransformerVectorizer()
|
| 40 |
vectorizer = TfidfVectorizer()
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
def clean_tmp_directory():
|
| 43 |
# Allow 20 user keys to be stored.
|
| 44 |
# Once that limitation is reached, deleted the oldest.
|
|
@@ -281,6 +285,11 @@ with demo:
|
|
| 281 |
gr.Markdown(
|
| 282 |
"Enter a contract or clause you want to analysis)."
|
| 283 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
text = gr.Textbox(label="Enter some words:", value="The Employee is entitled to two weeks of paid vacation annually, to be scheduled at the mutual convenience of the Employee and Employer.")
|
| 285 |
gr.Markdown(
|
| 286 |
"""
|
|
|
|
| 38 |
# Initialize the transformer vectorizer
|
| 39 |
transformer_vectorizer = TransformerVectorizer()
|
| 40 |
vectorizer = TfidfVectorizer()
|
| 41 |
+
def toggle_visibility(input_type):
|
| 42 |
+
user_input_visible = input_type == "Text Input"
|
| 43 |
+
file_upload_visible = input_type == "File Upload"
|
| 44 |
+
return gr.update(visible=user_input_visible), gr.update(visible=file_upload_visible)
|
| 45 |
+
|
| 46 |
def clean_tmp_directory():
|
| 47 |
# Allow 20 user keys to be stored.
|
| 48 |
# Once that limitation is reached, deleted the oldest.
|
|
|
|
| 285 |
gr.Markdown(
|
| 286 |
"Enter a contract or clause you want to analysis)."
|
| 287 |
)
|
| 288 |
+
input_type = gr.Radio(choices=["Text Input", "File Upload"], label="Select Input Method")
|
| 289 |
+
text = gr.Textbox(label="Enter some words:",visible=False,value="The Employee is entitled to two weeks of paid vacation annually, to be scheduled at the mutual convenience of the Employee and Employer.")
|
| 290 |
+
|
| 291 |
+
file_upload = gr.File(label="Upload File", file_types=[".txt"], visible=False) # Initially hidden
|
| 292 |
+
input_type.change(toggle_visibility, inputs=input_type, outputs=[user_input, file_upload])
|
| 293 |
text = gr.Textbox(label="Enter some words:", value="The Employee is entitled to two weeks of paid vacation annually, to be scheduled at the mutual convenience of the Employee and Employer.")
|
| 294 |
gr.Markdown(
|
| 295 |
"""
|