Class AlloyDBLoader (0.7.0)

AlloyDBLoader(
    key: object,
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    loader: langchain_google_alloydb_pg.async_loader.AsyncAlloyDBLoader,
)

Load documents from AlloyDB`.

Each document represents one row of the result. The content_columns are written into the content_columns of the document. The metadata_columns are written into the metadata_columns of the document. By default, first columns is written into the page_content and everything else into the metadata.

Methods

AlloyDBLoader

AlloyDBLoader(
    key: object,
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    loader: langchain_google_alloydb_pg.async_loader.AsyncAlloyDBLoader,
)

AlloyDBLoader constructor.

Parameters
Name Description
key object

Prevent direct constructor usage.

engine AlloyDBEngine

AsyncEngine with pool connection to the postgres database

query Optional[str], optional

SQL query. Defaults to None.

content_columns Optional[List[str]], optional

Column that represent a Document's page_content. Defaults to the first column.

metadata_columns Optional[List[str]], optional

Column(s) that represent a Document's metadata. Defaults to None.

formatter Optional[Callable], optional

A function to format page content (OneOf: format, formatter). Defaults to None.

metadata_json_column Optional[str], optional

Column to store metadata as JSON. Defaults to "langchain_metadata".

Exceptions
Type Description
Exception If called directly by user.

alazy_load

alazy_load() -> typing.AsyncIterator[langchain_core.documents.base.Document]

Load PostgreSQL data into Document objects lazily.

aload

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

Load PostgreSQL data into Document objects.

create

create(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    query: typing.Optional[str] = None,
    table_name: typing.Optional[str] = None,
    schema_name: str = "public",
    content_columns: typing.Optional[typing.List[str]] = None,
    metadata_columns: typing.Optional[typing.List[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
    format: typing.Optional[str] = None,
    formatter: typing.Optional[typing.Callable] = None,
) -> langchain_google_alloydb_pg.loader.AlloyDBLoader

Create a new AlloyDBLoader instance.

Parameters
Name Description
engine AlloyDBEngine

AsyncEngine with pool connection to the postgres database

query Optional[str], optional

SQL query. Defaults to None.

table_name Optional[str], optional

Name of table to query. Defaults to None.

schema_name str, optional

Name of the schema where table is located. Defaults to "public".

content_columns Optional[List[str]], optional

Column that represent a Document's page_content. Defaults to the first column.

metadata_columns Optional[List[str]], optional

Column(s) that represent a Document's metadata. Defaults to None.

metadata_json_column Optional[str], optional

Column to store metadata as JSON. Defaults to "langchain_metadata".

format Optional[str], optional

Format of page content (OneOf: text, csv, YAML, JSON). Defaults to 'text'.

formatter Optional[Callable], optional

A function to format page content (OneOf: format, formatter). Defaults to None.

create_sync

create_sync(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    query: typing.Optional[str] = None,
    table_name: typing.Optional[str] = None,
    schema_name: str = "public",
    content_columns: typing.Optional[typing.List[str]] = None,
    metadata_columns: typing.Optional[typing.List[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
    format: typing.Optional[str] = None,
    formatter: typing.Optional[typing.Callable] = None,
) -> langchain_google_alloydb_pg.loader.AlloyDBLoader

Create a new AlloyDBLoader instance.

Parameters
Name Description
engine AlloyDBEngine

AsyncEngine with pool connection to the postgres database

query Optional[str], optional

SQL query. Defaults to None.

table_name Optional[str], optional

Name of table to query. Defaults to None.

schema_name str, optional

Name of the schema where table is located. Defaults to "public".

content_columns Optional[List[str]], optional

Column that represent a Document's page_content. Defaults to the first column.

metadata_columns Optional[List[str]], optional

Column(s) that represent a Document's metadata. Defaults to None.

metadata_json_column Optional[str], optional

Column to store metadata as JSON. Defaults to "langchain_metadata".

format Optional[str], optional

Format of page content (OneOf: text, csv, YAML, JSON). Defaults to 'text'.

formatter Optional[Callable], optional

A function to format page content (OneOf: format, formatter). Defaults to None.

lazy_load

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

Load PostgreSQL data into Document objects lazily.

load

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

Load PostgreSQL data into Document objects.