1 00:00:00,310 --> 00:00:03,860 Let's go ahead and talk about PyCon indexes. 2 00:00:04,790 --> 00:00:07,220 An index is the highest level 3 00:00:07,230 --> 00:00:11,000 organizational unit of vector data in PyCon. 4 00:00:11,810 --> 00:00:16,100 It accepts and stores vectors, serves 5 00:00:16,110 --> 00:00:23,020 queries over the vectors it contains and does other vector operations over its contents. 6 00:00:24,250 --> 00:00:29,900 There are currently serverless indexes and pod -based indexes. 7 00:00:30,830 --> 00:00:36,120 Pods are pre -configured units of hardware for running a PyCon service. 8 00:00:37,390 --> 00:00:43,000 With serverless indexes, you don't configure or manage any compute or 9 00:00:43,010 --> 00:00:44,160 storage resources. 10 00:00:45,170 --> 00:00:48,520 Instead, serverless indexes scale 11 00:00:48,530 --> 00:00:54,860 automatically based on usage and you pay only for the amount of data stored and 12 00:00:54,870 --> 00:00:57,960 operations performed with no minimums. 13 00:00:58,130 --> 00:01:01,140 With pod -based indexes, you choose one 14 00:01:01,150 --> 00:01:05,120 or more pre -configured units of hardware called pods. 15 00:01:05,770 --> 00:01:11,960 Depending on the pod type, pod size and the number of pods used, you get a 16 00:01:11,970 --> 00:01:17,000 different amount of storage and higher or lower latency and throughput. 17 00:01:18,190 --> 00:01:23,520 In this section, we'll use the free starter plan which is suitable for trying 18 00:01:23,530 --> 00:01:25,380 out and for small applications. 19 00:01:26,210 --> 00:01:28,660 Currently, on the free starter plan, you 20 00:01:28,670 --> 00:01:35,700 get one project with up to 5 serverless indexes and up to 100 namespaces per index. 21 00:01:36,190 --> 00:01:42,660 This allows you to store nearly 300 ,000 vectors which is enough for tasks and 22 00:01:42,670 --> 00:01:43,400 small projects. 23 00:01:43,910 --> 00:01:45,780 If you need more, you'll have to upgrade 24 00:01:45,790 --> 00:01:46,820 to a paid plan. 25 00:01:47,870 --> 00:01:52,180 We are authenticated to Pinecon, so let's 26 00:01:52,190 --> 00:01:54,740 see some information about all indexes. 27 00:01:55,970 --> 00:01:59,660 Call PC .ListIndexes to get a complete 28 00:01:59,670 --> 00:02:02,640 description of all indexes in a project. 29 00:02:05,510 --> 00:02:07,660 Note that this is a list of dictionaries 30 00:02:07,670 --> 00:02:16,160 and you can access the name of the first index using PC .ListIndexes of 0. 31 00:02:16,170 --> 00:02:23,680 And you can access its name by accessing the value of the name key. 32 00:02:25,030 --> 00:02:27,500 This is the name of my index. 33 00:02:31,800 --> 00:02:35,730 This is equivalent to PC .DescribeIndex 34 00:02:35,740 --> 00:02:40,440 and the name of the index, Langchain. 35 00:02:43,850 --> 00:02:47,090 To display all index names, you can also 36 00:02:47,100 --> 00:02:48,790 call the names method. 37 00:02:50,000 --> 00:02:54,650 PC .ListIndexes .Names. 38 00:02:58,950 --> 00:03:01,700 Let's go ahead and create a Pinecon index. 39 00:03:02,270 --> 00:03:05,500 I'll import the serverlessSpec class from 40 00:03:05,510 --> 00:03:06,420 the Pinecon library. 41 00:03:06,870 --> 00:03:09,900 It is necessary to deploy a serverless index. 42 00:03:10,730 --> 00:03:15,600 From Pinecon, import serverlessSpec. 43 00:03:19,160 --> 00:03:22,130 Since I am using the free plan, I am 44 00:03:22,140 --> 00:03:24,270 allowed to have up to 5 indexes. 45 00:03:24,880 --> 00:03:27,770 In the Pinecon web console, check that 46 00:03:27,780 --> 00:03:28,490 you don't have more. 47 00:03:29,220 --> 00:03:31,970 In this example, I will remove the 48 00:03:31,980 --> 00:03:35,770 existing index called Langchain and recreate it. 49 00:03:44,080 --> 00:03:46,890 I will create a new index called Langchain. 50 00:03:49,870 --> 00:03:51,900 indexName equals Langchain. 51 00:03:51,910 --> 00:03:56,020 I will create it only if it doesn't already exist. 52 00:03:56,550 --> 00:04:16,700 So if indexName not in PC .ListIndexes .Names, I am printing a message for the user. 53 00:04:17,570 --> 00:04:19,320 It will be an F string. 54 00:04:19,930 --> 00:04:25,630 Creating index and indexName in curly braces. 55 00:04:28,210 --> 00:04:34,600 Now, I am calling PC .CreateIndex with the following arguments. 56 00:04:35,190 --> 00:04:36,760 Name equals indexName. 57 00:04:39,680 --> 00:04:43,650 Dimension equals 1536. 58 00:04:47,980 --> 00:04:53,330 This is the default dimension for text embedding 3small, one of the recommended 59 00:04:53,340 --> 00:04:55,370 OpenACE embedding models. 60 00:04:57,200 --> 00:04:59,930 Metric equals cosine. 61 00:05:01,850 --> 00:05:06,490 This is the algorithm used to calculate the distance between vectors. 62 00:05:08,940 --> 00:05:24,120 And the spec equals serverlessSpec of cloud equals AWS and the region equals US 63 00:05:24,130 --> 00:05:25,100 East 1. 64 00:05:27,740 --> 00:05:30,710 Check for other available regions in the 65 00:05:30,720 --> 00:05:31,690 Pinecon documentation. 66 00:05:32,360 --> 00:05:36,330 And I am printing the message index created. 67 00:05:39,170 --> 00:05:40,980 Now, the else branch. 68 00:05:41,570 --> 00:05:45,660 If the index already exists, print 69 00:05:45,670 --> 00:05:54,570 indexName in curly braces already exists. 70 00:05:59,360 --> 00:06:00,370 Very well. 71 00:06:00,740 --> 00:06:02,310 I am running the code. 72 00:06:04,540 --> 00:06:06,470 It is creating the index. 73 00:06:08,720 --> 00:06:14,370 The index was created and I can check it on the Pinecon web console. 74 00:06:17,470 --> 00:06:18,900 I am refreshing the page. 75 00:06:21,860 --> 00:06:24,070 Take a look, the index is here. 76 00:06:25,680 --> 00:06:29,070 Let's go ahead and take a look at how to delete an index. 77 00:06:30,920 --> 00:06:34,110 So, indexName equals lengthchain. 78 00:06:36,180 --> 00:06:38,920 First, I will check that the index 79 00:06:38,930 --> 00:06:39,900 already exists. 80 00:06:41,330 --> 00:06:46,510 If indexName in PC .list .indexes .names, 81 00:06:51,240 --> 00:06:55,790 I am printing a message and deleting the index. 82 00:06:56,360 --> 00:07:01,870 Deleting index and the indexName in curly braces. 83 00:07:01,880 --> 00:07:15,830 And I am calling the deleteIndex method with the indexName as an argument. 84 00:07:18,580 --> 00:07:19,510 And done. 85 00:07:22,170 --> 00:07:26,200 Else, if the index doesn't exist, I am 86 00:07:26,210 --> 00:07:27,120 just printing a message. 87 00:07:30,210 --> 00:07:37,520 index, indexName does not exist. 88 00:07:39,530 --> 00:07:42,980 The name of the variable is index underlined name. 89 00:07:43,330 --> 00:07:44,380 I am running the code. 90 00:07:45,130 --> 00:07:47,460 It is deleting the index. 91 00:07:47,470 --> 00:07:54,700 And I am refreshing the web page. 92 00:07:58,380 --> 00:08:00,110 There are no indexes available. 93 00:08:00,780 --> 00:08:03,790 I am creating the index again. 94 00:08:06,210 --> 00:08:07,060 It is creating it. 95 00:08:08,970 --> 00:08:13,920 To perform any operation with an index, you must first select it. 96 00:08:14,450 --> 00:08:24,360 To select an index, use PC .index and provide the indexName as an argument. 97 00:08:27,150 --> 00:08:30,620 This method will return an object of type index. 98 00:08:31,910 --> 00:08:35,140 Here, I am selecting the index and 99 00:08:35,150 --> 00:08:41,140 displaying some statistics about it, including the dimension and total vector count. 100 00:08:41,770 --> 00:08:45,520 index .describeIndexStacks. 101 00:08:50,000 --> 00:08:53,270 This operation provides statistics about 102 00:08:53,280 --> 00:08:59,070 the contents of an index, such as the vector count per namespace, the number of 103 00:08:59,080 --> 00:09:01,650 dimensions and the index fullness. 104 00:09:03,240 --> 00:09:05,930 Keep in mind that serverless indexes 105 00:09:05,940 --> 00:09:13,130 automatically scale as needed, so index fullness mainly applies to pod -based indexes. 106 00:09:14,300 --> 00:09:15,170 That is all for now. 107 00:09:15,760 --> 00:09:18,150 In this video, you have learned how to 108 00:09:18,160 --> 00:09:25,070 work with PyCon indexes, creating, deleting and retrieving information and stacks. 109 00:09:25,460 --> 00:09:28,690 Next up, we will dive into working with vectors.