Wauplin HF staff commited on
Commit
0870e54
1 Parent(s): a1d5397

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from huggingface_hub import list_models
4
+
5
+
6
+ def list_private_models(oauth_profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
7
+ if oauth_token is None:
8
+ return "Please log in to list private models."
9
+ # List models from author using token
10
+ models = list_models(author=oauth_profile.username, token=oauth_token.token)
11
+ # Return list of private models
12
+ return f"Private models: {', '.join(model.id for model in models if model.private)}"
13
+
14
+ with gr.Blocks() as demo:
15
+ gr.LoginButton()
16
+ gr.LogoutButton()
17
+ m1 = gr.Markdown()
18
+ demo.load(list_private_models, inputs=None, outputs=m1)