pinecone-io / examples

Jupyter Notebooks to help you get hands-on with Pinecone vector databases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

for semantic_text_search.ipynb

virgulvirgul opened this issue · comments

I got
ApiAttributeError: QueryResponse has no attribute 'results' at ['['received_data']']['results']
error when API Request.

Query:

query = "Is too much CO2 in the ocean bad for the environment? Research supports this claim."
vector_embedding = model.encode(query).tolist()
response = index.query([vector_embedding], top_k=3, include_metadata=True)
h.printmd(f"#### A sample response from Pinecone \n ==============\n \n ```python\n{response}\n```")

A sample response from Pinecone
==============

{'matches': [{'id': '10481',
              'metadata': {'month': 3.0, 'source': 'other', 'year': 2018.0},
              'score': 0.478467762,
              'sparseValues': {},
              'values': []},
             {'id': '14516',
              'metadata': {'month': 7.0, 'source': 'other', 'year': 2018.0},
              'score': 0.469798923,
              'sparseValues': {},
              'values': []},
             {'id': '20125',
              'metadata': {'month': 2.0, 'source': 'other', 'year': 2017.0},
              'score': 0.44912678,
              'sparseValues': {},
              'values': []}],
 'namespace': ''}

Oh, I fixed via edit in helper.py:

matches = response['results'][0]['matches'] to matches = response['matches']