Package Methods (0.2.2)

Summary of entries of Methods for langchain-google-cloud-sql-mysql.

langchain_google_cloud_sql_mysql.engine._get_iam_principal_email

_get_iam_principal_email(credentials: google.auth.credentials.Credentials) -> str

Get email address associated with current authenticated IAM principal.

See more: langchain_google_cloud_sql_mysql.engine._get_iam_principal_email

langchain_google_cloud_sql_mysql.vectorstore.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.

See more: langchain_google_cloud_sql_mysql.vectorstore.cosine_similarity

langchain_google_cloud_sql_mysql.vectorstore.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.

See more: langchain_google_cloud_sql_mysql.vectorstore.maximal_marginal_relevance

langchain_google_cloud_sql_mysql.chat_message_history.MySQLChatMessageHistory._verify_schema

_verify_schema() -> None

Verify table exists with required schema for MySQLChatMessageHistory class.

See more: langchain_google_cloud_sql_mysql.chat_message_history.MySQLChatMessageHistory._verify_schema

langchain_google_cloud_sql_mysql.chat_message_history.MySQLChatMessageHistory.add_message

add_message(message: langchain_core.messages.base.BaseMessage) -> None

langchain_google_cloud_sql_mysql.chat_message_history.MySQLChatMessageHistory.clear

clear() -> None

langchain_google_cloud_sql_mysql.engine.MySQLEngine._create_connector_engine

_create_connector_engine(
    instance_connection_name: str,
    database: str,
    user: typing.Optional[str],
    password: typing.Optional[str],
) -> sqlalchemy.engine.base.Engine

Create a SQLAlchemy engine using the Cloud SQL Python Connector.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._create_connector_engine

langchain_google_cloud_sql_mysql.engine.MySQLEngine._execute

_execute(query: str, params: typing.Optional[dict] = None) -> None

Executes a SQL query within a transaction.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._execute

langchain_google_cloud_sql_mysql.engine.MySQLEngine._execute_outside_tx

_execute_outside_tx(query: str, params: typing.Optional[dict] = None) -> None

Executes a SQL query with autocommit (outside of transaction).

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._execute_outside_tx

langchain_google_cloud_sql_mysql.engine.MySQLEngine._fetch

_fetch(query: str, params: typing.Optional[dict] = None)

Fetch results from a SQL query.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._fetch

langchain_google_cloud_sql_mysql.engine.MySQLEngine._fetch_rows

_fetch_rows(query: str, params: typing.Optional[dict] = None)

Fetch results from a SQL query as rows.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._fetch_rows

langchain_google_cloud_sql_mysql.engine.MySQLEngine._load_document_table

_load_document_table(table_name: str) -> sqlalchemy.sql.schema.Table

Load table schema from existing table in MySQL database.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine._load_document_table

langchain_google_cloud_sql_mysql.engine.MySQLEngine.connect

connect() -> sqlalchemy.engine.base.Connection

Create a connection from SQLAlchemy connection pool.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine.connect

langchain_google_cloud_sql_mysql.engine.MySQLEngine.from_instance

from_instance(
    project_id: str,
    region: str,
    instance: str,
    database: str,
    user: typing.Optional[str] = None,
    password: typing.Optional[str] = None,
) -> langchain_google_cloud_sql_mysql.engine.MySQLEngine

Create an instance of MySQLEngine from Cloud SQL instance details.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine.from_instance

langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_chat_history_table

init_chat_history_table(table_name: str) -> None

Create table with schema required for MySQLChatMessageHistory class.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_chat_history_table

langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_document_table

init_document_table(
    table_name: str,
    metadata_columns: typing.List[sqlalchemy.sql.schema.Column] = [],
    content_column: str = "page_content",
    metadata_json_column: typing.Optional[str] = "langchain_metadata",
    overwrite_existing: bool = False,
) -> None

Create a table for saving of langchain documents.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_document_table

langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_vectorstore_table

init_vectorstore_table(
    table_name: str,
    vector_size: int,
    content_column: str = "content",
    embedding_column: str = "embedding",
    metadata_columns: typing.List[langchain_google_cloud_sql_mysql.engine.Column] = [],
    metadata_json_column: str = "langchain_metadata",
    id_column: str = "langchain_id",
    overwrite_existing: bool = False,
    store_metadata: bool = True,
) -> None

Create a table for saving of vectors to be used with MySQLVectorStore.

See more: langchain_google_cloud_sql_mysql.engine.MySQLEngine.init_vectorstore_table

langchain_google_cloud_sql_mysql.indexes.VectorIndex

VectorIndex(
    name: typing.Optional[str] = None,
    index_type: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.IndexType
    ] = None,
    distance_measure: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.DistanceMeasure
    ] = None,
    num_partitions: typing.Optional[int] = None,
    num_neighbors: typing.Optional[int] = None,
)

Initializes a new instance of the VectorIndex class.

See more: langchain_google_cloud_sql_mysql.indexes.VectorIndex

langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver

MySQLDocumentSaver(
    engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,
    table_name: str,
    content_column: typing.Optional[str] = None,
    metadata_json_column: typing.Optional[str] = None,
)

MySQLDocumentSaver allows for saving of langchain documents in a database.

See more: langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver

langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver.add_documents

add_documents(docs: typing.List[langchain_core.documents.base.Document]) -> None

Save documents in the DocumentSaver table.

See more: langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver.add_documents

langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver.delete

delete(docs: typing.List[langchain_core.documents.base.Document]) -> None

Delete all instances of a document from the DocumentSaver table by matching the entire Document object.

See more: langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver.delete

langchain_google_cloud_sql_mysql.loader.MySQLLoader

