Skip to main content

LangChain integration for FoxNose - the knowledge layer for RAG and AI agents

Project description

langchain-foxnose

PyPI version Python License CI codecov

LangChain integration for FoxNose — the serverless knowledge platform purpose-built as the knowledge layer for RAG and AI agents.

  • FoxNoseRetriever — query-based retrieval for RAG pipelines
  • FoxNoseLoader — bulk document loading with cursor-based pagination
  • create_foxnose_tool — search tool for LLM agents

Installation

pip install langchain-foxnose

Requires foxnose-sdk>=0.5.0 and langchain-core>=0.3.0.

Quick Start

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

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

# Create the retriever
retriever = FoxNoseRetriever(
    client=client,
    folder_path="knowledge-base",
    page_content_field="body",
    search_mode="hybrid",
    top_k=5,
)

# Use it
docs = retriever.invoke("How do I reset my password?")
for doc in docs:
    print(doc.page_content)
    print(doc.metadata)

Features

  • All search modes: text, vector, hybrid, and vector-boosted search
  • Custom embeddings: bring your own LangChain Embeddings model or pre-computed vectors
  • Bulk document loading: cursor-based pagination with lazy loading for large folders
  • Agent-ready search tool: wrap any retriever as a tool for LLM agents
  • Flexible content mapping: single field, multiple fields, or custom mapper function
  • Metadata control: whitelist, blacklist, or include system metadata
  • Native async: uses AsyncFluxClient for true async when available
  • Structured filtering: pass FoxNose where filters for precise retrieval
  • Full configuration: search fields, thresholds, hybrid weights, sort, and more

Search Modes

# Pure vector (semantic) search
retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    search_mode="vector",
)

# Hybrid search (text + vector)
retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    search_mode="hybrid",
    hybrid_config={"vector_weight": 0.6, "text_weight": 0.4},
)

# Text search with vector boost
retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    search_mode="vector_boosted",
    vector_boost_config={"boost_factor": 1.3},
)

Custom Embeddings

Use your own embedding model for vector search:

from langchain_openai import OpenAIEmbeddings

retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    search_mode="vector",
    embeddings=OpenAIEmbeddings(model="text-embedding-3-small"),
    vector_field="embedding",
)

Or pass a pre-computed vector directly:

retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    search_mode="vector",
    query_vector=[0.1, 0.2, ...],
    vector_field="embedding",
)

Filtered Retrieval

retriever = FoxNoseRetriever(
    client=client,
    folder_path="articles",
    page_content_field="body",
    where={
        "$": {
            "all_of": [
                {"status__eq": "published"},
                {"category__in": ["tech", "science"]},
            ]
        }
    },
)

Document Loader

FoxNoseLoader iterates over all resources in a folder using cursor-based pagination. Use it to bulk-load documents for indexing, batch processing, or seeding a local vector store.

from langchain_foxnose import FoxNoseLoader

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

# Load all documents at once
docs = loader.load()

# Or iterate lazily for large folders
for doc in loader.lazy_load():
    print(doc.metadata.get("key"), doc.page_content[:100])

Agent Tool

create_foxnose_tool wraps a retriever as a LangChain tool that LLM agents can call.

from langchain_foxnose import create_foxnose_tool

tool = create_foxnose_tool(
    client=client,
    folder_path="knowledge-base",
    page_content_field="body",
    name="kb_search",
    description="Search the knowledge base for relevant information.",
    search_mode="hybrid",
    top_k=5,
)

# Use directly
result = tool.invoke("How do I reset my password?")

# Or plug into any LangChain agent
# from langgraph.prebuilt import create_react_agent
# agent = create_react_agent(llm, tools=[tool])

Async Usage

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"),
)

retriever = FoxNoseRetriever(
    async_client=async_client,
    folder_path="knowledge-base",
    page_content_field="body",
)

docs = await retriever.ainvoke("search query")

Documentation

License

Apache-2.0 — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_foxnose-0.3.1.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_foxnose-0.3.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_foxnose-0.3.1.tar.gz.

File metadata

  • Download URL: langchain_foxnose-0.3.1.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_foxnose-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4e8e5b03b8320beb7e8ae40b99fcc1ca22bf6a6c19a35e4d33da5489d264be68
MD5 053cae38a2fc78a9727b73cd09657a1c
BLAKE2b-256 ac42cf71b7e37e292a599fed93ac8a667c1b63af84df44f1829e6ff0db17f78c

See more details on using hashes here.

File details

Details for the file langchain_foxnose-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_foxnose-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14b0f63d647e630e536b82c292c3b8825de3ce88b193531f41a212344590bd8c
MD5 4794b20772fcd73d13f308a298007689
BLAKE2b-256 741d71349934bdc9dfa4947d5f76ab4d42b7a09c6a07ec0f4caa9c1750f9868d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page