defadd_documents( self, documents: list[Document], ids: Optional[list[str]] = None, **kwargs: Any, ) -> list[str]: """Add documents to the store.""" texts = [doc.page_content for doc in documents] vectors = self.embedding.embed_documents(texts)
if ids andlen(ids) != len(texts): msg = ( f"ids must be the same length as texts. " f"Got {len(ids)} ids and {len(texts)} texts." ) raise ValueError(msg)
id_iterator: Iterator[Optional[str]] = ( iter(ids) if ids elseiter(doc.idfor doc in documents) )
deffrom_vector_store( cls, vector_store: BasePydanticVectorStore, embed_model: Optional[EmbedType] = None, **kwargs: Any, ) -> "VectorStoreIndex": ifnot vector_store.stores_text: raise ValueError( "Cannot initialize from a vector store that does not store text." )