GCSFileLoader#

class langchain_community.document_loaders.gcs_file.GCSFileLoader(project_name: str, bucket: str, blob: str, loader_func: Callable[[str], BaseLoader] | None = None)[source]#

Deprecated since version 0.0.32: Use :class:`~langchain_google_community.GCSFileLoader` instead. It will be removed in None==1.0.

Load from GCS file.

Initialize with bucket and key name.

Parameters:
  • project_name (str) – The name of the project to load

  • bucket (str) – The name of the GCS bucket.

  • blob (str) – The name of the GCS blob to load.

  • loader_func (Callable[[str], BaseLoader] | None) – A loader function that instantiates a loader based on a file_path argument. If nothing is provided, the UnstructuredFileLoader is used.

Examples

To use an alternative PDF loader: >> from from langchain_community.document_loaders import PyPDFLoader >> loader = GCSFileLoader(…, loader_func=PyPDFLoader)

To use UnstructuredFileLoader with additional arguments: >> loader = GCSFileLoader(…, >> loader_func=lambda x: UnstructuredFileLoader(x, mode=”elements”))

Methods

__init__(project_name, bucket, blob[, ...])

Initialize with bucket and key name.

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

A lazy loader for Documents.

load()

Load documents.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(project_name: str, bucket: str, blob: str, loader_func: Callable[[str], BaseLoader] | None = None)[source]#

Initialize with bucket and key name.

Parameters:
  • project_name (str) – The name of the project to load

  • bucket (str) – The name of the GCS bucket.

  • blob (str) – The name of the GCS blob to load.

  • loader_func (Callable[[str], BaseLoader] | None) – A loader function that instantiates a loader based on a file_path argument. If nothing is provided, the UnstructuredFileLoader is used.

Examples

To use an alternative PDF loader: >> from from langchain_community.document_loaders import PyPDFLoader >> loader = GCSFileLoader(…, loader_func=PyPDFLoader)

To use UnstructuredFileLoader with additional arguments: >> loader = GCSFileLoader(…, >> loader_func=lambda x: UnstructuredFileLoader(x, mode=”elements”))

async alazy_load() AsyncIterator[Document]#

A lazy loader for Documents.

Return type:

AsyncIterator[Document]

async aload() list[Document]#

Load data into Document objects.

Return type:

list[Document]

lazy_load() Iterator[Document]#

A lazy loader for Documents.

Return type:

Iterator[Document]

load() List[Document][source]#

Load documents.

Return type:

List[Document]

load_and_split(text_splitter: TextSplitter | None = None) list[Document]#

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters:

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns:

List of Documents.

Return type:

list[Document]