Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -513,10 +513,12 @@ logging.basicConfig(level=logging.INFO, filename='translation.log', filemode='a'
|
|
| 513 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
| 514 |
|
| 515 |
# Main function to handle the translation workflow
|
| 516 |
-
def main(dataset_url, model_type, output_dataset_name, range_specification):
|
| 517 |
try:
|
| 518 |
# Login to Hugging Face
|
| 519 |
-
token
|
|
|
|
|
|
|
| 520 |
if token:
|
| 521 |
logging.info("Logged in to Hugging Face")
|
| 522 |
|
|
@@ -616,7 +618,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 616 |
output = gr.Textbox(label="Output", lines=1)
|
| 617 |
|
| 618 |
submit_btn = gr.Button("Translate Dataset", variant="primary")
|
| 619 |
-
submit_btn.click(main, inputs=[dataset_url, model_type, output_dataset_name, range_specification
|
| 620 |
|
| 621 |
gr.Markdown(value="We sincerely thank our community members for their extraordinary contributions to this project.")
|
| 622 |
|
|
|
|
| 513 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
| 514 |
|
| 515 |
# Main function to handle the translation workflow
|
| 516 |
+
def main(dataset_url, model_type, output_dataset_name, range_specification, token: gr.OAuthToken | None, profile: gr.OAuthProfile | None):
|
| 517 |
try:
|
| 518 |
# Login to Hugging Face
|
| 519 |
+
if token is None or profile is None or token.token is None or profile.username is None:
|
| 520 |
+
return "### You must be logged in to use this service."
|
| 521 |
+
|
| 522 |
if token:
|
| 523 |
logging.info("Logged in to Hugging Face")
|
| 524 |
|
|
|
|
| 618 |
output = gr.Textbox(label="Output", lines=1)
|
| 619 |
|
| 620 |
submit_btn = gr.Button("Translate Dataset", variant="primary")
|
| 621 |
+
submit_btn.click(main, inputs=[dataset_url, model_type, output_dataset_name, range_specification], outputs=output)
|
| 622 |
|
| 623 |
gr.Markdown(value="We sincerely thank our community members for their extraordinary contributions to this project.")
|
| 624 |
|