CommencerCommencer gratuitement

Fetching vectors

In this exercise, you've been provided with a list of ids containing IDs of different records in your 'datacamp-index' index. You'll use these IDs to retrieve the associated records and explore their metadata.

Cet exercice fait partie du cours

Vector Databases for Embeddings with Pinecone

Afficher le cours

Instructions

  • Initialize the Pinecone connection with your API key.
  • Retrieve the vectors with IDs in the ids list from the connected index.
  • Create a list of dictionaries containing the metadata from each record in fetched_vectors.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')
ids = ['2', '5', '8']

# Fetch the vectors from the connected Pinecone index
fetched_vectors = ____

# Extract the metadata from each result in fetched_vectors
metadatas = [fetched_vectors['____'][____]['____'] for id in ids]
print(metadatas)
Modifier et exécuter le code