Index.query() got multiple values for argument 'top_k'

Getting this strange error while calling Index.query() Following is the code:

def get_context(question, t):
# generate embeddings for the question
xq = retriever.encode([question]).tolist()
# search pinecone index for context passage with the answer
#print(xq)

xc = index.query(xq, top_k=t, include_metadata=True)
# extract the context passage from pinecone search result
c = [x["metadata"]['context'] for x in xc["matches"]]
return c

get_context(“Example”,1)

The same error occurred while using langchain.

from langchain.vectorstores import Pinecone

text_field = "context"

# switch back to normal index for langchain

vectorstore = Pinecone(
    demo_index, embeddings.embed_query, text_field
)
vectorstore.similarity_search("black boxes")

Error:

TypeError: Index.query() got multiple values for argument 'top_k'
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.