About LangChain
LangChain is the most popular framework for building LLM-powered applications. Moss provides a MossRetriever class that implements LangChain's BaseRetriever interface, plus a get_moss_tool() function for agentic workflows. Replace cloud vector database calls with sub-10ms local search without changing your chain architecture.
Why Use Moss with LangChain
01
Native BaseRetriever
MossRetriever implements BaseRetriever — drop into any LangChain RAG chain or LCEL pipeline
02
Agent-Ready Tool
get_moss_tool() wraps Moss as a LangChain Tool for ReAct and function-calling agents
03
Sub-10 ms Latency
Sub-10 ms retrieval replaces 300–900 ms cloud vector DB round-trips
04
Hybrid Search
Hybrid search via alpha parameter: blend semantic similarity with BM25 keyword matching
05
Async-First
Async-first: ainvoke() for Jupyter notebooks and async agent loops
Quick Start
from moss_langchain import MossRetriever
retriever = MossRetriever(
project_id="your-project-id",
project_key="your-project-key",
index_name="your-index-name",
top_k=3,
alpha=0.5,
)
# Use in async contexts (recommended)
docs = await retriever.ainvoke("What is the return policy?")
for doc in docs:
print(doc.page_content, doc.metadata["score"])Get Started in 3 Steps
01
Install dependencies
Run pip install moss langchain langchain-openai python-dotenv to set up your environment.
02
Create a MossRetriever
Initialize MossRetriever with your project credentials and index name. The retriever auto-loads the index on first query.
03
Use in your chain or agent
Call retriever.ainvoke(query) in RAG chains, or wrap the retriever as a LangChain tool for ReAct and function-calling agents.
Frequently asked questions
Ready to ship faster AI products?
Moss gives you production-ready semantic retrieval without infrastructure complexity.