MCPcopy Create free account
hub / github.com/MinishLab/vicinity / insert

Method insert

vicinity/vicinity.py:236–253  ·  view source on GitHub ↗

Insert new items into the vector space. :param tokens: A list of items to insert into the vector space. :param vectors: The vectors to insert into the vector space. :raises ValueError: If the tokens and vectors are not the same length.

(self, tokens: Sequence[T], vectors: npt.NDArray)

Source from the content-addressed store, hash-verified

234 return instance
235
236 def insert(self, tokens: Sequence[T], vectors: npt.NDArray) -> None:
237 """
238 Insert new items into the vector space.
239
240 :param tokens: A list of items to insert into the vector space.
241 :param vectors: The vectors to insert into the vector space.
242 :raises ValueError: If the tokens and vectors are not the same length.
243 """
244 if len(tokens) != len(vectors):
245 raise ValueError(f"Your tokens and vectors are not the same length: {len(tokens)} != {len(vectors)}")
246
247 if vectors.shape[1] != self.dim:
248 raise ValueError("The inserted vectors must have the same dimension as the backend.")
249
250 self.items.extend(tokens)
251 self.backend.insert(vectors)
252 if self.vector_store is not None:
253 self.vector_store.insert(vectors)
254
255 def delete(self, tokens: Sequence[T]) -> None:
256 """

Calls

no outgoing calls