|
76 | 76 | },
|
77 | 77 | {
|
78 | 78 | "cell_type": "code",
|
79 |
| - "execution_count": null, |
| 79 | + "execution_count": 1, |
80 | 80 | "id": "5pLAhQmTOKiV",
|
81 | 81 | "metadata": {
|
82 | 82 | "id": "5pLAhQmTOKiV"
|
83 | 83 | },
|
84 | 84 | "outputs": [],
|
85 | 85 | "source": [
|
86 |
| - "! pip install cohere hnswlib unstructured -q" |
| 86 | + "! pip install cohere hnswlib unstructured python-dotenv -q" |
87 | 87 | ]
|
88 | 88 | },
|
89 | 89 | {
|
90 | 90 | "cell_type": "code",
|
91 |
| - "execution_count": 16, |
| 91 | + "execution_count": 2, |
92 | 92 | "id": "f3a03a57",
|
93 | 93 | "metadata": {
|
94 | 94 | "id": "f3a03a57"
|
95 | 95 | },
|
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": [], |
134 | 97 | "source": [
|
135 | 98 | "import cohere\n",
|
136 | 99 | "from pinecone import Pinecone, PodSpec\n",
|
|
146 | 109 | },
|
147 | 110 | {
|
148 | 111 | "cell_type": "code",
|
149 |
| - "execution_count": 17, |
| 112 | + "execution_count": 3, |
150 | 113 | "id": "f0b1935e",
|
151 | 114 | "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": [], |
190 | 116 | "source": [
|
191 | 117 | "import cohere\n",
|
192 | 118 | "import os\n",
|
| 119 | + "import dotenv\n", |
| 120 | + "\n", |
| 121 | + "dotenv.load_dotenv()\n", |
193 | 122 | "co = cohere.Client(os.getenv(\"COHERE_API_KEY\"))\n",
|
194 | 123 | "pc = Pinecone(\n",
|
195 |
| - " api_key=os.environ.get(\"PINECONE_API_KEY\")\n", |
| 124 | + " api_key=os.getenv(\"PINECONE_API_KEY\")\n", |
196 | 125 | ")\n"
|
197 | 126 | ]
|
198 | 127 | },
|
199 | 128 | {
|
200 | 129 | "cell_type": "code",
|
201 |
| - "execution_count": 3, |
| 130 | + "execution_count": 4, |
202 | 131 | "id": "Dx1cncziCWBB",
|
203 | 132 | "metadata": {
|
204 | 133 | "cellView": "form",
|
205 | 134 | "id": "Dx1cncziCWBB"
|
206 | 135 | },
|
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": [], |
227 | 137 | "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)" |
241 | 152 | ]
|
242 | 153 | },
|
243 | 154 | {
|
|
254 | 165 | },
|
255 | 166 | {
|
256 | 167 | "cell_type": "code",
|
257 |
| - "execution_count": 4, |
| 168 | + "execution_count": 5, |
258 | 169 | "id": "3dca4a88",
|
259 | 170 | "metadata": {
|
260 | 171 | "colab": {
|
|
264 | 175 | "id": "3dca4a88",
|
265 | 176 | "outputId": "b05da1ee-0456-4387-c232-a43e0ffed54c"
|
266 | 177 | },
|
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": [], |
305 | 179 | "source": [
|
306 | 180 | "raw_documents = [\n",
|
307 | 181 | " {\n",
|
|
347 | 221 | },
|
348 | 222 | {
|
349 | 223 | "cell_type": "code",
|
350 |
| - "execution_count": 113, |
| 224 | + "execution_count": 6, |
351 | 225 | "id": "7c33412c",
|
352 | 226 | "metadata": {
|
353 | 227 | "colab": {
|
|
357 | 231 | "id": "7c33412c",
|
358 | 232 | "outputId": "cf04f8ed-8000-4433-f976-2d37747f21e7"
|
359 | 233 | },
|
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": [], |
398 | 235 | "source": [
|
399 | 236 | "class Vectorstore:\n",
|
400 | 237 | " \"\"\"\n",
|
|
548 | 385 | },
|
549 | 386 | {
|
550 | 387 | "cell_type": "code",
|
551 |
| - "execution_count": 114, |
| 388 | + "execution_count": 7, |
552 | 389 | "id": "4643e630",
|
553 | 390 | "metadata": {
|
554 | 391 | "colab": {
|
|
559 | 396 | "outputId": "fe01fcb6-3574-4322-d8d0-57d37aad397d"
|
560 | 397 | },
|
561 | 398 | "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 |
| - }, |
598 | 399 | {
|
599 | 400 | "name": "stdout",
|
600 | 401 | "output_type": "stream",
|
|
649 | 450 | },
|
650 | 451 | {
|
651 | 452 | "cell_type": "code",
|
652 |
| - "execution_count": 115, |
| 453 | + "execution_count": 8, |
653 | 454 | "id": "82617b91",
|
654 | 455 | "metadata": {
|
655 | 456 | "colab": {
|
|
660 | 461 | "outputId": "7f1f2bc8-8ed9-4190-bd6b-7af2d9dc1980"
|
661 | 462 | },
|
662 | 463 | "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 |
| - }, |
699 | 464 | {
|
700 | 465 | "data": {
|
701 | 466 | "text/plain": [
|
|
0 commit comments