Skip to content

Commit cb8dd84

Browse files
committed
Improved UX of hugging face token input
1 parent c784bc5 commit cb8dd84

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

locallab/cli/interactive.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,26 @@ def prompt_for_config(use_ngrok: bool = None, port: int = None, ngrok_auth_token
259259
# Ask about HuggingFace token
260260
hf_token = config.get("huggingface_token") or os.environ.get("HUGGINGFACE_TOKEN")
261261
if not hf_token or force_reconfigure:
262-
hf_token = click.prompt(
263-
"🔑 Enter your HuggingFace token (optional, press Enter to skip)",
264-
default="",
265-
hide_input=True
266-
)
262+
click.echo("\n🔑 Enter your HuggingFace token (optional)")
263+
click.echo(" Get your token from: https://huggingface.co/settings/tokens")
264+
click.echo(" Press Enter to skip or paste your token (it will be hidden): ", nl=False)
265+
hf_token = click.getchar()
266+
if hf_token and hf_token != '\r' and hf_token != '\n':
267+
# Read the rest of the token
268+
token_chars = [hf_token]
269+
while True:
270+
char = click.getchar()
271+
if char in ('\r', '\n'):
272+
break
273+
token_chars.append(char)
274+
click.echo('*', nl=False) # Show * for each character
275+
hf_token = ''.join(token_chars)
276+
click.echo() # New line after token input
277+
click.echo("✅ Token saved!")
278+
else:
279+
click.echo("\nSkipping HuggingFace token...")
280+
hf_token = ""
281+
267282
if hf_token:
268283
os.environ["HUGGINGFACE_TOKEN"] = hf_token
269284
config["huggingface_token"] = hf_token

locallab/model_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ async def load_model(self, model_id: str) -> bool:
255255
start_time = time.time()
256256
logger.info(f"\n{Fore.CYAN}Loading model: {model_id}{Style.RESET_ALL}")
257257

258-
from .config import get_hf_token
259-
hf_token = get_hf_token(interactive=True)
258+
from .config import get_hf_token
259+
hf_token = get_hf_token(interactive=True)
260260

261261
if self.model is not None:
262262
prev_model = self.current_model

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="locallab",
8-
version="0.4.25",
8+
version="0.4.24",
99
packages=find_packages(include=["locallab", "locallab.*"]),
1010
install_requires=[
1111
"fastapi>=0.95.0,<1.0.0",

0 commit comments

Comments
 (0)