Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit be9ac87

Browse files
author
Rossdan Craig [email protected]
committed
RAG Guide: Include python-dotenv to load Cohere and Pinecone API keys from .env file
Nice convenience function, don't need to acecpt if you don't like it ## Test Plan Notebook runs if you define API keys in an .env file
1 parent 9c91089 commit be9ac87

File tree

1 file changed

+10
-81
lines changed

1 file changed

+10
-81
lines changed

notebooks/guides/RAG_with_Chat_Embed_and_Rerank_via_Pinecone.ipynb

Lines changed: 10 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -76,61 +76,24 @@
7676
},
7777
{
7878
"cell_type": "code",
79-
"execution_count": null,
79+
"execution_count": 1,
8080
"id": "5pLAhQmTOKiV",
8181
"metadata": {
8282
"id": "5pLAhQmTOKiV"
8383
},
8484
"outputs": [],
8585
"source": [
86-
"! pip install cohere hnswlib unstructured -q"
86+
"! pip install cohere hnswlib unstructured python-dotenv -q"
8787
]
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 16,
91+
"execution_count": 2,
9292
"id": "f3a03a57",
9393
"metadata": {
9494
"id": "f3a03a57"
9595
},
96-
"outputs": [
97-
{
98-
"data": {
99-
"text/html": [
100-
"\n",
101-
" <style>\n",
102-
" pre {\n",
103-
" white-space: pre-wrap;\n",
104-
" }\n",
105-
" </style>\n",
106-
" "
107-
],
108-
"text/plain": [
109-
"<IPython.core.display.HTML object>"
110-
]
111-
},
112-
"metadata": {},
113-
"output_type": "display_data"
114-
},
115-
{
116-
"data": {
117-
"text/html": [
118-
"\n",
119-
" <style>\n",
120-
" pre {\n",
121-
" white-space: pre-wrap;\n",
122-
" }\n",
123-
" </style>\n",
124-
" "
125-
],
126-
"text/plain": [
127-
"<IPython.core.display.HTML object>"
128-
]
129-
},
130-
"metadata": {},
131-
"output_type": "display_data"
132-
}
133-
],
96+
"outputs": [],
13497
"source": [
13598
"import cohere\n",
13699
"from pinecone import Pinecone, PodSpec\n",
@@ -146,53 +109,19 @@
146109
},
147110
{
148111
"cell_type": "code",
149-
"execution_count": 17,
112+
"execution_count": 3,
150113
"id": "f0b1935e",
151114
"metadata": {},
152-
"outputs": [
153-
{
154-
"data": {
155-
"text/html": [
156-
"\n",
157-
" <style>\n",
158-
" pre {\n",
159-
" white-space: pre-wrap;\n",
160-
" }\n",
161-
" </style>\n",
162-
" "
163-
],
164-
"text/plain": [
165-
"<IPython.core.display.HTML object>"
166-
]
167-
},
168-
"metadata": {},
169-
"output_type": "display_data"
170-
},
171-
{
172-
"data": {
173-
"text/html": [
174-
"\n",
175-
" <style>\n",
176-
" pre {\n",
177-
" white-space: pre-wrap;\n",
178-
" }\n",
179-
" </style>\n",
180-
" "
181-
],
182-
"text/plain": [
183-
"<IPython.core.display.HTML object>"
184-
]
185-
},
186-
"metadata": {},
187-
"output_type": "display_data"
188-
}
189-
],
115+
"outputs": [],
190116
"source": [
191117
"import cohere\n",
192118
"import os\n",
119+
"import dotenv\n",
120+
"\n",
121+
"dotenv.load_dotenv()\n",
193122
"co = cohere.Client(os.getenv(\"COHERE_API_KEY\"))\n",
194123
"pc = Pinecone(\n",
195-
" api_key=os.environ.get(\"PINECONE_API_KEY\")\n",
124+
" api_key=os.getenv(\"PINECONE_API_KEY\")\n",
196125
")\n"
197126
]
198127
},

0 commit comments

Comments
 (0)