MySQLLoader(
    engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,
    table_name: str = "",
    query: str = "",
    content_columns: typing.Optional[typing.List[str]] = None,
    metadata_columns: typing.Optional[typing.List[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
)

Document page content defaults to the first column present in the query or table and metadata defaults to all other columns.

See more: langchain_google_cloud_sql_mysql.loader.MySQLLoader

langchain_google_cloud_sql_mysql.loader.MySQLLoader.lazy_load

lazy_load() -> typing.Iterator[langchain_core.documents.base.Document]

Lazy Load langchain documents from a Cloud SQL MySQL database.

See more: langchain_google_cloud_sql_mysql.loader.MySQLLoader.lazy_load

langchain_google_cloud_sql_mysql.loader.MySQLLoader.load

load() -> typing.List[langchain_core.documents.base.Document]

Load langchain documents from a Cloud SQL MySQL database.

See more: langchain_google_cloud_sql_mysql.loader.MySQLLoader.load

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.add_documents

add_documents(
    documents: typing.List[langchain_core.documents.base.Document],
    ids: typing.Optional[typing.List[str]] = None,
    **kwargs: typing.Any
) -> typing.List[str]

Run more documents through the embeddings and add to the vectorstore.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.add_documents

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.add_texts

add_texts(
    texts: typing.Iterable[str],
    metadatas: typing.Optional[typing.List[dict]] = None,
    ids: typing.Optional[typing.List[str]] = None,
    **kwargs: typing.Any
) -> typing.List[str]

Run more texts through the embeddings and add to the vectorstore.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.add_texts

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.delete

delete(ids: typing.Optional[typing.List[str]] = None, **kwargs: typing.Any) -> bool

Delete by vector ID or other criteria.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.delete

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.from_documents

from_documents(documents: typing.List[langchain_core.documents.base.Document], embedding: langchain_core.embeddings.embeddings.Embeddings, engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine, table_name: str, ids: typing.Optional[typing.List[str]] = None, content_column: str = 'content', embedding_column: str = 'embedding', metadata_columns: typing.List[str] = [], ignore_metadata_columns: typing.Optional[typing.List[str]] = None, id_column: str = 'langchain_id', metadata_json_column: str = 'langchain_metadata', query_options: langchain_google_cloud_sql_mysql.indexes.QueryOptions = QueryOptions(num_partitions=None, num_neighbors=10, distance_measure=

Return VectorStore initialized from documents and embeddings.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.from_documents

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.from_texts

from_texts(texts: typing.List[str], embedding: langchain_core.embeddings.embeddings.Embeddings, engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine, table_name: str, metadatas: typing.Optional[typing.List[dict]] = None, ids: typing.Optional[typing.List[str]] = None, content_column: str = 'content', embedding_column: str = 'embedding', metadata_columns: typing.List[str] = [], ignore_metadata_columns: typing.Optional[typing.List[str]] = None, id_column: str = 'langchain_id', metadata_json_column: str = 'langchain_metadata', query_options: langchain_google_cloud_sql_mysql.indexes.QueryOptions = QueryOptions(num_partitions=None, num_neighbors=10, distance_measure=

Return VectorStore initialized from texts and embeddings.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.from_texts

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search

max_marginal_relevance_search(
    query: str,
    k: typing.Optional[int] = None,
    fetch_k: typing.Optional[int] = None,
    lambda_mult: typing.Optional[float] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[langchain_core.documents.base.Document]

Performs Maximal Marginal Relevance (MMR) search based on a text query.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search_by_vector

max_marginal_relevance_search_by_vector(
    embedding: typing.List[float],
    k: typing.Optional[int] = None,
    fetch_k: typing.Optional[int] = None,
    lambda_mult: typing.Optional[float] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[langchain_core.documents.base.Document]

Performs Maximal Marginal Relevance (MMR) search based on a vector embedding.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search_by_vector

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search_with_score_by_vector

max_marginal_relevance_search_with_score_by_vector(
    embedding: typing.List[float],
    k: typing.Optional[int] = None,
    fetch_k: typing.Optional[int] = None,
    lambda_mult: typing.Optional[float] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[typing.Tuple[langchain_core.documents.base.Document, float]]

Performs Maximal Marginal Relevance (MMR) search based on a vector embedding and returns documents with scores.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.max_marginal_relevance_search_with_score_by_vector

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search

similarity_search(
    query: str,
    k: typing.Optional[int] = None,
    filter: typing.Optional[str] = None,
    **kwargs: typing.Any
) -> typing.List[langchain_core.documents.base.Document]

Searches for similar documents based on a text query.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_by_vector

similarity_search_by_vector(
    embedding: typing.List[float],
    k: typing.Optional[int] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[langchain_core.documents.base.Document]

Searches for similar documents based on a vector embedding.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_by_vector

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_with_score

similarity_search_with_score(
    query: str,
    k: typing.Optional[int] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[typing.Tuple[langchain_core.documents.base.Document, float]]

Searches for similar documents based on a text query and returns their scores.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_with_score

langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_with_score_by_vector

similarity_search_with_score_by_vector(
    embedding: typing.List[float],
    k: typing.Optional[int] = None,
    filter: typing.Optional[str] = None,
    query_options: typing.Optional[
        langchain_google_cloud_sql_mysql.indexes.QueryOptions
    ] = None,
    **kwargs: typing.Any
) -> typing.List[typing.Tuple[langchain_core.documents.base.Document, float]]

Searches for similar documents based on a vector embedding and returns their scores.

See more: langchain_google_cloud_sql_mysql.vectorstore.MySQLVectorStore.similarity_search_with_score_by_vector