LangChain integration for Moss semantic search
Project description
Moss LangChain Cookbook
This cookbook demonstrates how to integrate Moss with LangChain.
Overview
Moss is a semantic search platform that allows you to build and query high-performance vector indices without managing infrastructure. This integration provides:
- MossRetriever: A LangChain-compatible retriever for semantic search.
- MossSearchTool: A tool for LangChain agents to search your knowledge base.
Installation
Ensure you have the required packages installed:
pip install inferedge-moss langchain langchain-openai python-dotenv
Setup
Create a .env file with your Moss credentials:
MOSS_PROJECT_ID=your_project_id
MOSS_PROJECT_KEY=your_project_key
MOSS_INDEX_NAME=your_index_name
OPENAI_API_KEY=your_openai_api_key
Usage
Using the Retriever
The MossRetriever can be used in any LangChain chain.
from moss_langchain import MossRetriever
retriever = MossRetriever(
project_id="your_id",
project_key="your_key",
index_name="your_index",
top_k=3,
alpha=0
)
docs = retriever.invoke("What is the refund policy?")
Using the Agent Tool
You can also use Moss as a tool for an agent.
from moss_langchain import get_moss_tool
tool = get_moss_tool(
project_id="your_id",
project_key="your_key",
index_name="your_index"
)
# Add to agent tools
tools = [tool]
Examples
Check out the moss_langchain.ipynb notebook for complete examples including:
- Direct index querying
- Retrieval-Augmented Generation (RAG)
- ReAct Agent with Moss search
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_moss-0.1.0.tar.gz.
File metadata
- Download URL: langchain_moss-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3815fae401aa31c0711864e11c6f81e590ae02960d355003b08d6403e16742cb
|
|
| MD5 |
03d1f951fd9a7d2bb9bcf4fee76ee32f
|
|
| BLAKE2b-256 |
b0ce4b277aff2e22f6e2faadbc947617f2d36dbc818ff0910517d655ce665cd5
|
File details
Details for the file langchain_moss-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_moss-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7336d32e30b6bb0b1cc84861aa1634f1d573c3d41a8e6a0b10338afdc9720b8b
|
|
| MD5 |
a04258623acc3a60fe8373bd620d363b
|
|
| BLAKE2b-256 |
9ba592106569cb70205229e9beed9318e04765ed9f6c9a91067ab39159d64753
|