langchain/libs/partners/mongodb
William FH b7b62e29fb
community[patch], mongodb[patch]: Stop spamming SIMD import warnings (#19531)
If you use an embedding dist function in an eval loop, you get warned
every time. Would prefer to just check once and forget about it.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2024-03-28 03:11:02 +00:00
..
langchain_mongodb community[patch], mongodb[patch]: Stop spamming SIMD import warnings (#19531) 2024-03-28 03:11:02 +00:00
scripts mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 2024-02-29 23:09:48 +00:00
tests mongodb[patch]: Added scoring threshold to caching (#19286) 2024-03-19 11:30:02 -07:00
.gitignore mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 2024-02-29 23:09:48 +00:00
LICENSE mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 2024-02-29 23:09:48 +00:00
Makefile mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 2024-02-29 23:09:48 +00:00
poetry.lock mongodb[patch]: fix core dep (#18926) 2024-03-11 10:27:29 -07:00
pyproject.toml mongodb[patch]: Added scoring threshold to caching (#19286) 2024-03-19 11:30:02 -07:00
README.md mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 2024-02-29 23:09:48 +00:00

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][COLLECITON_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,
)