Module vectorstore (0.8.0)

API documentation for vectorstore module.

Classes

PostgresVectorStore

PostgresVectorStore(
    key: object,
    engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
    embedding_service: langchain_core.embeddings.embeddings.Embeddings,
    table_name: str,
    content_column: str = "content",
    embedding_column: str = "embedding",
    metadata_columns: typing.List[str] = [],
    id_column: str = "langchain_id",
    metadata_json_column: typing.Optional[str] = "langchain_metadata",
    distance_strategy: langchain_google_cloud_sql_pg.indexes.DistanceStrategy = DistanceStrategy.COSINE_DISTANCE,
    k: int = 4,
    fetch_k: int = 20,
    lambda_mult: float = 0.5,
    index_query_options: typing.Optional[
        langchain_google_cloud_sql_pg.indexes.QueryOptions
    ] = None,
)

Google Cloud SQL for PostgreSQL Vector Store class

Modules Functions

cosine_similarity

cosine_similarity(
    X: typing.Union[
        typing.List[typing.List[float]], typing.List[numpy.ndarray], numpy.ndarray
    ],
    Y: typing.Union[
        typing.List[typing.List[float]], typing.List[numpy.ndarray], numpy.ndarray
    ],
) -> numpy.ndarray

Row-wise cosine similarity between two equal-width matrices.

maximal_marginal_relevance

maximal_marginal_relevance(
    query_embedding: numpy.ndarray,
    embedding_list: list,
    lambda_mult: float = 0.5,
    k: int = 4,
) -> typing.List[int]

Calculate maximal marginal relevance.