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:
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: |
None
|
async_client
|
Any | None
|
Asynchronous :class: |
None
|
folder_path
|
str
|
Folder path in FoxNose (e.g. |
required |
page_content_field
|
str | None
|
Single |
None
|
page_content_fields
|
list[str] | None
|
Multiple |
None
|
page_content_separator
|
str
|
Separator when using page_content_fields. |
'\n\n'
|
page_content_mapper
|
Callable[[dict[str, Any]], str] | None
|
Custom callable |
None
|
metadata_fields
|
list[str] | None
|
Whitelist of |
None
|
exclude_metadata_fields
|
list[str] | None
|
Blacklist of |
None
|
include_sys_metadata
|
bool
|
Whether to include |
True
|
params
|
dict[str, Any] | None
|
Query parameters forwarded to |
None
|
batch_size
|
int
|
Page size for |
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. |
required |
api_prefix
|
str
|
Flux API prefix. |
required |
auth
|
Any
|
An :class: |
required |
folder_path
|
str
|
Folder path to load from. |
required |
async_mode
|
bool
|
If |
False
|
timeout
|
float
|
HTTP timeout in seconds. |
15.0
|
**kwargs
|
Any
|
Additional arguments passed to :class: |
{}
|
Returns:
| Type | Description |
|---|---|
FoxNoseLoader
|
A configured :class: |
lazy_load()
¶
Lazily load documents from FoxNose with cursor-based pagination.
Yields:
| Type | Description |
|---|---|
Document
|
class: |
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: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no async client is available. |