Problems with vector (length) validation

hi @Ken_Tola !

This is about the number of dimensions of a vector, and not the object itself.

Whenever you vectorize a text, the embedding model should always return the same number of dimensions.

Check this code, for example. We are requesting two vectors for two difference texts, and they will always have 1536 dimensions (default for text-embedding-ada-002)

import os
import requests

headers = {
    'Authorization': 'Bearer ' + os.getenv('OPENAI_API_KEY', ''),
    'Content-Type': 'application/json',
}

json_data = {
    'input': 'text here',
    'model': 'text-embedding-ada-002',
    'encoding_format': 'float',
}

# embedding1
json_data["input"] = "pet animals"
response1 = requests.post('https://api.openai.com/v1/embeddings', headers=headers, json=json_data)
embedding1 = response1.json().get("data")[0].get("embedding")
print(len(embedding1))

# embedding2
json_data["input"] = "something about dogs"
response2 = requests.post('https://api.openai.com/v1/embeddings', headers=headers, json=json_data)
embedding2 = response2.json().get("data")[0].get("embedding")
print(len(embedding2))

Outputs:

1536
1536