Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2b65c13

Browse files
authoredMay 6, 2024
Merge pull request #161 from rossdanlm/pr161
RAG Guide: Comment out set_css logic that breaks for Jupyter notebooks
2 parents 4199b7b + d1d0e1c commit 2b65c13

File tree

1 file changed

+32
-267
lines changed

1 file changed

+32
-267
lines changed
 

‎notebooks/guides/RAG_with_Chat_Embed_and_Rerank_via_Pinecone.ipynb

Lines changed: 32 additions & 267 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,98 +109,46 @@
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
},
199128
{
200129
"cell_type": "code",
201-
"execution_count": 3,
130+
"execution_count": 4,
202131
"id": "Dx1cncziCWBB",
203132
"metadata": {
204133
"cellView": "form",
205134
"id": "Dx1cncziCWBB"
206135
},
207-
"outputs": [
208-
{
209-
"data": {
210-
"text/html": [
211-
"\n",
212-
" <style>\n",
213-
" pre {\n",
214-
" white-space: pre-wrap;\n",
215-
" }\n",
216-
" </style>\n",
217-
" "
218-
],
219-
"text/plain": [
220-
"<IPython.core.display.HTML object>"
221-
]
222-
},
223-
"metadata": {},
224-
"output_type": "display_data"
225-
}
226-
],
136+
"outputs": [],
227137
"source": [
228-
"#@title Enable text wrapping in Google Colab\n",
229-
"\n",
230-
"from IPython.display import HTML, display\n",
231-
"\n",
232-
"def set_css():\n",
233-
" display(HTML('''\n",
234-
" <style>\n",
235-
" pre {\n",
236-
" white-space: pre-wrap;\n",
237-
" }\n",
238-
" </style>\n",
239-
" '''))\n",
240-
"get_ipython().events.register('pre_run_cell', set_css)"
138+
"# #@title Enable text wrapping in Google Colab\n",
139+
"# Uncomment the code below for Google Colab\n",
140+
"\n",
141+
"# from IPython.display import HTML, display\n",
142+
"\n",
143+
"# def set_css():\n",
144+
"# display(HTML('''\n",
145+
"# <style>\n",
146+
"# pre {\n",
147+
"# white-space: pre-wrap;\n",
148+
"# }\n",
149+
"# </style>\n",
150+
"# '''))\n",
151+
"# get_ipython().events.register('pre_run_cell', set_css)"
241152
]
242153
},
243154
{
@@ -254,7 +165,7 @@
254165
},
255166
{
256167
"cell_type": "code",
257-
"execution_count": 4,
168+
"execution_count": 5,
258169
"id": "3dca4a88",
259170
"metadata": {
260171
"colab": {
@@ -264,44 +175,7 @@
264175
"id": "3dca4a88",
265176
"outputId": "b05da1ee-0456-4387-c232-a43e0ffed54c"
266177
},
267-
"outputs": [
268-
{
269-
"data": {
270-
"text/html": [
271-
"\n",
272-
" <style>\n",
273-
" pre {\n",
274-
" white-space: pre-wrap;\n",
275-
" }\n",
276-
" </style>\n",
277-
" "
278-
],
279-
"text/plain": [
280-
"<IPython.core.display.HTML object>"
281-
]
282-
},
283-
"metadata": {},
284-
"output_type": "display_data"
285-
},
286-
{
287-
"data": {
288-
"text/html": [
289-
"\n",
290-
" <style>\n",
291-
" pre {\n",
292-
" white-space: pre-wrap;\n",
293-
" }\n",
294-
" </style>\n",
295-
" "
296-
],
297-
"text/plain": [
298-
"<IPython.core.display.HTML object>"
299-
]
300-
},
301-
"metadata": {},
302-
"output_type": "display_data"
303-
}
304-
],
178+
"outputs": [],
305179
"source": [
306180
"raw_documents = [\n",
307181
" {\n",
@@ -347,7 +221,7 @@
347221
},
348222
{
349223
"cell_type": "code",
350-
"execution_count": 113,
224+
"execution_count": 6,
351225
"id": "7c33412c",
352226
"metadata": {
353227
"colab": {
@@ -357,44 +231,7 @@
357231
"id": "7c33412c",
358232
"outputId": "cf04f8ed-8000-4433-f976-2d37747f21e7"
359233
},
360-
"outputs": [
361-
{
362-
"data": {
363-
"text/html": [
364-
"\n",
365-
" <style>\n",
366-
" pre {\n",
367-
" white-space: pre-wrap;\n",
368-
" }\n",
369-
" </style>\n",
370-
" "
371-
],
372-
"text/plain": [
373-
"<IPython.core.display.HTML object>"
374-
]
375-
},
376-
"metadata": {},
377-
"output_type": "display_data"
378-
},
379-
{
380-
"data": {
381-
"text/html": [
382-
"\n",
383-
" <style>\n",
384-
" pre {\n",
385-
" white-space: pre-wrap;\n",
386-
" }\n",
387-
" </style>\n",
388-
" "
389-
],
390-
"text/plain": [
391-
"<IPython.core.display.HTML object>"
392-
]
393-
},
394-
"metadata": {},
395-
"output_type": "display_data"
396-
}
397-
],
234+
"outputs": [],
398235
"source": [
399236
"class Vectorstore:\n",
400237
" \"\"\"\n",
@@ -548,7 +385,7 @@
548385
},
549386
{
550387
"cell_type": "code",
551-
"execution_count": 114,
388+
"execution_count": 7,
552389
"id": "4643e630",
553390
"metadata": {
554391
"colab": {
@@ -559,42 +396,6 @@
559396
"outputId": "fe01fcb6-3574-4322-d8d0-57d37aad397d"
560397
},
561398
"outputs": [
562-
{
563-
"data": {
564-
"text/html": [
565-
"\n",
566-
" <style>\n",
567-
" pre {\n",
568-
" white-space: pre-wrap;\n",
569-
" }\n",
570-
" </style>\n",
571-
" "
572-
],
573-
"text/plain": [
574-
"<IPython.core.display.HTML object>"
575-
]
576-
},
577-
"metadata": {},
578-
"output_type": "display_data"
579-
},
580-
{
581-
"data": {
582-
"text/html": [
583-
"\n",
584-
" <style>\n",
585-
" pre {\n",
586-
" white-space: pre-wrap;\n",
587-
" }\n",
588-
" </style>\n",
589-
" "
590-
],
591-
"text/plain": [
592-
"<IPython.core.display.HTML object>"
593-
]
594-
},
595-
"metadata": {},
596-
"output_type": "display_data"
597-
},
598399
{
599400
"name": "stdout",
600401
"output_type": "stream",
@@ -649,7 +450,7 @@
649450
},
650451
{
651452
"cell_type": "code",
652-
"execution_count": 115,
453+
"execution_count": 8,
653454
"id": "82617b91",
654455
"metadata": {
655456
"colab": {
@@ -660,42 +461,6 @@
660461
"outputId": "7f1f2bc8-8ed9-4190-bd6b-7af2d9dc1980"
661462
},
662463
"outputs": [
663-
{
664-
"data": {
665-
"text/html": [
666-
"\n",
667-
" <style>\n",
668-
" pre {\n",
669-
" white-space: pre-wrap;\n",
670-
" }\n",
671-
" </style>\n",
672-
" "
673-
],
674-
"text/plain": [
675-
"<IPython.core.display.HTML object>"
676-
]
677-
},
678-
"metadata": {},
679-
"output_type": "display_data"
680-
},
681-
{
682-
"data": {
683-
"text/html": [
684-
"\n",
685-
" <style>\n",
686-
" pre {\n",
687-
" white-space: pre-wrap;\n",
688-
" }\n",
689-
" </style>\n",
690-
" "
691-
],
692-
"text/plain": [
693-
"<IPython.core.display.HTML object>"
694-
]
695-
},
696-
"metadata": {},
697-
"output_type": "display_data"
698-
},
699464
{
700465
"data": {
701466
"text/plain": [

0 commit comments

Comments
 (0)
This repository has been archived.