self.vectors is initialized as a list
anay-p opened this issue · comments
Anay Pareek commented
self.vectors is initialized as a list:
documents = documents or []
self.documents = []
--> self.vectors = []
self.embedding_function = embedding_function or (
lambda docs: get_embedding(docs, key=key)
)
which raises an attribute error in add_document:
107 if self.vectors is None:
108 self.vectors = np.empty((0, len(vector)), dtype=np.float32)
--> 109 elif len(vector) != self.vectors.shape[1]:
110 raise ValueError("All vectors must have the same length.")
111 self.vectors = np.vstack([self.vectors, vector]).astype(np.float32)
AttributeError: 'list' object has no attribute 'shape'
It should be initialized as None. We know that self.vectors is going to be a numpy array of dimension (<no of vectors>, <no of vector dimensions>) so it makes no sense for it to be initialized as an empty list.