Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HF_TOKEN environment variable in huggingface_provider.py #59

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GOOGLE_REGION=
GOOGLE_PROJECT_ID=

# Hugging Face token
HUGGINGFACE_TOKEN=
HF_TOKEN=

# Fireworks
FIREWORKS_API_KEY=
Expand Down
4 changes: 2 additions & 2 deletions aisuite/providers/huggingface_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def __init__(self, **config):
The token is fetched from the config or environment variables.
"""
# Ensure API key is provided either in config or via environment variable
self.token = config.get("token") or os.getenv("HUGGINGFACE_TOKEN")
self.token = config.get("token") or os.getenv("HF_TOKEN")
if not self.token:
raise ValueError(
"Hugging Face token is missing. Please provide it in the config or set the HUGGINGFACE_TOKEN environment variable."
"Hugging Face token is missing. Please provide it in the config or set the HF_TOKEN environment variable."
)

# Optionally set a custom timeout (default to 30s)
Expand Down
2 changes: 1 addition & 1 deletion guides/huggingface.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ After setting up your model, you'll need to gather the following information:
Set the following environment variables to make authentication and requests easy:

```shell
export HUGGINGFACE_TOKEN="your-api-token"
export HF_TOKEN="your-api-token"
```

## Create a Chat Completion
Expand Down
Loading