langchain.document_loaders.gcs_file.GCSFileLoader

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

Load from GCS file.

Initialize with bucket and key name.

Parameters
  • project_name – The name of the project to load

  • bucket – The name of the GCS bucket.

  • blob – The name of the GCS blob to load.

  • loader_func – 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.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.

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: Optional[Callable[[str], BaseLoader]] = None)[source]

Initialize with bucket and key name.

Parameters
  • project_name – The name of the project to load

  • bucket – The name of the GCS bucket.

  • blob – The name of the GCS blob to load.

  • loader_func – 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.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”))

lazy_load() Iterator[Document]

A lazy loader for Documents.

load() List[Document][source]

Load documents.

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]

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

Parameters

text_splitter – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Examples using GCSFileLoader