Claude commited on
Commit
1c21844
·
1 Parent(s): ce7f3f9

feat: Add HuggingFace token login panel to Gradio interface

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -1108,6 +1108,41 @@ def create_interface():
1108
  </div>
1109
  """)
1110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1111
  with gr.Tabs():
1112
  # =================== CHAT TAB ===================
1113
  with gr.Tab("Explore", id="chat"):
 
1108
  </div>
1109
  """)
1110
 
1111
+ # Login Panel
1112
+ with gr.Group():
1113
+ gr.Markdown("### 🔐 HuggingFace Token (Optional for LLM Synthesis)")
1114
+ with gr.Row():
1115
+ token_input = gr.Textbox(
1116
+ label="HF API Token",
1117
+ type="password",
1118
+ placeholder="hf_...",
1119
+ scale=4,
1120
+ )
1121
+ login_btn = gr.Button("Login", variant="primary", scale=1)
1122
+
1123
+ auth_status = gr.Textbox(
1124
+ label="Status",
1125
+ value="Ready (token not loaded)",
1126
+ interactive=False,
1127
+ show_label=False,
1128
+ )
1129
+
1130
+ def handle_login(token):
1131
+ """Authenticate with HuggingFace token."""
1132
+ if not token or token.strip() == "":
1133
+ return "No token provided"
1134
+ try:
1135
+ login(token=token.strip())
1136
+ return f"✅ Authenticated! Token valid."
1137
+ except Exception as e:
1138
+ return f"❌ Auth failed: {str(e)[:100]}"
1139
+
1140
+ login_btn.click(
1141
+ handle_login,
1142
+ token_input,
1143
+ auth_status,
1144
+ )
1145
+
1146
  with gr.Tabs():
1147
  # =================== CHAT TAB ===================
1148
  with gr.Tab("Explore", id="chat"):