fix: support Google Colab secrets for HF_TOKEN loading
#134
by sergiopaniego HF Staff - opened
unit1/dummy_agent_library.ipynb
CHANGED
|
@@ -44,10 +44,15 @@
|
|
| 44 |
"import os\n",
|
| 45 |
"from huggingface_hub import InferenceClient\n",
|
| 46 |
"\n",
|
| 47 |
-
"## You need a token from https://hf.co/settings/tokens, ensure that you select 'read' as the token type.
|
| 48 |
-
"#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
"\n",
|
| 50 |
-
"client = InferenceClient(model=\"moonshotai/Kimi-K2.5\")"
|
| 51 |
]
|
| 52 |
},
|
| 53 |
{
|
|
|
|
| 44 |
"import os\n",
|
| 45 |
"from huggingface_hub import InferenceClient\n",
|
| 46 |
"\n",
|
| 47 |
+
"## You need a token from https://hf.co/settings/tokens, ensure that you select 'read' as the token type.\n",
|
| 48 |
+
"## If you run this on Google Colab, add it in the \"Secrets\" tab (key icon on the left sidebar) and call it \"HF_TOKEN\".\n",
|
| 49 |
+
"try:\n",
|
| 50 |
+
" from google.colab import userdata\n",
|
| 51 |
+
" HF_TOKEN = userdata.get(\"HF_TOKEN\")\n",
|
| 52 |
+
"except ImportError:\n",
|
| 53 |
+
" HF_TOKEN = os.environ.get(\"HF_TOKEN\")\n",
|
| 54 |
"\n",
|
| 55 |
+
"client = InferenceClient(model=\"moonshotai/Kimi-K2.5\", token=HF_TOKEN)"
|
| 56 |
]
|
| 57 |
},
|
| 58 |
{
|