Skip to content

rag.vectorstores

Vectorstores for the RAG module.

BaseVectorStore

Bases: BaseModel, Generic[BaseQueryResultsT], ABC

The base class abstract interface for interacting with vectorstores.

Source code in mirascope/rag/vectorstores.py
class BaseVectorStore(BaseModel, Generic[BaseQueryResultsT], ABC):
    """The base class abstract interface for interacting with vectorstores."""

    api_key: ClassVar[Optional[str]] = None
    index_name: ClassVar[Optional[str]] = None
    chunker: ClassVar[BaseChunker] = TextChunker(chunk_size=1000, chunk_overlap=200)
    embedder: ClassVar[BaseEmbedder]
    vectorstore_params: ClassVar[BaseVectorStoreParams] = BaseVectorStoreParams()
    configuration: ClassVar[BaseConfig] = BaseConfig()
    _provider: ClassVar[str] = "base"

    @abstractmethod
    def retrieve(self, text: str, **kwargs: Any) -> BaseQueryResultsT:
        """Queries the vectorstore for closest match"""
        ...  # pragma: no cover

    @abstractmethod
    def add(self, text: Union[str, list[Document]], **kwargs: Any) -> None:
        """Takes unstructured data and upserts into vectorstore"""
        ...  # pragma: no cover

add(text, **kwargs) abstractmethod

Takes unstructured data and upserts into vectorstore

Source code in mirascope/rag/vectorstores.py
@abstractmethod
def add(self, text: Union[str, list[Document]], **kwargs: Any) -> None:
    """Takes unstructured data and upserts into vectorstore"""
    ...  # pragma: no cover

retrieve(text, **kwargs) abstractmethod

Queries the vectorstore for closest match

Source code in mirascope/rag/vectorstores.py
@abstractmethod
def retrieve(self, text: str, **kwargs: Any) -> BaseQueryResultsT:
    """Queries the vectorstore for closest match"""
    ...  # pragma: no cover