Error while upserting data

        new_row = pd.DataFrame({"id": [content_id], "vector": [embedding], 'metadata': [{'content': chunk_text}]})
        df = pd.concat([df, new_row], ignore_index=True)
 
    index.upsert(vectors=zip(df.id, df.vector, df['metadata'].apply(lambda x: x['content'])))

I am trying to upsert the data but i encountered error metadata: invalid value

I don’t think you can pass an iterator to the upsert function. It needs to be a list such as:

# list of tuples:
index.upsert(vectors=[
                 ('id1', [1.0, 2.0, 3.0], {'key': 'value'}),
                 ('id2', [1.0, 2.0, 3.0])]
            )
# or

# list of objects:
index.upsert(vectors=[
                 {'id': 'id1', 'values': [1.0, 2.0, 3.0], 'metadata': {'key': 'value'}},
                 {'id': 'id2', 'values': [1.0, 2.0, 3.0]}]
            )
1 Like

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