Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,7 @@ import os
|
|
| 2 |
from threading import Thread
|
| 3 |
from typing import Iterator
|
| 4 |
import os
|
| 5 |
-
from huggingface_hub import HfApi
|
| 6 |
-
|
| 7 |
-
# Retrieve the token
|
| 8 |
-
hf_token = os.getenv("HF_AUTH_TOKEN")
|
| 9 |
-
|
| 10 |
-
# Example: Using the token with Hugging Face Hub
|
| 11 |
from huggingface_hub import login
|
| 12 |
-
print(hf_token)
|
| 13 |
-
login(token = hf_token)
|
| 14 |
import gradio as gr
|
| 15 |
import spaces
|
| 16 |
import torch
|
|
@@ -117,6 +109,18 @@ chat_interface = gr.ChatInterface(
|
|
| 117 |
|
| 118 |
with gr.Blocks(css_paths="style.css", fill_height=True) as demo:
|
| 119 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
chat_interface.render()
|
| 121 |
|
| 122 |
if __name__ == "__main__":
|
|
|
|
| 2 |
from threading import Thread
|
| 3 |
from typing import Iterator
|
| 4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from huggingface_hub import login
|
|
|
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
import torch
|
|
|
|
| 109 |
|
| 110 |
with gr.Blocks(css_paths="style.css", fill_height=True) as demo:
|
| 111 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
| 112 |
+
def authenticate_token(token):
|
| 113 |
+
try:
|
| 114 |
+
# Validate token using Hugging Face Hub API
|
| 115 |
+
login(token = hf_token)
|
| 116 |
+
return f"Authenticated successfully"
|
| 117 |
+
except HfHubHTTPError:
|
| 118 |
+
return "Invalid token. Please try again."
|
| 119 |
+
|
| 120 |
+
# Components
|
| 121 |
+
token_input = gr.Textbox(label="Hugging Face Access Token", type="password", placeholder="Enter your token here...")
|
| 122 |
+
auth_button = gr.Button("Authenticate")
|
| 123 |
+
output = gr.Textbox(label="Output")
|
| 124 |
chat_interface.render()
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|