sergiopaniego HF Staff commited on
Commit
cecf8ed
·
1 Parent(s): fdb5b43

fix: support Google Colab secrets for HF_TOKEN loading (#134)

Browse files

- fix: support Google Colab secrets for HF_TOKEN loading (f9fb548bc8e2e16be522a87e0cd2354a8a0fee8e)

Files changed (1) hide show
  1. unit1/dummy_agent_library.ipynb +8 -3
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. If you run this on Google Colab, you can set it up in the \"settings\" tab under \"secrets\". Make sure to call it \"HF_TOKEN\"\n",
48
- "# HF_TOKEN = os.environ.get(\"HF_TOKEN\")\n",
 
 
 
 
 
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
  {