ngxson HF staff commited on
Commit
b70567b
·
verified ·
1 Parent(s): 6872f01

add oauth token validation before running

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -117,6 +117,13 @@ def split_upload_model(model_path: str, outdir: str, repo_id: str, oauth_token:
117
  def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_repo, train_data_file, split_model, split_max_tensors, split_max_size, oauth_token: gr.OAuthToken | None):
118
  if oauth_token is None or oauth_token.token is None:
119
  raise gr.Error("You must be logged in to use GGUF-my-repo")
 
 
 
 
 
 
 
120
  model_name = model_id.split('/')[-1]
121
 
122
  try:
 
117
  def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_repo, train_data_file, split_model, split_max_tensors, split_max_size, oauth_token: gr.OAuthToken | None):
118
  if oauth_token is None or oauth_token.token is None:
119
  raise gr.Error("You must be logged in to use GGUF-my-repo")
120
+
121
+ # validate the oauth token
122
+ try:
123
+ whoami(oauth_token.token)
124
+ except Exception as e:
125
+ raise gr.Error("You must be logged in to use GGUF-my-repo")
126
+
127
  model_name = model_id.split('/')[-1]
128
 
129
  try: