Skip to content

Document Loader

FoxNoseLoader is a LangChain BaseLoader that iterates over all resources in a FoxNose folder using cursor-based pagination.

Use it when you need to bulk-load every document in a folder — for example to seed a local vector store, build an index, or run batch processing.

Quick Start

from foxnose_sdk.flux import FluxClient
from foxnose_sdk.auth import SimpleKeyAuth
from langchain_foxnose import FoxNoseLoader

client = FluxClient(
    base_url="https://<env_key>.fxns.io",
    api_prefix="my_api",
    auth=SimpleKeyAuth("YOUR_PUBLIC_KEY", "YOUR_SECRET_KEY"),
)

loader = FoxNoseLoader(
    client=client,
    folder_path="knowledge-base",
    page_content_field="body",
)

docs = loader.load()  # loads all documents

Lazy Loading

For large folders, use lazy_load() to stream documents without holding everything in memory:

for doc in loader.lazy_load():
    print(doc.metadata["key"], doc.page_content[:100])

Async Loading

from foxnose_sdk.flux import AsyncFluxClient

async_client = AsyncFluxClient(
    base_url="https://<env_key>.fxns.io",
    api_prefix="my_api",
    auth=SimpleKeyAuth("YOUR_PUBLIC_KEY", "YOUR_SECRET_KEY"),
)

loader = FoxNoseLoader(
    async_client=async_client,
    folder_path="knowledge-base",
    page_content_field="body",
)

async for doc in loader.alazy_load():
    print(doc.metadata["key"])

Filtering & Sorting

Pass query parameters via params to filter or sort results:

loader = FoxNoseLoader(
    client=client,
    folder_path="articles",
    page_content_field="body",
    params={
        "where": {"status__eq": "published"},
        "sort": "-created_at",
    },
)

Pagination

The loader automatically handles cursor-based pagination. Control the page size with batch_size:

loader = FoxNoseLoader(
    client=client,
    folder_path="articles",
    page_content_field="body",
    batch_size=50,  # fetch 50 resources per page (default: 100)
)

Content Mapping

Content mapping works the same way as in FoxNoseRetriever. See Configuration for details.

Strategy Parameter Description
Single field page_content_field One data field becomes page_content
Multi field page_content_fields Multiple fields concatenated with page_content_separator
Custom mapper page_content_mapper Callable (result_dict) -> str for full control

Metadata

Parameter Description
metadata_fields Whitelist of data fields to include
exclude_metadata_fields Blacklist of data fields to exclude
include_sys_metadata Include _sys fields (default: True)

API Reference

langchain_foxnose.loaders.FoxNoseLoader

Bases: BaseLoader

LangChain document loader backed by FoxNose Flux list_resources.

Iterates over all resources in a FoxNose folder with automatic cursor-based pagination.

Example

.. code-block:: python

from foxnose_sdk.flux import FluxClient
from foxnose_sdk.auth import SimpleKeyAuth
from langchain_foxnose import FoxNoseLoader

client = FluxClient(
    base_url="https://<env_key>.fxns.io",
    api_prefix="my_api",
    auth=SimpleKeyAuth("pk", "sk"),
)
loader = FoxNoseLoader(
    client=client,
    folder_path="knowledge-base",
    page_content_field="body",
)
docs = loader.load()

Parameters:

Name Type Description Default
client Any | None

Synchronous :class:~foxnose_sdk.flux.FluxClient instance.

None
async_client Any | None

Asynchronous :class:~foxnose_sdk.flux.AsyncFluxClient instance.

None
folder_path str

Folder path in FoxNose (e.g. "knowledge-base").

required
page_content_field str | None

Single data field whose value becomes page_content.

None
page_content_fields list[str] | None

Multiple data fields concatenated into page_content.

None
page_content_separator str

Separator when using page_content_fields.

'\n\n'
page_content_mapper Callable[[dict[str, Any]], str] | None

Custom callable (result_dict) -> str for full control.

None
metadata_fields list[str] | None

Whitelist of data fields to include in metadata.

None
exclude_metadata_fields list[str] | None

Blacklist of data fields to exclude from metadata.

None
include_sys_metadata bool

Whether to include _sys fields in metadata.

True
params dict[str, Any] | None

Query parameters forwarded to list_resources.

None
batch_size int

Page size for list_resources calls (must be >= 1).

100

Functions

from_client_params(*, base_url, api_prefix, auth, folder_path, async_mode=False, timeout=15.0, **kwargs) classmethod

Create a loader by constructing the Flux client internally.

Parameters:

Name Type Description Default
base_url str

FoxNose environment URL (e.g. "https://<env_key>.fxns.io").

required
api_prefix str

Flux API prefix.

required
auth Any

An :class:~foxnose_sdk.auth.AuthStrategy instance.

required
folder_path str

Folder path to load from.

required
async_mode bool

If True, create an AsyncFluxClient instead.

False
timeout float

HTTP timeout in seconds.

15.0
**kwargs Any

Additional arguments passed to :class:FoxNoseLoader.

{}

Returns:

Type Description
FoxNoseLoader

A configured :class:FoxNoseLoader instance.

lazy_load()

Lazily load documents from FoxNose with cursor-based pagination.

Yields:

Type Description
Document

class:langchain_core.documents.Document objects.

Raises:

Type Description
ValueError

If no synchronous client is available.

alazy_load() async

Asynchronously load documents from FoxNose with cursor-based pagination.

Yields:

Type Description
AsyncIterator[Document]

class:langchain_core.documents.Document objects.

Raises:

Type Description
ValueError

If no async client is available.