Spaces:
Running
on
Zero
Running
on
Zero
merge
Browse files
app.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
-
from __future__ import annotations
|
2 |
import spaces
|
3 |
import gradio as gr
|
4 |
-
import torch
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
from huggingface_hub import whoami
|
7 |
import os
|
@@ -80,23 +78,5 @@ demo = gr.ChatInterface(
|
|
80 |
# chatbot_style="default"
|
81 |
)
|
82 |
|
83 |
-
def hello(profile: gr.OAuthProfile | None) -> str:
|
84 |
-
if profile is None:
|
85 |
-
return "I don't know you."
|
86 |
-
return f"Hello {profile.name}"
|
87 |
-
|
88 |
-
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
|
89 |
-
if oauth_token is None:
|
90 |
-
return "Please deploy this on Spaces and log in to list organizations."
|
91 |
-
org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
|
92 |
-
return f"You belong to {', '.join(org_names)}."
|
93 |
-
|
94 |
-
with gr.Blocks() as demo:
|
95 |
-
gr.LoginButton()
|
96 |
-
m1 = gr.Markdown()
|
97 |
-
m2 = gr.Markdown()
|
98 |
-
demo.load(hello, inputs=None, outputs=m1)
|
99 |
-
demo.load(list_organizations, inputs=None, outputs=m2)
|
100 |
-
|
101 |
if __name__ == "__main__":
|
102 |
demo.launch()
|
|
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
|
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
from huggingface_hub import whoami
|
5 |
import os
|
|
|
78 |
# chatbot_style="default"
|
79 |
)
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
if __name__ == "__main__":
|
82 |
demo.launch()
|