You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/partners/mongodb
Casey Clements 25f2e25be1
partners[patch]: Mongodb Retrievers - CI final touches. (#25202)
## Description

Contains 2 updates to for integration tests to run on langchain's CI.
Addendum to #25057 to get release github action to succeed.
1 month ago
..
langchain_mongodb mongodb: Add Hybrid and Full-Text Search Retrievers, release 0.2.0 (#25057) 1 month ago
scripts patch[Partners] Unified fix of incorrect variable declarations in all check_imports (#25014) 2 months ago
tests partners[patch]: Mongodb Retrievers - CI final touches. (#25202) 1 month ago
.gitignore
LICENSE
Makefile
README.md mongodb: Add Hybrid and Full-Text Search Retrievers, release 0.2.0 (#25057) 1 month ago
poetry.lock mongodb: Add Hybrid and Full-Text Search Retrievers, release 0.2.0 (#25057) 1 month ago
pyproject.toml mongodb: Add Hybrid and Full-Text Search Retrievers, release 0.2.0 (#25057) 1 month ago

README.md

langchain-mongodb

Installation

pip install -U langchain-mongodb

Usage

Using MongoDBAtlasVectorSearch

from langchain_mongodb import MongoDBAtlasVectorSearch

# Pull MongoDB Atlas URI from environment variables
MONGODB_ATLAS_CLUSTER_URI = os.environ.get("MONGODB_ATLAS_CLUSTER_URI")

DB_NAME = "langchain_db"
COLLECTION_NAME = "test"
ATLAS_VECTOR_SEARCH_INDEX_NAME = "index_name"
MONGODB_COLLECTION = client[DB_NAME][COLLECTION_NAME]

# Create the vector search via `from_connection_string`
vector_search = MongoDBAtlasVectorSearch.from_connection_string(
    MONGODB_ATLAS_CLUSTER_URI,
    DB_NAME + "." + COLLECTION_NAME,
    OpenAIEmbeddings(disallowed_special=()),
    index_name=ATLAS_VECTOR_SEARCH_INDEX_NAME,
)

# Initialize MongoDB python client
client = MongoClient(MONGODB_ATLAS_CLUSTER_URI)
# Create the vector search via instantiation
vector_search_2 = MongoDBAtlasVectorSearch(
    collection=MONGODB_COLLECTION,
    embeddings=OpenAIEmbeddings(disallowed_special=()),
    index_name=ATLAS_VECTOR_SEARCH_INDEX_NAME,
)