Skip to content

Commit 95ae6af

Browse files
committed
Fixed some package errors
1 parent cb8dd84 commit 95ae6af

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

locallab/cli/interactive.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,26 +262,24 @@ def prompt_for_config(use_ngrok: bool = None, port: int = None, ngrok_auth_token
262262
click.echo("\n🔑 Enter your HuggingFace token (optional)")
263263
click.echo(" Get your token from: https://huggingface.co/settings/tokens")
264264
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 = ""
265+
266+
# Read token character by character
267+
chars = []
268+
while True:
269+
char = click.getchar()
270+
if char in ('\r', '\n'):
271+
break
272+
chars.append(char)
273+
click.echo('*', nl=False) # Show * for each character
274+
275+
hf_token = ''.join(chars)
281276

282277
if hf_token:
278+
click.echo("\n✅ Token saved!")
283279
os.environ["HUGGINGFACE_TOKEN"] = hf_token
284280
config["huggingface_token"] = hf_token
281+
else:
282+
click.echo("\nSkipping HuggingFace token...")
285283

286284
click.echo("\n✅ Configuration complete!\n")
287285
return config

locallab/config.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,43 @@ def reset_instructions(self, model_id: Optional[str] = None):
515515
system_instructions = SystemInstructions()
516516

517517

518-
519-
520-
518+
def get_hf_token(interactive: bool = False) -> Optional[str]:
519+
"""Get HuggingFace token from environment or config"""
520+
# First check environment
521+
token = os.environ.get("HUGGINGFACE_TOKEN")
522+
523+
# Then check config
524+
if not token:
525+
try:
526+
from .cli.config import get_config_value
527+
token = get_config_value("huggingface_token")
528+
except:
529+
pass
530+
531+
# If interactive and still no token, prompt user
532+
if not token and interactive:
533+
try:
534+
click.echo("\n🔑 HuggingFace token is recommended for better model access.")
535+
click.echo("Get your token from: https://huggingface.co/settings/tokens")
536+
click.echo("Enter token (press Enter to skip): ", nl=False)
537+
538+
# Read token character by character
539+
chars = []
540+
while True:
541+
char = click.getchar()
542+
if char in ('\r', '\n'):
543+
break
544+
chars.append(char)
545+
click.echo('*', nl=False) # Show * for each character
546+
547+
token = ''.join(chars)
548+
if token:
549+
click.echo("\n✅ Token saved!")
550+
os.environ["HUGGINGFACE_TOKEN"] = token
551+
else:
552+
click.echo("\nSkipping token...")
553+
except:
554+
# If there's any error in interactive mode, just return None
555+
pass
556+
557+
return token

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.24",
8+
version="0.4.26",
99
packages=find_packages(include=["locallab", "locallab.*"]),
1010
install_requires=[
1111
"fastapi>=0.95.0,<1.0.0",

0 commit comments

Comments
 (0)