In our last video, we discussed vector databases, what they are and why they are
essential for LLM applications.
In this lecture, we ll delve into
Pinecone, which is one of the most popular vector databases out there.
Pinecone is a high -performance, scalable and distributed distributed vector store
designed for LLMs.
To use it, you ll need an API key for authentication.
First, head over to pinecone .io and sign up for a free account.
Once you are logged in, navigate to the API Keys section to generate a new key.
Enter a name for the key and generate it.
Copy this key to your clipboard and
create a variable in your .tnv file named pinecone -api -key with the value of the key.
In my case, I am opening the .tnv file from the project directory and appending
the following line pinecone -api -key equals and the key between double quotes.
I am saving the file.
Remember, it s crucial to keep all your
keys secure.
After recording this video, I ll delete
this key just as I ll do for any other keys used in this project.
Next, I ll load the keys from the .tnv file as environment variables using
python .tnv.
Make sure that you have installed the
pinecone -client library, if not, run pip install -q pinecone -client.
To upgrade the library to its latest version, run pip install -upgrade -q
pinecone -client and to display the version of the installed library, run pip
show pinecone -client.
With the new client, import the pinecone class.
It is written with a capital P.
Next, I will instantiate an object of the
pinecone class, pc equals and I am calling the constructor.
This constructor expects an environment variable called pinecone -api -key.
If you ve already created and loaded such a variable into memory as we did, the
authentication is automatically handled.
However, if you haven t loaded the
environment variable, you should explicitly pass an argument named api
-key with your keys value to the pinecone constructor.
Like this, api -key equals and your api -key.
After creating the pinecone instance, you can check if it is successfully connected
by attempting to perform an operation that requires authentication.
For instance, you can create an index or list all existing indexes.
If the operation completes without errors, your authentication is working.
It completed without errors, so the authentication is working.