move access token to config.json

This commit is contained in:
rasbt 2024-09-23 08:56:16 -05:00
parent 58df945ed4
commit 6bc3de165c
No known key found for this signature in database
GPG Key ID: 3C6E5C7C075611DB
3 changed files with 13 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,4 +1,5 @@
# Configs and keys
ch05/07_gpt_to_llama/config.json
ch07/02_dataset-utilities/config.json
ch07/03_model-evaluation/config.json
@ -95,6 +96,7 @@ ch07/04_preference-tuning-with-dpo/loss-plot.pdf
ch0?/0?_user_interface/.chainlit/
ch0?/0?_user_interface/chainlit.md
ch0?/0?_user_interface/.files
*.lock
# Temporary OS-related files
.DS_Store

View File

@ -0,0 +1,4 @@
{
"HF_ACCESS_TOKEN": "hf-...",
"_comment": "Enter your access token from https://huggingface.co/settings/tokens"
}

View File

@ -733,8 +733,8 @@
]
},
{
"cell_type": "raw",
"id": "aa79780d-74a8-4ee0-934a-9ad63205a02e",
"cell_type": "markdown",
"id": "ba5d991a-559b-47be-96f4-31b881ab2da8",
"metadata": {
"id": "aa79780d-74a8-4ee0-934a-9ad63205a02e"
},
@ -1104,7 +1104,11 @@
"source": [
"from huggingface_hub import login\n",
"\n",
"login(token=\"hf_...\") # Insert your token here"
"with open(\"config.json\", \"r\") as config_file:\n",
" config = json.load(config_file)\n",
" access_token = config[\"HF_ACCESS_TOKEN\"]\n",
"\n",
"login(token=access_token)"
]
},
{