langchain-mongodb
Installation
pip install -U langchain-mongodb
Usage
For more detailed usage examples and documentation, please refer to the MongoDB LangChain documentation.
- Integrate Atlas Vector Search with LangChain for a walkthrough on using your first LangChain implementation with MongoDB Atlas.
Using MongoDBAtlasVectorSearch
import os
from langchain_mongodb import MongoDBAtlasVectorSearch
from langchain_openai import OpenAIEmbeddings
# Pull MongoDB Atlas URI from environment variables
MONGODB_ATLAS_CONNECTION_STRING = os.environ["MONGODB_CONNECTION_STRING"]
DB_NAME = "langchain_db"
COLLECTION_NAME = "test"
VECTOR_SEARCH_INDEX_NAME = "index_name"
MODEL_NAME = "text-embedding-3-large"
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
vectorstore = MongoDBAtlasVectorSearch.from_connection_string(
connection_string=MONGODB_ATLAS_CONNECTION_STRING,
namespace=DB_NAME + "." + COLLECTION_NAME,
embedding=OpenAIEmbeddings(model=MODEL_NAME),
index_name=VECTOR_SEARCH_INDEX_NAME,
)
retrieved_docs = vectorstore.similarity_search(
"How do I deploy MongoDBAtlasVectorSearch in our production environment?")
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
langchain_mongodb-0.12.0.tar.gz
(322.8 kB
view details)
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_mongodb-0.12.0.tar.gz.
File metadata
- Download URL: langchain_mongodb-0.12.0.tar.gz
- Upload date:
- Size: 322.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128acf526848035f7900b2b0957f63e5a3118002dc27831bd749b848ddab2bba
|
|
| MD5 |
ff55c08006c1518211102fe6eb9c4076
|
|
| BLAKE2b-256 |
82c0ae7c590b1415165c603d0fe692eed398f16bb2f9f35f28bfa266437e7335
|
File details
Details for the file langchain_mongodb-0.12.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mongodb-0.12.0-py3-none-any.whl
- Upload date:
- Size: 66.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8623fb2019fde9d8f0c7fc63000d14abfb399bd1b81a1fb6936862c1399651e
|
|
| MD5 |
b9013a94213f306ef036d0d8727900bc
|
|
| BLAKE2b-256 |
83a43859562f62ba9ec22130bed7f152e2cf83b0271612d93d97d66ade8e4da3
|