langchain_community.vectorstores.momento_vector_index.MomentoVectorIndex¶
class langchain_community.vectorstores.momento_vector_index.MomentoVectorIndex(embedding: Embeddings, client: PreviewVectorIndexClient, index_name: str = 'default', distance_strategy: DistanceStrategy = DistanceStrategy.COSINE, text_field: str = 'text', ensure_index_exists: bool = True, **kwargs: Any)[source]¶
Momento Vector Index (MVI) vector store.
Momento Vector Index is a serverless vector index that can be used to store and
search vectors. To use you should have the momento python package installed.
Example
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.vectorstores import MomentoVectorIndex
from momento import (
    CredentialProvider,
    PreviewVectorIndexClient,
    VectorIndexConfigurations,
)
vectorstore = MomentoVectorIndex(
    embedding=OpenAIEmbeddings(),
    client=PreviewVectorIndexClient(
        VectorIndexConfigurations.Default.latest(),
        credential_provider=CredentialProvider.from_environment_variable(
            "MOMENTO_API_KEY"
        ),
    ),
    index_name="my-index",
)
Initialize a Vector Store backed by Momento Vector Index.
Parameters
embedding (Embeddings) – The embedding function to use.
configuration (VectorIndexConfiguration) – The configuration to initialize
the Vector Index with.
credential_provider (CredentialProvider) – The credential provider to
authenticate the Vector Index with.
index_name (str, optional) – The name of the index to store the documents in.
Defaults to “default”.
distance_strategy (DistanceStrategy, optional) – The distance strategy to
use. If you select DistanceStrategy.EUCLIDEAN_DISTANCE, Momento uses
the squared Euclidean distance. Defaults to DistanceStrategy.COSINE.