Source code for langchain.vectorstores.tigris
from __future__ import annotations
import itertools
from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple
from langchain.schema import Document
from langchain.schema.embeddings import Embeddings
from langchain.vectorstores import VectorStore
if TYPE_CHECKING:
    from tigrisdb import TigrisClient
    from tigrisdb import VectorStore as TigrisVectorStore
    from tigrisdb.types.filters import Filter as TigrisFilter
    from tigrisdb.types.vector import Document as TigrisDocument
[docs]class Tigris(VectorStore):
    """`Tigris` vector store."""
[docs]    def __init__(self, client: TigrisClient, embeddings: Embeddings, index_name: str):
        """Initialize Tigris vector store."""
        try:
            import tigrisdb  # noqa: F401
        except ImportError:
            raise ImportError(
                "Could not import tigrisdb python package. "
                "Please install it with `pip install tigrisdb`"
            )
        self._embed_fn = embeddings
        self._vector_store = TigrisVectorStore(client.get_search(), index_name)
    @property
    def embeddings(self) -> Embeddings:
        return self._embed_fn
    @property
    def search_index(self) -> TigrisVectorStore:
        return self._vector_store
[docs]    def add_texts(
        self,
        texts: Iterable[str],
        metadatas: Optional[List[dict]] = None,
        ids: Optional[List[str]] = None,
        **kwargs: Any,
    ) -> List[str]:
        """Run more texts through the embeddings and add to the vectorstore.