examples

Форк
0
/
00-azure-openai-retrieval.ipynb 
1610 строк · 57.2 Кб
1
{
2
  "cells": [
3
    {
4
      "attachments": {},
5
      "cell_type": "markdown",
6
      "metadata": {},
7
      "source": [
8
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pinecone-io/examples/blob/master/learn/generation/langchain/00-azure-openai-retrieval.ipynb) [![Open nbviewer](https://raw.githubusercontent.com/pinecone-io/examples/master/assets/nbviewer-shield.svg)](https://nbviewer.org/github/pinecone-io/examples/blob/master/learn/generation/langchain/00-azure-openai-retrieval.ipynb)"
9
      ]
10
    },
11
    {
12
      "attachments": {},
13
      "cell_type": "markdown",
14
      "metadata": {
15
        "id": "AWGzucuFfbBn"
16
      },
17
      "source": [
18
        "# Using Azure's OpenAI with LangChain"
19
      ]
20
    },
21
    {
22
      "cell_type": "code",
23
      "execution_count": 1,
24
      "metadata": {
25
        "id": "r-ryCeG_f_GC"
26
      },
27
      "outputs": [],
28
      "source": [
29
        "!pip install -qU \\\n",
30
        "    langchain==0.0.227 \\\n",
31
        "    openai==0.27.8 \\\n",
32
        "    \"pinecone-client[grpc]\"==2.2.2 \\\n",
33
        "    pinecone-datasets=='0.5.0rc10'"
34
      ]
35
    },
36
    {
37
      "attachments": {},
38
      "cell_type": "markdown",
39
      "metadata": {
40
        "id": "QTOov1l53Nzs"
41
      },
42
      "source": [
43
        "## Building the Knowledge Base\n",
44
        "\n",
45
        "Adding an external knowledge to chatbots allows us to ground generation to this external knowledge. For our use-case our external knowledge will be the LangChain docs. We can load this from Pinecone datasets like so:"
46
      ]
47
    },
48
    {
49
      "cell_type": "code",
50
      "execution_count": 2,
51
      "metadata": {
52
        "colab": {
53
          "base_uri": "https://localhost:8080/",
54
          "height": 206
55
        },
56
        "id": "pzoBAqUN5El_",
57
        "outputId": "0bd3f6ba-6f35-4a46-f0b2-8ebd96fcf71d"
58
      },
59
      "outputs": [
60
        {
61
          "data": {
62
            "text/html": [
63
              "\n",
64
              "\n",
65
              "  <div id=\"df-8f658644-742d-4e6f-b688-29710288691a\">\n",
66
              "    <div class=\"colab-df-container\">\n",
67
              "      <div>\n",
68
              "<style scoped>\n",
69
              "    .dataframe tbody tr th:only-of-type {\n",
70
              "        vertical-align: middle;\n",
71
              "    }\n",
72
              "\n",
73
              "    .dataframe tbody tr th {\n",
74
              "        vertical-align: top;\n",
75
              "    }\n",
76
              "\n",
77
              "    .dataframe thead th {\n",
78
              "        text-align: right;\n",
79
              "    }\n",
80
              "</style>\n",
81
              "<table border=\"1\" class=\"dataframe\">\n",
82
              "  <thead>\n",
83
              "    <tr style=\"text-align: right;\">\n",
84
              "      <th></th>\n",
85
              "      <th>id</th>\n",
86
              "      <th>values</th>\n",
87
              "      <th>metadata</th>\n",
88
              "    </tr>\n",
89
              "  </thead>\n",
90
              "  <tbody>\n",
91
              "    <tr>\n",
92
              "      <th>0.0</th>\n",
93
              "      <td>417ede5d-39be-498f-b518-f47ed4e53b90</td>\n",
94
              "      <td>[0.005949743557721376, 0.01983247883617878, -0...</td>\n",
95
              "      <td>{'chunk': 0, 'text': '.rst\n",
96
              ".pdf\n",
97
              "Welcome to Lan...</td>\n",
98
              "    </tr>\n",
99
              "    <tr>\n",
100
              "      <th>1.0</th>\n",
101
              "      <td>110f550d-110b-4378-b95e-141397fa21bc</td>\n",
102
              "      <td>[0.009401749819517136, 0.02443608082830906, 0....</td>\n",
103
              "      <td>{'chunk': 1, 'text': 'Use Cases#\n",
104
              "Best practice...</td>\n",
105
              "    </tr>\n",
106
              "    <tr>\n",
107
              "      <th>2.0</th>\n",
108
              "      <td>d5f00f02-3295-4567-b297-5e3262dc2728</td>\n",
109
              "      <td>[-0.005517194513231516, 0.0208403542637825, 0....</td>\n",
110
              "      <td>{'chunk': 2, 'text': 'Gallery: A collection of...</td>\n",
111
              "    </tr>\n",
112
              "    <tr>\n",
113
              "      <th>3.0</th>\n",
114
              "      <td>0b6fe3c6-1f0e-4608-a950-43231e46b08a</td>\n",
115
              "      <td>[-0.006499645300209522, 0.0011573900701478124,...</td>\n",
116
              "      <td>{'chunk': 0, 'text': 'Search\n",
117
              "Error\n",
118
              "Please acti...</td>\n",
119
              "    </tr>\n",
120
              "    <tr>\n",
121
              "      <th>4.0</th>\n",
122
              "      <td>39d5f15f-b973-42c0-8c9b-a2df49b627dc</td>\n",
123
              "      <td>[-0.005658374633640051, 0.00817849114537239, 0...</td>\n",
124
              "      <td>{'chunk': 0, 'text': '.md\n",
125
              ".pdf\n",
126
              "Dependents\n",
127
              "Depe...</td>\n",
128
              "    </tr>\n",
129
              "  </tbody>\n",
130
              "</table>\n",
131
              "</div>\n",
132
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8f658644-742d-4e6f-b688-29710288691a')\"\n",
133
              "              title=\"Convert this dataframe to an interactive table.\"\n",
134
              "              style=\"display:none;\">\n",
135
              "\n",
136
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
137
              "       width=\"24px\">\n",
138
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
139
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
140
              "  </svg>\n",
141
              "      </button>\n",
142
              "\n",
143
              "\n",
144
              "\n",
145
              "    <div id=\"df-9dc7fd91-952f-4102-a97d-f0003177be21\">\n",
146
              "      <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-9dc7fd91-952f-4102-a97d-f0003177be21')\"\n",
147
              "              title=\"Suggest charts.\"\n",
148
              "              style=\"display:none;\">\n",
149
              "\n",
150
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
151
              "     width=\"24px\">\n",
152
              "    <g>\n",
153
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
154
              "    </g>\n",
155
              "</svg>\n",
156
              "      </button>\n",
157
              "    </div>\n",
158
              "\n",
159
              "<style>\n",
160
              "  .colab-df-quickchart {\n",
161
              "    background-color: #E8F0FE;\n",
162
              "    border: none;\n",
163
              "    border-radius: 50%;\n",
164
              "    cursor: pointer;\n",
165
              "    display: none;\n",
166
              "    fill: #1967D2;\n",
167
              "    height: 32px;\n",
168
              "    padding: 0 0 0 0;\n",
169
              "    width: 32px;\n",
170
              "  }\n",
171
              "\n",
172
              "  .colab-df-quickchart:hover {\n",
173
              "    background-color: #E2EBFA;\n",
174
              "    box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
175
              "    fill: #174EA6;\n",
176
              "  }\n",
177
              "\n",
178
              "  [theme=dark] .colab-df-quickchart {\n",
179
              "    background-color: #3B4455;\n",
180
              "    fill: #D2E3FC;\n",
181
              "  }\n",
182
              "\n",
183
              "  [theme=dark] .colab-df-quickchart:hover {\n",
184
              "    background-color: #434B5C;\n",
185
              "    box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
186
              "    filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
187
              "    fill: #FFFFFF;\n",
188
              "  }\n",
189
              "</style>\n",
190
              "\n",
191
              "    <script>\n",
192
              "      async function quickchart(key) {\n",
193
              "        const containerElement = document.querySelector('#' + key);\n",
194
              "        const charts = await google.colab.kernel.invokeFunction(\n",
195
              "            'suggestCharts', [key], {});\n",
196
              "      }\n",
197
              "    </script>\n",
198
              "\n",
199
              "      <script>\n",
200
              "\n",
201
              "function displayQuickchartButton(domScope) {\n",
202
              "  let quickchartButtonEl =\n",
203
              "    domScope.querySelector('#df-9dc7fd91-952f-4102-a97d-f0003177be21 button.colab-df-quickchart');\n",
204
              "  quickchartButtonEl.style.display =\n",
205
              "    google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
206
              "}\n",
207
              "\n",
208
              "        displayQuickchartButton(document);\n",
209
              "      </script>\n",
210
              "      <style>\n",
211
              "    .colab-df-container {\n",
212
              "      display:flex;\n",
213
              "      flex-wrap:wrap;\n",
214
              "      gap: 12px;\n",
215
              "    }\n",
216
              "\n",
217
              "    .colab-df-convert {\n",
218
              "      background-color: #E8F0FE;\n",
219
              "      border: none;\n",
220
              "      border-radius: 50%;\n",
221
              "      cursor: pointer;\n",
222
              "      display: none;\n",
223
              "      fill: #1967D2;\n",
224
              "      height: 32px;\n",
225
              "      padding: 0 0 0 0;\n",
226
              "      width: 32px;\n",
227
              "    }\n",
228
              "\n",
229
              "    .colab-df-convert:hover {\n",
230
              "      background-color: #E2EBFA;\n",
231
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
232
              "      fill: #174EA6;\n",
233
              "    }\n",
234
              "\n",
235
              "    [theme=dark] .colab-df-convert {\n",
236
              "      background-color: #3B4455;\n",
237
              "      fill: #D2E3FC;\n",
238
              "    }\n",
239
              "\n",
240
              "    [theme=dark] .colab-df-convert:hover {\n",
241
              "      background-color: #434B5C;\n",
242
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
243
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
244
              "      fill: #FFFFFF;\n",
245
              "    }\n",
246
              "  </style>\n",
247
              "\n",
248
              "      <script>\n",
249
              "        const buttonEl =\n",
250
              "          document.querySelector('#df-8f658644-742d-4e6f-b688-29710288691a button.colab-df-convert');\n",
251
              "        buttonEl.style.display =\n",
252
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
253
              "\n",
254
              "        async function convertToInteractive(key) {\n",
255
              "          const element = document.querySelector('#df-8f658644-742d-4e6f-b688-29710288691a');\n",
256
              "          const dataTable =\n",
257
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
258
              "                                                     [key], {});\n",
259
              "          if (!dataTable) return;\n",
260
              "\n",
261
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
262
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
263
              "            + ' to learn more about interactive tables.';\n",
264
              "          element.innerHTML = '';\n",
265
              "          dataTable['output_type'] = 'display_data';\n",
266
              "          await google.colab.output.renderOutput(dataTable, element);\n",
267
              "          const docLink = document.createElement('div');\n",
268
              "          docLink.innerHTML = docLinkHtml;\n",
269
              "          element.appendChild(docLink);\n",
270
              "        }\n",
271
              "      </script>\n",
272
              "    </div>\n",
273
              "  </div>\n"
274
            ],
275
            "text/plain": [
276
              "                                       id  \\\n",
277
              "0.0  417ede5d-39be-498f-b518-f47ed4e53b90   \n",
278
              "1.0  110f550d-110b-4378-b95e-141397fa21bc   \n",
279
              "2.0  d5f00f02-3295-4567-b297-5e3262dc2728   \n",
280
              "3.0  0b6fe3c6-1f0e-4608-a950-43231e46b08a   \n",
281
              "4.0  39d5f15f-b973-42c0-8c9b-a2df49b627dc   \n",
282
              "\n",
283
              "                                                values  \\\n",
284
              "0.0  [0.005949743557721376, 0.01983247883617878, -0...   \n",
285
              "1.0  [0.009401749819517136, 0.02443608082830906, 0....   \n",
286
              "2.0  [-0.005517194513231516, 0.0208403542637825, 0....   \n",
287
              "3.0  [-0.006499645300209522, 0.0011573900701478124,...   \n",
288
              "4.0  [-0.005658374633640051, 0.00817849114537239, 0...   \n",
289
              "\n",
290
              "                                              metadata  \n",
291
              "0.0  {'chunk': 0, 'text': '.rst\n",
292
              ".pdf\n",
293
              "Welcome to Lan...  \n",
294
              "1.0  {'chunk': 1, 'text': 'Use Cases#\n",
295
              "Best practice...  \n",
296
              "2.0  {'chunk': 2, 'text': 'Gallery: A collection of...  \n",
297
              "3.0  {'chunk': 0, 'text': 'Search\n",
298
              "Error\n",
299
              "Please acti...  \n",
300
              "4.0  {'chunk': 0, 'text': '.md\n",
301
              ".pdf\n",
302
              "Dependents\n",
303
              "Depe...  "
304
            ]
305
          },
306
          "execution_count": 2,
307
          "metadata": {},
308
          "output_type": "execute_result"
309
        }
310
      ],
311
      "source": [
312
        "from pinecone_datasets import load_dataset\n",
313
        "\n",
314
        "dataset = load_dataset('langchain-python-docs-text-embedding-ada-002')\n",
315
        "# we drop sparse_values as they are not needed for this example\n",
316
        "dataset.documents.drop(['metadata', 'sparse_values'], axis=1, inplace=True)\n",
317
        "dataset.documents.rename(columns={'blob': 'metadata'}, inplace=True)\n",
318
        "dataset.head()"
319
      ]
320
    },
321
    {
322
      "attachments": {},
323
      "cell_type": "markdown",
324
      "metadata": {
325
        "id": "I-e33-oABWmB"
326
      },
327
      "source": [
328
        "We must change the `\"url\"` field in the **metadata** column to `\"source\"` for compatibility with later LangChain components."
329
      ]
330
    },
331
    {
332
      "cell_type": "code",
333
      "execution_count": 3,
334
      "metadata": {
335
        "id": "aFss5U1RFl1U"
336
      },
337
      "outputs": [],
338
      "source": [
339
        "for i, row in dataset.documents.iterrows():\n",
340
        "    row['metadata']['source'] = row['metadata'].pop('url')"
341
      ]
342
    },
343
    {
344
      "attachments": {},
345
      "cell_type": "markdown",
346
      "metadata": {
347
        "id": "GMFaruC43NOU"
348
      },
349
      "source": [
350
        "Our input docs are ready so we can move onto indexing everything."
351
      ]
352
    },
353
    {
354
      "attachments": {},
355
      "cell_type": "markdown",
356
      "metadata": {
357
        "id": "rJSTrhOZ51On"
358
      },
359
      "source": [
360
        "## Initializing the Index\n",
361
        "\n",
362
        "Now we need a place to store these embeddings and enable a efficient vector search through them all. To do that we use Pinecone, we can get a [free API key](https://app.pinecone.io/) and enter it below where we will initialize our connection to Pinecone and create a new index."
363
      ]
364
    },
365
    {
366
      "cell_type": "code",
367
      "execution_count": 4,
368
      "metadata": {
369
        "id": "Ta9-67QN51oj"
370
      },
371
      "outputs": [],
372
      "source": [
373
        "import os\n",
374
        "from pinecone import Pinecone\n",
375
        "\n",
376
        "# initialize connection to pinecone (get API key at app.pinecone.io)\n",
377
        "api_key = os.getenv(\"PINECONE_API_KEY\") or \"PINECONE_API_KEY\"\n",
378
        "# find your environment/region next to the api key in pinecone console\n",
379
        "env = os.getenv(\"PINECONE_ENVIRONMENT\") or \"PINECONE_ENV\"\n",
380
        "\n",
381
        "pc = Pinecone(api_key=api_key)"
382
      ]
383
    },
384
    {
385
      "cell_type": "code",
386
      "execution_count": 5,
387
      "metadata": {
388
        "id": "TKWZmg9l6Cuj"
389
      },
390
      "outputs": [],
391
      "source": [
392
        "index_name = 'azure-openai-langchain-intro'"
393
      ]
394
    },
395
    {
396
      "cell_type": "code",
397
      "execution_count": 6,
398
      "metadata": {
399
        "colab": {
400
          "base_uri": "https://localhost:8080/"
401
        },
402
        "id": "jTSFmN-K6HV8",
403
        "outputId": "3680b637-a5c1-4cee-b22d-a8409bd0cefd"
404
      },
405
      "outputs": [
406
        {
407
          "data": {
408
            "text/plain": [
409
              "{'dimension': 1536,\n",
410
              " 'index_fullness': 0.0,\n",
411
              " 'namespaces': {},\n",
412
              " 'total_vector_count': 0}"
413
            ]
414
          },
415
          "execution_count": 6,
416
          "metadata": {},
417
          "output_type": "execute_result"
418
        }
419
      ],
420
      "source": [
421
        "import time\n",
422
        "\n",
423
        "# check if index already exists (it shouldn't if this is first time)\n",
424
        "if index_name not in pinecone.list_indexes().names():\n",
425
        "    # if does not exist, create index\n",
426
        "    pinecone.create_index(\n",
427
        "        index_name,\n",
428
        "        dimension=1536,  # dimensionality of text-embedding-ada-002\n",
429
        "        metric='cosine'\n",
430
        "    )\n",
431
        "    # wait for index to be initialized\n",
432
        "    while not pinecone.describe_index(index_name).status['ready']:\n",
433
        "        time.sleep(1)\n",
434
        "\n",
435
        "# connect to index\n",
436
        "index = pinecone.Index(index_name)\n",
437
        "# view index stats\n",
438
        "index.describe_index_stats()"
439
      ]
440
    },
441
    {
442
      "attachments": {},
443
      "cell_type": "markdown",
444
      "metadata": {
445
        "id": "ZPnVHRNt6eCd"
446
      },
447
      "source": [
448
        "Now we add all of our docs to Pinecone:"
449
      ]
450
    },
451
    {
452
      "cell_type": "code",
453
      "execution_count": 7,
454
      "metadata": {
455
        "colab": {
456
          "base_uri": "https://localhost:8080/",
457
          "height": 98,
458
          "referenced_widgets": [
459
            "bb4b1deb4d324c459ecc58ff987923ac",
460
            "037cdcbedf9745099dec9c021217f91c",
461
            "9c272465c73c401daf0e323b49c145a8",
462
            "21aa8b33791e44f797cf4ea6862460b2",
463
            "e701b82c73db4a0abe8a50d6efa2454a",
464
            "22ea72881fc94694aa7e4511ac2cd528",
465
            "39fb48d1d26f4ce1a02e5a4854e46312",
466
            "0b4f718f21434759a777e49f7053b432",
467
            "14693a607c7042a98364f3f6d7c0cd0c",
468
            "3ec8c293047c438d91405f51cef54875",
469
            "442ac390a53c43e7b37c4ff9663a4565",
470
            "99fb6f80660d491c9c0b35b61756407a",
471
            "a4edbd751a0d497b98d3bd9af4f8444b",
472
            "790bcea9241e4c9bb2cdfe2177cdba52",
473
            "28c1711a93294f38b477cf46621d22d5",
474
            "938e8a4b843043cb8350fbe714a6d83e",
475
            "41d03cbe02284448b5792da6137da533",
476
            "253d5a11c0b948f29cc4cb528300295c",
477
            "a59445fb528b45dc9943545f24ae3543",
478
            "0e7d09a428d04caca8bd83f8f436621d",
479
            "90250c5b719c4c66b30ae2c68ffa0b49",
480
            "3d6aea5e4ac148e2942a9e99cc4db8a2"
481
          ]
482
        },
483
        "id": "rPkX2a-c6gXb",
484
        "outputId": "8ccbca1a-4336-4058-d852-473bd1e6aa3b"
485
      },
486
      "outputs": [
487
        {
488
          "data": {
489
            "application/vnd.jupyter.widget-view+json": {
490
              "model_id": "bb4b1deb4d324c459ecc58ff987923ac",
491
              "version_major": 2,
492
              "version_minor": 0
493
            },
494
            "text/plain": [
495
              "sending upsert requests:   0%|          | 0/6952 [00:00<?, ?it/s]"
496
            ]
497
          },
498
          "metadata": {},
499
          "output_type": "display_data"
500
        },
501
        {
502
          "data": {
503
            "application/vnd.jupyter.widget-view+json": {
504
              "model_id": "99fb6f80660d491c9c0b35b61756407a",
505
              "version_major": 2,
506
              "version_minor": 0
507
            },
508
            "text/plain": [
509
              "collecting async responses:   0%|          | 0/70 [00:00<?, ?it/s]"
510
            ]
511
          },
512
          "metadata": {},
513
          "output_type": "display_data"
514
        },
515
        {
516
          "data": {
517
            "text/plain": [
518
              "upserted_count: 6952"
519
            ]
520
          },
521
          "execution_count": 7,
522
          "metadata": {},
523
          "output_type": "execute_result"
524
        }
525
      ],
526
      "source": [
527
        "index.upsert_from_dataframe(dataset.documents, batch_size=100)"
528
      ]
529
    },
530
    {
531
      "attachments": {},
532
      "cell_type": "markdown",
533
      "metadata": {
534
        "id": "Pzoh2J5E6jJl"
535
      },
536
      "source": [
537
        "After indexing everything we can check the number of vectors in our index like so:"
538
      ]
539
    },
540
    {
541
      "cell_type": "code",
542
      "execution_count": 8,
543
      "metadata": {
544
        "colab": {
545
          "base_uri": "https://localhost:8080/"
546
        },
547
        "id": "gkM-ku8j6m5K",
548
        "outputId": "b21ec780-acf4-4ee9-e956-fdce486abb24"
549
      },
550
      "outputs": [
551
        {
552
          "data": {
553
            "text/plain": [
554
              "{'dimension': 1536,\n",
555
              " 'index_fullness': 0.0,\n",
556
              " 'namespaces': {'': {'vector_count': 3476}},\n",
557
              " 'total_vector_count': 3476}"
558
            ]
559
          },
560
          "execution_count": 8,
561
          "metadata": {},
562
          "output_type": "execute_result"
563
        }
564
      ],
565
      "source": [
566
        "index.describe_index_stats()"
567
      ]
568
    },
569
    {
570
      "attachments": {},
571
      "cell_type": "markdown",
572
      "metadata": {
573
        "id": "3quLsQzw9Jrb"
574
      },
575
      "source": [
576
        "## Initializing Azure OpenAI"
577
      ]
578
    },
579
    {
580
      "attachments": {},
581
      "cell_type": "markdown",
582
      "metadata": {
583
        "id": "0fOo9qQvDgkz"
584
      },
585
      "source": [
586
        "To use OpenAI's service via Azure we first need to setup the service in Azure and in **Azure OpenAI Studio** we need to create two *Deployments*, one using `gpt-4` and another using `text-embedding-ada-002`.\n",
587
        "\n",
588
        "Once we've done this we need to set a few environment variables (all found in **Azure OpenAI Studio**) like so:"
589
      ]
590
    },
591
    {
592
      "cell_type": "code",
593
      "execution_count": 9,
594
      "metadata": {
595
        "id": "deWmOJecfbBr"
596
      },
597
      "outputs": [],
598
      "source": [
599
        "os.environ['OPENAI_API_KEY'] = 'YOUR_OPENAI_API_KEY'\n",
600
        "os.environ['OPENAI_API_TYPE'] = 'azure'\n",
601
        "os.environ['OPENAI_API_VERSION'] = '2023-03-15-preview'\n",
602
        "os.environ['OPENAI_API_BASE'] = 'https://azure-pinecone-demo.openai.azure.com/'"
603
      ]
604
    },
605
    {
606
      "attachments": {},
607
      "cell_type": "markdown",
608
      "metadata": {
609
        "id": "2AWnaTCP0Ryg"
610
      },
611
      "source": [
612
        "We can now connect to both of our deployments via LangChain. First our `ChatCompletion` endpoint which uses `gpt-3.5-turbo`:"
613
      ]
614
    },
615
    {
616
      "cell_type": "code",
617
      "execution_count": 10,
618
      "metadata": {
619
        "id": "ZhQSDoYe0ly4"
620
      },
621
      "outputs": [],
622
      "source": [
623
        "from langchain.chat_models import AzureChatOpenAI\n",
624
        "\n",
625
        "llm = AzureChatOpenAI(\n",
626
        "    deployment_name=\"gpt4\",\n",
627
        "    model_name=\"gpt-4\"\n",
628
        ")"
629
      ]
630
    },
631
    {
632
      "attachments": {},
633
      "cell_type": "markdown",
634
      "metadata": {
635
        "id": "h4WOy6zCyAJF"
636
      },
637
      "source": [
638
        "And then our embedding endpoint which uses `text-embedding-ada-002`:"
639
      ]
640
    },
641
    {
642
      "cell_type": "code",
643
      "execution_count": 11,
644
      "metadata": {
645
        "id": "j10WYSvbyGv8"
646
      },
647
      "outputs": [],
648
      "source": [
649
        "from langchain.embeddings import OpenAIEmbeddings\n",
650
        "\n",
651
        "embed = OpenAIEmbeddings(\n",
652
        "    deployment='embedding',\n",
653
        "    model='text-embedding-ada-002'\n",
654
        ")"
655
      ]
656
    },
657
    {
658
      "attachments": {},
659
      "cell_type": "markdown",
660
      "metadata": {
661
        "id": "gaatTCay96VF"
662
      },
663
      "source": [
664
        "## Initializing Retrieval Component with LangChain"
665
      ]
666
    },
667
    {
668
      "attachments": {},
669
      "cell_type": "markdown",
670
      "metadata": {
671
        "id": "5hUPG7IG9e_8"
672
      },
673
      "source": [
674
        "Before we move on, we must also initialize a connection to our index via LangChain. We need this for compatibility with later LangChain components. To use this we pass the `index` from above into a LangChain `vectorstores.Pinecone` object:"
675
      ]
676
    },
677
    {
678
      "cell_type": "code",
679
      "execution_count": 12,
680
      "metadata": {
681
        "id": "40zQcOJh9yvh"
682
      },
683
      "outputs": [],
684
      "source": [
685
        "from langchain.vectorstores import Pinecone\n",
686
        "\n",
687
        "text_field = \"text\"\n",
688
        "\n",
689
        "# switch back to normal index for langchain\n",
690
        "index = pinecone.Index(index_name)\n",
691
        "\n",
692
        "vectorstore = Pinecone(\n",
693
        "    index, embed.embed_query, text_field\n",
694
        ")"
695
      ]
696
    },
697
    {
698
      "attachments": {},
699
      "cell_type": "markdown",
700
      "metadata": {
701
        "id": "rJ_Xo5GJ9-ej"
702
      },
703
      "source": [
704
        "## Initializing the RetrievalQA Component"
705
      ]
706
    },
707
    {
708
      "attachments": {},
709
      "cell_type": "markdown",
710
      "metadata": {
711
        "id": "yS87i9wa_Ck4"
712
      },
713
      "source": [
714
        "The `RetrievalQA` and `RetrievalQAWithSourcesChain` are both components in LangChain that allow us to ask a natural language query and return a response grounded in the knowledge retrieved from our knowledge base. We can implement this and include original data sources like so:"
715
      ]
716
    },
717
    {
718
      "cell_type": "code",
719
      "execution_count": 13,
720
      "metadata": {
721
        "id": "ZgpuJlYa_VL6"
722
      },
723
      "outputs": [],
724
      "source": [
725
        "from langchain.chains import RetrievalQAWithSourcesChain\n",
726
        "\n",
727
        "qa = RetrievalQAWithSourcesChain.from_chain_type(\n",
728
        "    llm=llm,\n",
729
        "    chain_type=\"stuff\",\n",
730
        "    retriever=vectorstore.as_retriever()\n",
731
        ")"
732
      ]
733
    },
734
    {
735
      "attachments": {},
736
      "cell_type": "markdown",
737
      "metadata": {
738
        "id": "aryiOoS8aLsz"
739
      },
740
      "source": [
741
        "Now we can begin asking questions about LangChain!"
742
      ]
743
    },
744
    {
745
      "cell_type": "code",
746
      "execution_count": 14,
747
      "metadata": {
748
        "colab": {
749
          "base_uri": "https://localhost:8080/"
750
        },
751
        "id": "ICFmRHCV_YiD",
752
        "outputId": "9dc06ba1-c655-49bf-f196-af864705c325"
753
      },
754
      "outputs": [
755
        {
756
          "data": {
757
            "text/plain": [
758
              "{'question': 'can you tell me about the PromptLayer for OpenAI in LangChain?',\n",
759
              " 'answer': 'PromptLayer for OpenAI in LangChain is a middleware that allows developers to track, manage, and share GPT prompt engineering. It records all OpenAI API requests, enabling users to search and explore request history in the PromptLayer dashboard. LangChain provides PromptLayer wrappers for LLM, PromptLayerChatOpenAI, and PromptLayerOpenAIChat. To use PromptLayer within LangChain, you need to install the promptlayer python library, create a PromptLayer account, and create an API token to set as an environment variable (PROMPTLAYER_API_KEY).\\n\\n',\n",
760
              " 'sources': '\\n- https://python.langchain.com/en/latest/integrations/promptlayer.html\\n- https://python.langchain.com/en/latest/modules/models/llms/integrations/promptlayer_openai.html\\n- https://python.langchain.com/en/latest/modules/models/chat/integrations/promptlayer_chatopenai.html'}"
761
            ]
762
          },
763
          "execution_count": 14,
764
          "metadata": {},
765
          "output_type": "execute_result"
766
        }
767
      ],
768
      "source": [
769
        "qa(\"can you tell me about the PromptLayer for OpenAI in LangChain?\")"
770
      ]
771
    },
772
    {
773
      "attachments": {},
774
      "cell_type": "markdown",
775
      "metadata": {
776
        "id": "VoQFiqntaPya"
777
      },
778
      "source": [
779
        "We can format responses nicely like so:"
780
      ]
781
    },
782
    {
783
      "cell_type": "code",
784
      "execution_count": 16,
785
      "metadata": {
786
        "colab": {
787
          "base_uri": "https://localhost:8080/",
788
          "height": 98
789
        },
790
        "id": "kmjmHp0I1pbe",
791
        "outputId": "a825795f-3e5c-4a75-8da9-d4468651bc29"
792
      },
793
      "outputs": [
794
        {
795
          "data": {
796
            "text/markdown": [
797
              "You would use an output parser in LangChain to get more structured information than just text back from language model responses. Output parsers are classes that help structure language model responses by implementing methods to format and parse the output into a desired structure. This can be useful in cases where you need specific data structures or structured information for further processing.\n"
798
            ],
799
            "text/plain": [
800
              "<IPython.core.display.Markdown object>"
801
            ]
802
          },
803
          "metadata": {},
804
          "output_type": "display_data"
805
        },
806
        {
807
          "name": "stdout",
808
          "output_type": "stream",
809
          "text": [
810
            "https://python.langchain.com/docs/modules/model_io/output_parsers/\n"
811
          ]
812
        }
813
      ],
814
      "source": [
815
        "from IPython.display import display, Markdown\n",
816
        "\n",
817
        "res = qa(\"why would I use an output parser in LangChain?\")\n",
818
        "display(Markdown(res['answer']))\n",
819
        "print(res['sources'])"
820
      ]
821
    },
822
    {
823
      "cell_type": "code",
824
      "execution_count": 15,
825
      "metadata": {
826
        "colab": {
827
          "base_uri": "https://localhost:8080/",
828
          "height": 474
829
        },
830
        "id": "trnhMhielMp0",
831
        "outputId": "3fa9dd12-cf3a-4d86-c1f9-dcfb97361b3f"
832
      },
833
      "outputs": [
834
        {
835
          "data": {
836
            "text/markdown": [
837
              "To use output parsers, you need to follow these steps:\n",
838
              "\n",
839
              "1. Choose the output parser that fits your needs, such as PydanticOutputParser, RetryOutputParser, or OutputFixingParser.\n",
840
              "2. Implement the necessary methods in the output parser, such as `get_format_instructions()` and `parse(str)`.\n",
841
              "3. Optionally, implement the `parse_with_prompt(str, PromptValue)` method if you need additional information from the prompt to parse the output.\n",
842
              "4. Use the output parser in your language model code, like in the PromptTemplate or ChatOpenAI.\n",
843
              "\n",
844
              "Example usage with PydanticOutputParser:\n",
845
              "\n",
846
              "```python\n",
847
              "from langchain.prompts import PromptTemplate\n",
848
              "from langchain.llms import OpenAI\n",
849
              "from langchain.output_parsers import PydanticOutputParser\n",
850
              "from pydantic import BaseModel, Field, validator\n",
851
              "\n",
852
              "class Joke(BaseModel):\n",
853
              "    setup: str = Field(description=\"question to set up a joke\")\n",
854
              "    punchline: str = Field(description=\"answer to resolve the joke\")\n",
855
              "\n",
856
              "parser = PydanticOutputParser(pydantic_object=Joke)\n",
857
              "prompt = PromptTemplate(\n",
858
              "    template=\"Your prompt template here\",\n",
859
              "    input_variables=[\"your_input_variables\"],\n",
860
              "    partial_variables={\"format_instructions\": parser.get_format_instructions()}\n",
861
              ")\n",
862
              "```\n",
863
              "\n"
864
            ],
865
            "text/plain": [
866
              "<IPython.core.display.Markdown object>"
867
            ]
868
          },
869
          "metadata": {},
870
          "output_type": "display_data"
871
        },
872
        {
873
          "name": "stdout",
874
          "output_type": "stream",
875
          "text": [
876
            "- https://python.langchain.com/en/latest/modules/prompts/output_parsers.html\n",
877
            "- https://python.langchain.com/docs/modules/model_io/output_parsers/\n",
878
            "- https://python.langchain.com/en/latest/modules/prompts/output_parsers/examples/retry.html\n"
879
          ]
880
        }
881
      ],
882
      "source": [
883
        "from IPython.display import display, Markdown\n",
884
        "\n",
885
        "res = qa(\"how can I use output parsers?\")\n",
886
        "display(Markdown(res['answer']))\n",
887
        "print(res['sources'])"
888
      ]
889
    },
890
    {
891
      "attachments": {},
892
      "cell_type": "markdown",
893
      "metadata": {
894
        "id": "6hKiHbUVaVmR"
895
      },
896
      "source": [
897
        "---"
898
      ]
899
    }
900
  ],
901
  "metadata": {
902
    "colab": {
903
      "provenance": []
904
    },
905
    "kernelspec": {
906
      "display_name": "Python 3",
907
      "name": "python3"
908
    },
909
    "language_info": {
910
      "name": "python",
911
      "version": "3.9.12 (main, Apr  5 2022, 01:52:34) \n[Clang 12.0.0 ]"
912
    },
913
    "orig_nbformat": 4,
914
    "vscode": {
915
      "interpreter": {
916
        "hash": "b8e7999f96e1b425e2d542f21b571f5a4be3e97158b0b46ea1b2500df63956ce"
917
      }
918
    },
919
    "widgets": {
920
      "application/vnd.jupyter.widget-state+json": {
921
        "037cdcbedf9745099dec9c021217f91c": {
922
          "model_module": "@jupyter-widgets/controls",
923
          "model_module_version": "1.5.0",
924
          "model_name": "HTMLModel",
925
          "state": {
926
            "_dom_classes": [],
927
            "_model_module": "@jupyter-widgets/controls",
928
            "_model_module_version": "1.5.0",
929
            "_model_name": "HTMLModel",
930
            "_view_count": null,
931
            "_view_module": "@jupyter-widgets/controls",
932
            "_view_module_version": "1.5.0",
933
            "_view_name": "HTMLView",
934
            "description": "",
935
            "description_tooltip": null,
936
            "layout": "IPY_MODEL_22ea72881fc94694aa7e4511ac2cd528",
937
            "placeholder": "​",
938
            "style": "IPY_MODEL_39fb48d1d26f4ce1a02e5a4854e46312",
939
            "value": "sending upsert requests: 100%"
940
          }
941
        },
942
        "0b4f718f21434759a777e49f7053b432": {
943
          "model_module": "@jupyter-widgets/base",
944
          "model_module_version": "1.2.0",
945
          "model_name": "LayoutModel",
946
          "state": {
947
            "_model_module": "@jupyter-widgets/base",
948
            "_model_module_version": "1.2.0",
949
            "_model_name": "LayoutModel",
950
            "_view_count": null,
951
            "_view_module": "@jupyter-widgets/base",
952
            "_view_module_version": "1.2.0",
953
            "_view_name": "LayoutView",
954
            "align_content": null,
955
            "align_items": null,
956
            "align_self": null,
957
            "border": null,
958
            "bottom": null,
959
            "display": null,
960
            "flex": null,
961
            "flex_flow": null,
962
            "grid_area": null,
963
            "grid_auto_columns": null,
964
            "grid_auto_flow": null,
965
            "grid_auto_rows": null,
966
            "grid_column": null,
967
            "grid_gap": null,
968
            "grid_row": null,
969
            "grid_template_areas": null,
970
            "grid_template_columns": null,
971
            "grid_template_rows": null,
972
            "height": null,
973
            "justify_content": null,
974
            "justify_items": null,
975
            "left": null,
976
            "margin": null,
977
            "max_height": null,
978
            "max_width": null,
979
            "min_height": null,
980
            "min_width": null,
981
            "object_fit": null,
982
            "object_position": null,
983
            "order": null,
984
            "overflow": null,
985
            "overflow_x": null,
986
            "overflow_y": null,
987
            "padding": null,
988
            "right": null,
989
            "top": null,
990
            "visibility": null,
991
            "width": null
992
          }
993
        },
994
        "0e7d09a428d04caca8bd83f8f436621d": {
995
          "model_module": "@jupyter-widgets/controls",
996
          "model_module_version": "1.5.0",
997
          "model_name": "ProgressStyleModel",
998
          "state": {
999
            "_model_module": "@jupyter-widgets/controls",
1000
            "_model_module_version": "1.5.0",
1001
            "_model_name": "ProgressStyleModel",
1002
            "_view_count": null,
1003
            "_view_module": "@jupyter-widgets/base",
1004
            "_view_module_version": "1.2.0",
1005
            "_view_name": "StyleView",
1006
            "bar_color": null,
1007
            "description_width": ""
1008
          }
1009
        },
1010
        "14693a607c7042a98364f3f6d7c0cd0c": {
1011
          "model_module": "@jupyter-widgets/controls",
1012
          "model_module_version": "1.5.0",
1013
          "model_name": "ProgressStyleModel",
1014
          "state": {
1015
            "_model_module": "@jupyter-widgets/controls",
1016
            "_model_module_version": "1.5.0",
1017
            "_model_name": "ProgressStyleModel",
1018
            "_view_count": null,
1019
            "_view_module": "@jupyter-widgets/base",
1020
            "_view_module_version": "1.2.0",
1021
            "_view_name": "StyleView",
1022
            "bar_color": null,
1023
            "description_width": ""
1024
          }
1025
        },
1026
        "21aa8b33791e44f797cf4ea6862460b2": {
1027
          "model_module": "@jupyter-widgets/controls",
1028
          "model_module_version": "1.5.0",
1029
          "model_name": "HTMLModel",
1030
          "state": {
1031
            "_dom_classes": [],
1032
            "_model_module": "@jupyter-widgets/controls",
1033
            "_model_module_version": "1.5.0",
1034
            "_model_name": "HTMLModel",
1035
            "_view_count": null,
1036
            "_view_module": "@jupyter-widgets/controls",
1037
            "_view_module_version": "1.5.0",
1038
            "_view_name": "HTMLView",
1039
            "description": "",
1040
            "description_tooltip": null,
1041
            "layout": "IPY_MODEL_3ec8c293047c438d91405f51cef54875",
1042
            "placeholder": "​",
1043
            "style": "IPY_MODEL_442ac390a53c43e7b37c4ff9663a4565",
1044
            "value": " 6952/6952 [00:06&lt;00:00, 895.46it/s]"
1045
          }
1046
        },
1047
        "22ea72881fc94694aa7e4511ac2cd528": {
1048
          "model_module": "@jupyter-widgets/base",
1049
          "model_module_version": "1.2.0",
1050
          "model_name": "LayoutModel",
1051
          "state": {
1052
            "_model_module": "@jupyter-widgets/base",
1053
            "_model_module_version": "1.2.0",
1054
            "_model_name": "LayoutModel",
1055
            "_view_count": null,
1056
            "_view_module": "@jupyter-widgets/base",
1057
            "_view_module_version": "1.2.0",
1058
            "_view_name": "LayoutView",
1059
            "align_content": null,
1060
            "align_items": null,
1061
            "align_self": null,
1062
            "border": null,
1063
            "bottom": null,
1064
            "display": null,
1065
            "flex": null,
1066
            "flex_flow": null,
1067
            "grid_area": null,
1068
            "grid_auto_columns": null,
1069
            "grid_auto_flow": null,
1070
            "grid_auto_rows": null,
1071
            "grid_column": null,
1072
            "grid_gap": null,
1073
            "grid_row": null,
1074
            "grid_template_areas": null,
1075
            "grid_template_columns": null,
1076
            "grid_template_rows": null,
1077
            "height": null,
1078
            "justify_content": null,
1079
            "justify_items": null,
1080
            "left": null,
1081
            "margin": null,
1082
            "max_height": null,
1083
            "max_width": null,
1084
            "min_height": null,
1085
            "min_width": null,
1086
            "object_fit": null,
1087
            "object_position": null,
1088
            "order": null,
1089
            "overflow": null,
1090
            "overflow_x": null,
1091
            "overflow_y": null,
1092
            "padding": null,
1093
            "right": null,
1094
            "top": null,
1095
            "visibility": null,
1096
            "width": null
1097
          }
1098
        },
1099
        "253d5a11c0b948f29cc4cb528300295c": {
1100
          "model_module": "@jupyter-widgets/controls",
1101
          "model_module_version": "1.5.0",
1102
          "model_name": "DescriptionStyleModel",
1103
          "state": {
1104
            "_model_module": "@jupyter-widgets/controls",
1105
            "_model_module_version": "1.5.0",
1106
            "_model_name": "DescriptionStyleModel",
1107
            "_view_count": null,
1108
            "_view_module": "@jupyter-widgets/base",
1109
            "_view_module_version": "1.2.0",
1110
            "_view_name": "StyleView",
1111
            "description_width": ""
1112
          }
1113
        },
1114
        "28c1711a93294f38b477cf46621d22d5": {
1115
          "model_module": "@jupyter-widgets/controls",
1116
          "model_module_version": "1.5.0",
1117
          "model_name": "HTMLModel",
1118
          "state": {
1119
            "_dom_classes": [],
1120
            "_model_module": "@jupyter-widgets/controls",
1121
            "_model_module_version": "1.5.0",
1122
            "_model_name": "HTMLModel",
1123
            "_view_count": null,
1124
            "_view_module": "@jupyter-widgets/controls",
1125
            "_view_module_version": "1.5.0",
1126
            "_view_name": "HTMLView",
1127
            "description": "",
1128
            "description_tooltip": null,
1129
            "layout": "IPY_MODEL_90250c5b719c4c66b30ae2c68ffa0b49",
1130
            "placeholder": "​",
1131
            "style": "IPY_MODEL_3d6aea5e4ac148e2942a9e99cc4db8a2",
1132
            "value": " 70/70 [00:00&lt;00:00, 908.75it/s]"
1133
          }
1134
        },
1135
        "39fb48d1d26f4ce1a02e5a4854e46312": {
1136
          "model_module": "@jupyter-widgets/controls",
1137
          "model_module_version": "1.5.0",
1138
          "model_name": "DescriptionStyleModel",
1139
          "state": {
1140
            "_model_module": "@jupyter-widgets/controls",
1141
            "_model_module_version": "1.5.0",
1142
            "_model_name": "DescriptionStyleModel",
1143
            "_view_count": null,
1144
            "_view_module": "@jupyter-widgets/base",
1145
            "_view_module_version": "1.2.0",
1146
            "_view_name": "StyleView",
1147
            "description_width": ""
1148
          }
1149
        },
1150
        "3d6aea5e4ac148e2942a9e99cc4db8a2": {
1151
          "model_module": "@jupyter-widgets/controls",
1152
          "model_module_version": "1.5.0",
1153
          "model_name": "DescriptionStyleModel",
1154
          "state": {
1155
            "_model_module": "@jupyter-widgets/controls",
1156
            "_model_module_version": "1.5.0",
1157
            "_model_name": "DescriptionStyleModel",
1158
            "_view_count": null,
1159
            "_view_module": "@jupyter-widgets/base",
1160
            "_view_module_version": "1.2.0",
1161
            "_view_name": "StyleView",
1162
            "description_width": ""
1163
          }
1164
        },
1165
        "3ec8c293047c438d91405f51cef54875": {
1166
          "model_module": "@jupyter-widgets/base",
1167
          "model_module_version": "1.2.0",
1168
          "model_name": "LayoutModel",
1169
          "state": {
1170
            "_model_module": "@jupyter-widgets/base",
1171
            "_model_module_version": "1.2.0",
1172
            "_model_name": "LayoutModel",
1173
            "_view_count": null,
1174
            "_view_module": "@jupyter-widgets/base",
1175
            "_view_module_version": "1.2.0",
1176
            "_view_name": "LayoutView",
1177
            "align_content": null,
1178
            "align_items": null,
1179
            "align_self": null,
1180
            "border": null,
1181
            "bottom": null,
1182
            "display": null,
1183
            "flex": null,
1184
            "flex_flow": null,
1185
            "grid_area": null,
1186
            "grid_auto_columns": null,
1187
            "grid_auto_flow": null,
1188
            "grid_auto_rows": null,
1189
            "grid_column": null,
1190
            "grid_gap": null,
1191
            "grid_row": null,
1192
            "grid_template_areas": null,
1193
            "grid_template_columns": null,
1194
            "grid_template_rows": null,
1195
            "height": null,
1196
            "justify_content": null,
1197
            "justify_items": null,
1198
            "left": null,
1199
            "margin": null,
1200
            "max_height": null,
1201
            "max_width": null,
1202
            "min_height": null,
1203
            "min_width": null,
1204
            "object_fit": null,
1205
            "object_position": null,
1206
            "order": null,
1207
            "overflow": null,
1208
            "overflow_x": null,
1209
            "overflow_y": null,
1210
            "padding": null,
1211
            "right": null,
1212
            "top": null,
1213
            "visibility": null,
1214
            "width": null
1215
          }
1216
        },
1217
        "41d03cbe02284448b5792da6137da533": {
1218
          "model_module": "@jupyter-widgets/base",
1219
          "model_module_version": "1.2.0",
1220
          "model_name": "LayoutModel",
1221
          "state": {
1222
            "_model_module": "@jupyter-widgets/base",
1223
            "_model_module_version": "1.2.0",
1224
            "_model_name": "LayoutModel",
1225
            "_view_count": null,
1226
            "_view_module": "@jupyter-widgets/base",
1227
            "_view_module_version": "1.2.0",
1228
            "_view_name": "LayoutView",
1229
            "align_content": null,
1230
            "align_items": null,
1231
            "align_self": null,
1232
            "border": null,
1233
            "bottom": null,
1234
            "display": null,
1235
            "flex": null,
1236
            "flex_flow": null,
1237
            "grid_area": null,
1238
            "grid_auto_columns": null,
1239
            "grid_auto_flow": null,
1240
            "grid_auto_rows": null,
1241
            "grid_column": null,
1242
            "grid_gap": null,
1243
            "grid_row": null,
1244
            "grid_template_areas": null,
1245
            "grid_template_columns": null,
1246
            "grid_template_rows": null,
1247
            "height": null,
1248
            "justify_content": null,
1249
            "justify_items": null,
1250
            "left": null,
1251
            "margin": null,
1252
            "max_height": null,
1253
            "max_width": null,
1254
            "min_height": null,
1255
            "min_width": null,
1256
            "object_fit": null,
1257
            "object_position": null,
1258
            "order": null,
1259
            "overflow": null,
1260
            "overflow_x": null,
1261
            "overflow_y": null,
1262
            "padding": null,
1263
            "right": null,
1264
            "top": null,
1265
            "visibility": null,
1266
            "width": null
1267
          }
1268
        },
1269
        "442ac390a53c43e7b37c4ff9663a4565": {
1270
          "model_module": "@jupyter-widgets/controls",
1271
          "model_module_version": "1.5.0",
1272
          "model_name": "DescriptionStyleModel",
1273
          "state": {
1274
            "_model_module": "@jupyter-widgets/controls",
1275
            "_model_module_version": "1.5.0",
1276
            "_model_name": "DescriptionStyleModel",
1277
            "_view_count": null,
1278
            "_view_module": "@jupyter-widgets/base",
1279
            "_view_module_version": "1.2.0",
1280
            "_view_name": "StyleView",
1281
            "description_width": ""
1282
          }
1283
        },
1284
        "790bcea9241e4c9bb2cdfe2177cdba52": {
1285
          "model_module": "@jupyter-widgets/controls",
1286
          "model_module_version": "1.5.0",
1287
          "model_name": "FloatProgressModel",
1288
          "state": {
1289
            "_dom_classes": [],
1290
            "_model_module": "@jupyter-widgets/controls",
1291
            "_model_module_version": "1.5.0",
1292
            "_model_name": "FloatProgressModel",
1293
            "_view_count": null,
1294
            "_view_module": "@jupyter-widgets/controls",
1295
            "_view_module_version": "1.5.0",
1296
            "_view_name": "ProgressView",
1297
            "bar_style": "success",
1298
            "description": "",
1299
            "description_tooltip": null,
1300
            "layout": "IPY_MODEL_a59445fb528b45dc9943545f24ae3543",
1301
            "max": 70,
1302
            "min": 0,
1303
            "orientation": "horizontal",
1304
            "style": "IPY_MODEL_0e7d09a428d04caca8bd83f8f436621d",
1305
            "value": 70
1306
          }
1307
        },
1308
        "90250c5b719c4c66b30ae2c68ffa0b49": {
1309
          "model_module": "@jupyter-widgets/base",
1310
          "model_module_version": "1.2.0",
1311
          "model_name": "LayoutModel",
1312
          "state": {
1313
            "_model_module": "@jupyter-widgets/base",
1314
            "_model_module_version": "1.2.0",
1315
            "_model_name": "LayoutModel",
1316
            "_view_count": null,
1317
            "_view_module": "@jupyter-widgets/base",
1318
            "_view_module_version": "1.2.0",
1319
            "_view_name": "LayoutView",
1320
            "align_content": null,
1321
            "align_items": null,
1322
            "align_self": null,
1323
            "border": null,
1324
            "bottom": null,
1325
            "display": null,
1326
            "flex": null,
1327
            "flex_flow": null,
1328
            "grid_area": null,
1329
            "grid_auto_columns": null,
1330
            "grid_auto_flow": null,
1331
            "grid_auto_rows": null,
1332
            "grid_column": null,
1333
            "grid_gap": null,
1334
            "grid_row": null,
1335
            "grid_template_areas": null,
1336
            "grid_template_columns": null,
1337
            "grid_template_rows": null,
1338
            "height": null,
1339
            "justify_content": null,
1340
            "justify_items": null,
1341
            "left": null,
1342
            "margin": null,
1343
            "max_height": null,
1344
            "max_width": null,
1345
            "min_height": null,
1346
            "min_width": null,
1347
            "object_fit": null,
1348
            "object_position": null,
1349
            "order": null,
1350
            "overflow": null,
1351
            "overflow_x": null,
1352
            "overflow_y": null,
1353
            "padding": null,
1354
            "right": null,
1355
            "top": null,
1356
            "visibility": null,
1357
            "width": null
1358
          }
1359
        },
1360
        "938e8a4b843043cb8350fbe714a6d83e": {
1361
          "model_module": "@jupyter-widgets/base",
1362
          "model_module_version": "1.2.0",
1363
          "model_name": "LayoutModel",
1364
          "state": {
1365
            "_model_module": "@jupyter-widgets/base",
1366
            "_model_module_version": "1.2.0",
1367
            "_model_name": "LayoutModel",
1368
            "_view_count": null,
1369
            "_view_module": "@jupyter-widgets/base",
1370
            "_view_module_version": "1.2.0",
1371
            "_view_name": "LayoutView",
1372
            "align_content": null,
1373
            "align_items": null,
1374
            "align_self": null,
1375
            "border": null,
1376
            "bottom": null,
1377
            "display": null,
1378
            "flex": null,
1379
            "flex_flow": null,
1380
            "grid_area": null,
1381
            "grid_auto_columns": null,
1382
            "grid_auto_flow": null,
1383
            "grid_auto_rows": null,
1384
            "grid_column": null,
1385
            "grid_gap": null,
1386
            "grid_row": null,
1387
            "grid_template_areas": null,
1388
            "grid_template_columns": null,
1389
            "grid_template_rows": null,
1390
            "height": null,
1391
            "justify_content": null,
1392
            "justify_items": null,
1393
            "left": null,
1394
            "margin": null,
1395
            "max_height": null,
1396
            "max_width": null,
1397
            "min_height": null,
1398
            "min_width": null,
1399
            "object_fit": null,
1400
            "object_position": null,
1401
            "order": null,
1402
            "overflow": null,
1403
            "overflow_x": null,
1404
            "overflow_y": null,
1405
            "padding": null,
1406
            "right": null,
1407
            "top": null,
1408
            "visibility": null,
1409
            "width": null
1410
          }
1411
        },
1412
        "99fb6f80660d491c9c0b35b61756407a": {
1413
          "model_module": "@jupyter-widgets/controls",
1414
          "model_module_version": "1.5.0",
1415
          "model_name": "HBoxModel",
1416
          "state": {
1417
            "_dom_classes": [],
1418
            "_model_module": "@jupyter-widgets/controls",
1419
            "_model_module_version": "1.5.0",
1420
            "_model_name": "HBoxModel",
1421
            "_view_count": null,
1422
            "_view_module": "@jupyter-widgets/controls",
1423
            "_view_module_version": "1.5.0",
1424
            "_view_name": "HBoxView",
1425
            "box_style": "",
1426
            "children": [
1427
              "IPY_MODEL_a4edbd751a0d497b98d3bd9af4f8444b",
1428
              "IPY_MODEL_790bcea9241e4c9bb2cdfe2177cdba52",
1429
              "IPY_MODEL_28c1711a93294f38b477cf46621d22d5"
1430
            ],
1431
            "layout": "IPY_MODEL_938e8a4b843043cb8350fbe714a6d83e"
1432
          }
1433
        },
1434
        "9c272465c73c401daf0e323b49c145a8": {
1435
          "model_module": "@jupyter-widgets/controls",
1436
          "model_module_version": "1.5.0",
1437
          "model_name": "FloatProgressModel",
1438
          "state": {
1439
            "_dom_classes": [],
1440
            "_model_module": "@jupyter-widgets/controls",
1441
            "_model_module_version": "1.5.0",
1442
            "_model_name": "FloatProgressModel",
1443
            "_view_count": null,
1444
            "_view_module": "@jupyter-widgets/controls",
1445
            "_view_module_version": "1.5.0",
1446
            "_view_name": "ProgressView",
1447
            "bar_style": "success",
1448
            "description": "",
1449
            "description_tooltip": null,
1450
            "layout": "IPY_MODEL_0b4f718f21434759a777e49f7053b432",
1451
            "max": 6952,
1452
            "min": 0,
1453
            "orientation": "horizontal",
1454
            "style": "IPY_MODEL_14693a607c7042a98364f3f6d7c0cd0c",
1455
            "value": 6952
1456
          }
1457
        },
1458
        "a4edbd751a0d497b98d3bd9af4f8444b": {
1459
          "model_module": "@jupyter-widgets/controls",
1460
          "model_module_version": "1.5.0",
1461
          "model_name": "HTMLModel",
1462
          "state": {
1463
            "_dom_classes": [],
1464
            "_model_module": "@jupyter-widgets/controls",
1465
            "_model_module_version": "1.5.0",
1466
            "_model_name": "HTMLModel",
1467
            "_view_count": null,
1468
            "_view_module": "@jupyter-widgets/controls",
1469
            "_view_module_version": "1.5.0",
1470
            "_view_name": "HTMLView",
1471
            "description": "",
1472
            "description_tooltip": null,
1473
            "layout": "IPY_MODEL_41d03cbe02284448b5792da6137da533",
1474
            "placeholder": "​",
1475
            "style": "IPY_MODEL_253d5a11c0b948f29cc4cb528300295c",
1476
            "value": "collecting async responses: 100%"
1477
          }
1478
        },
1479
        "a59445fb528b45dc9943545f24ae3543": {
1480
          "model_module": "@jupyter-widgets/base",
1481
          "model_module_version": "1.2.0",
1482
          "model_name": "LayoutModel",
1483
          "state": {
1484
            "_model_module": "@jupyter-widgets/base",
1485
            "_model_module_version": "1.2.0",
1486
            "_model_name": "LayoutModel",
1487
            "_view_count": null,
1488
            "_view_module": "@jupyter-widgets/base",
1489
            "_view_module_version": "1.2.0",
1490
            "_view_name": "LayoutView",
1491
            "align_content": null,
1492
            "align_items": null,
1493
            "align_self": null,
1494
            "border": null,
1495
            "bottom": null,
1496
            "display": null,
1497
            "flex": null,
1498
            "flex_flow": null,
1499
            "grid_area": null,
1500
            "grid_auto_columns": null,
1501
            "grid_auto_flow": null,
1502
            "grid_auto_rows": null,
1503
            "grid_column": null,
1504
            "grid_gap": null,
1505
            "grid_row": null,
1506
            "grid_template_areas": null,
1507
            "grid_template_columns": null,
1508
            "grid_template_rows": null,
1509
            "height": null,
1510
            "justify_content": null,
1511
            "justify_items": null,
1512
            "left": null,
1513
            "margin": null,
1514
            "max_height": null,
1515
            "max_width": null,
1516
            "min_height": null,
1517
            "min_width": null,
1518
            "object_fit": null,
1519
            "object_position": null,
1520
            "order": null,
1521
            "overflow": null,
1522
            "overflow_x": null,
1523
            "overflow_y": null,
1524
            "padding": null,
1525
            "right": null,
1526
            "top": null,
1527
            "visibility": null,
1528
            "width": null
1529
          }
1530
        },
1531
        "bb4b1deb4d324c459ecc58ff987923ac": {
1532
          "model_module": "@jupyter-widgets/controls",
1533
          "model_module_version": "1.5.0",
1534
          "model_name": "HBoxModel",
1535
          "state": {
1536
            "_dom_classes": [],
1537
            "_model_module": "@jupyter-widgets/controls",
1538
            "_model_module_version": "1.5.0",
1539
            "_model_name": "HBoxModel",
1540
            "_view_count": null,
1541
            "_view_module": "@jupyter-widgets/controls",
1542
            "_view_module_version": "1.5.0",
1543
            "_view_name": "HBoxView",
1544
            "box_style": "",
1545
            "children": [
1546
              "IPY_MODEL_037cdcbedf9745099dec9c021217f91c",
1547
              "IPY_MODEL_9c272465c73c401daf0e323b49c145a8",
1548
              "IPY_MODEL_21aa8b33791e44f797cf4ea6862460b2"
1549
            ],
1550
            "layout": "IPY_MODEL_e701b82c73db4a0abe8a50d6efa2454a"
1551
          }
1552
        },
1553
        "e701b82c73db4a0abe8a50d6efa2454a": {
1554
          "model_module": "@jupyter-widgets/base",
1555
          "model_module_version": "1.2.0",
1556
          "model_name": "LayoutModel",
1557
          "state": {
1558
            "_model_module": "@jupyter-widgets/base",
1559
            "_model_module_version": "1.2.0",
1560
            "_model_name": "LayoutModel",
1561
            "_view_count": null,
1562
            "_view_module": "@jupyter-widgets/base",
1563
            "_view_module_version": "1.2.0",
1564
            "_view_name": "LayoutView",
1565
            "align_content": null,
1566
            "align_items": null,
1567
            "align_self": null,
1568
            "border": null,
1569
            "bottom": null,
1570
            "display": null,
1571
            "flex": null,
1572
            "flex_flow": null,
1573
            "grid_area": null,
1574
            "grid_auto_columns": null,
1575
            "grid_auto_flow": null,
1576
            "grid_auto_rows": null,
1577
            "grid_column": null,
1578
            "grid_gap": null,
1579
            "grid_row": null,
1580
            "grid_template_areas": null,
1581
            "grid_template_columns": null,
1582
            "grid_template_rows": null,
1583
            "height": null,
1584
            "justify_content": null,
1585
            "justify_items": null,
1586
            "left": null,
1587
            "margin": null,
1588
            "max_height": null,
1589
            "max_width": null,
1590
            "min_height": null,
1591
            "min_width": null,
1592
            "object_fit": null,
1593
            "object_position": null,
1594
            "order": null,
1595
            "overflow": null,
1596
            "overflow_x": null,
1597
            "overflow_y": null,
1598
            "padding": null,
1599
            "right": null,
1600
            "top": null,
1601
            "visibility": null,
1602
            "width": null
1603
          }
1604
        }
1605
      }
1606
    }
1607
  },
1608
  "nbformat": 4,
1609
  "nbformat_minor": 0
1610
}
1611

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.