check_validations
function in \site-packages\pinecone\core\client\model_utils.py
incorrectly mentions “input_values (list/str/int/float/date/datetime): the values that we are checking.”
You can’t check len(input_values) for int values.
ERROR: TypeError: object of type ‘int’ has no len()
Hi @kshrivastava. Can you share the full stack trace for the error you’re seeing? That’ll help us see where in the code the problem is so we can fix it.
Thanks.
Traceback (most recent call last):
File “\HRQA.py”, line 143, in
index.upsert(vectors=to_upsert)
File “\Python\Python39\lib\site-packages\pinecone\core\utils\error_handling.py”, line 17, in inner_func
return func(*args, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\index.py”, line 147, in upsert
return self._upsert_batch(vectors, namespace, _check_type, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\index.py”, line 233, in _upsert_batch
vectors=list(map(_vector_transform, vectors)),
File “\Python\Python39\lib\site-packages\pinecone\index.py”, line 226, in _vector_transform
return Vector(id=id, values=values, metadata=metadata or {}, _check_type=_check_type)
File “\Python\Python39\lib\site-packages\pinecone\core\client\model_utils.py”, line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\core\client\model\vector.py”, line 280, in init
self.id = id
File “\Python\Python39\lib\site-packages\pinecone\core\client\model_utils.py”, line 188, in setattr
self[attr] = value
File “\Python\Python39\lib\site-packages\pinecone\core\client\model_utils.py”, line 488, in setitem
self.set_attribute(name, value)
File “\Python\Python39\lib\site-packages\pinecone\core\client\model_utils.py”, line 170, in set_attribute
check_validations(
File “\Python\Python39\lib\site-packages\pinecone\core\client\model_utils.py”, line 908, in check_validations
len(input_values) > current_validations[‘max_length’]):
TypeError: object of type ‘int’ has no len()
Can you post your code? I think I was getting something like that when I first started experimenting with Pinecone (object has no len()) - it may have had to do with the tuple format.
x[‘id’] was numeric…
for i in tqdm(range(0, len(new_data), batch_size)):
# find end of batch
i_end = min(len(new_data), i + batch_size)
meta_batch = new_data[i:i_end]
# get ids
ids_batch = [x['id'] for x in meta_batch]
# get texts to encode
texts = [x['text'] for x in meta_batch]
# create embeddings (try-except added to avoid RateLimitError)
try:
res = openai.Embedding.create(input=texts, engine=embed_model)
except:
done = False
while not done:
sleep(5)
try:
res = openai.Embedding.create(input=texts, engine=embed_model)
done = True
except:
pass
embeds = [record['embedding'] for record in res['data']]
# cleanup metadata
meta_batch = [{
'text': x['text']
, 'published': x['published']
} for x in meta_batch]
to_upsert = list(zip(ids_batch, embeds, meta_batch))
# upsert to Pinecone
index.upsert(vectors=to_upsert)
Hi @Cory_Pinecone - Any insights?