0
0
LangChainframework~10 mins

Pinecone cloud vector store in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the Pinecone client with your API key.

LangChain
import pinecone
pinecone.init(api_key=[1])
Drag options to blanks, or click blank then click option'
Aapi_key
B"your-api-key"
C12345
Dpinecone_key
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the API key without quotes
Using a variable name instead of the key string
2fill in blank
medium

Complete the code to create a Pinecone index named 'example-index' with dimension 128.

LangChain
pinecone.create_index(name=[1], dimension=128)
Drag options to blanks, or click blank then click option'
A"example-index"
B"myindex"
Cexample_index
D'index128'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes
Wrong index name string
3fill in blank
hard

Fix the error in the code to connect to an existing Pinecone index named 'example-index'.

LangChain
index = pinecone.Index([1])
Drag options to blanks, or click blank then click option'
Aexample-index
B'index-example'
C"example-index"
Dindex_name
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the name without quotes
Using a wrong index name string
4fill in blank
hard

Fill both blanks to upsert vectors into the Pinecone index.

LangChain
vectors = [("id1", [0.1, 0.2, 0.3], [1])]
index.upsert(vectors=[2])
Drag options to blanks, or click blank then click option'
Ametadata
Bvectors
C['meta']
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Passing wrong variable names
Using list literals instead of variable names
5fill in blank
hard

Fill all three blanks to query the Pinecone index for top 3 matches with a vector.

LangChain
query_response = index.query(
  vector=[1],
  top_k=[2],
  include_metadata=[3]
)
Drag options to blanks, or click blank then click option'
A[0.1, 0.2, 0.3]
B3
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Passing vector as a string
Wrong top_k number
Forgetting to include metadata