Skip to content

Commit 595a955

Browse files
committed
Move environment variables higher
1 parent c59f5de commit 595a955

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

use-cases/rag-with-voyage.ipynb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,21 @@
4040
"outputs": [],
4141
"source": [
4242
"import os\n",
43+
"\n",
44+
"# Specify your Hugging Face access token and Voyage API key\n",
45+
"os.environ[\"HF_TOKEN\"] = \"<token>\"\n",
46+
"os.environ[\"VOYAGE_API_KEY\"] = \"<api-key>\""
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
4355
"import voyageai\n",
4456
"\n",
45-
"# Specify your Voyage API key and embedding model\n",
46-
"os.environ[\"VOYAGE_API_KEY\"] = \"<api-key>\"\n",
57+
"# Specify the Voyage AI embedding model\n",
4758
"model = \"voyage-3\"\n",
4859
"vo = voyageai.Client()\n",
4960
"\n",
@@ -189,7 +200,6 @@
189200
"metadata": {},
190201
"outputs": [],
191202
"source": [
192-
"import os\n",
193203
"from huggingface_hub import InferenceClient\n",
194204
"\n",
195205
"# Specify search query, retrieve relevant documents, and convert to string\n",
@@ -203,8 +213,7 @@
203213
" Question: {query}\n",
204214
"\"\"\"\n",
205215
"\n",
206-
"# Authenticate to Hugging Face and access the model\n",
207-
"os.environ[\"HF_TOKEN\"] = \"<token>\"\n",
216+
"# Use a model from Hugging Face\n",
208217
"llm = InferenceClient(\n",
209218
" \"mistralai/Mistral-7B-Instruct-v0.3\",\n",
210219
" token = os.getenv(\"HF_TOKEN\"))\n",

use-cases/rag.ipynb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
"pip install --quiet --upgrade pymongo sentence_transformers einops langchain langchain_community pypdf huggingface_hub"
3434
]
3535
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"metadata": {},
40+
"outputs": [],
41+
"source": [
42+
"import os\n",
43+
"\n",
44+
"# Specify your Hugging Face access token\n",
45+
"os.environ[\"HF_TOKEN\"] = \"<token>\""
46+
]
47+
},
3648
{
3749
"cell_type": "code",
3850
"execution_count": null,
@@ -186,7 +198,6 @@
186198
"metadata": {},
187199
"outputs": [],
188200
"source": [
189-
"import os\n",
190201
"from huggingface_hub import InferenceClient\n",
191202
"\n",
192203
"# Specify search query, retrieve relevant documents, and convert to string\n",
@@ -200,8 +211,7 @@
200211
" Question: {query}\n",
201212
"\"\"\"\n",
202213
"\n",
203-
"# Authenticate to Hugging Face and access the model\n",
204-
"os.environ[\"HF_TOKEN\"] = \"<token>\"\n",
214+
"# Use a model from Hugging Face\n",
205215
"llm = InferenceClient(\n",
206216
" \"mistralai/Mistral-7B-Instruct-v0.3\",\n",
207217
" token = os.getenv(\"HF_TOKEN\"))\n",

0 commit comments

Comments
 (0)