cstr commited on
Commit
8f62037
1 Parent(s): c557b53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
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 = login()
 
 
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, token_input], outputs=output)
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