Cannot get upsert to work no matter what I am trying

No matter what I am trying on my flask server, I cannot get an upsert to work. I even stopped using the document I was trying with, and have switched over to just the sample from pinecone. That works on the website itself, but not when I try via the sdk. Any help is appreciated, I am going nuts here.

sample_doc = {
    "vectors": [
        {
            "id": "item_0",
            "metadata": {
                "category": "sports",
                "colors": [
                    "blue",
                    "red",
                    "green"
                ],
                "time_stamp": 0
            },
            "values": [
                0.07446312652229216,
                0.8866284618893006,
                0.5244262265711986
            ]
        },
    ],
    "namespace": "example_namespace"
}

# Upsert the vector into the Pinecone index
index = pinecone.Index(index_name)
index.upsert(vectors=[sample_doc])

ValueError: Invalid vector value passed: cannot interpret type <class ‘list’>

Note that I have tried every possible variation on this, i’ve tried index.upsert(sample_doc), etc.

Hi thanks for reaching out! We think we have found a bug in the client and are working to resolve. If you are blocked please consider using our tuple based upserts.

upsert_response = index.upsert(
    vectors=[
        ("vec1", [0.1, 0.2, 0.3], {"genre": "drama"}),
        ("vec2", [0.2, 0.3, 0.4], {"genre": "action"}),
    ],
    namespace="example-namespace"
)

We’ll update as soon as we have a solution. Thank you!

I couldn’t get it to work either so I switched to using the requests python library with POST statements and it worked great. I’m not using the python library anymore.

request_data = {'vectors': [
                    {'id': str(record_id), 'values': embed_list}
               ]}

request_url = "https://url-from-console.svc.us-east1-gcp.pinecone.io/vectors/upsert"
response = requests.post(request_url,
                             headers={
                                 'Api-Key': 'xyzzy',
                                 'accept': 'application/json',
                                 'content-type': 'application/json'
                             },
                             data=json.dumps(request_data))


if response.status_code == 200:
   # good to go
2 Likes

We have fixed the issue with passing dictionaries to upsert in version 2.2.1 of the client.

Have you been able to upsert to a particular namespace. This code works great but I cannot get it to do this.