An integration package connecting MongoDB and LangChain
Project description
from libs.community.tests.unit_tests.chains.test_pebblo_retrieval import retriever
langchain-mongodb
Installation
pip install -U langchain-mongodb
Usage
- 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?")
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
langchain_mongodb-0.9.0.tar.gz
(353.6 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.9.0.tar.gz.
File metadata
- Download URL: langchain_mongodb-0.9.0.tar.gz
- Upload date:
- Size: 353.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb33bace482a279b2c0e7c2c1948c51ed7fb9a008f237201a7dab33fa074b699
|
|
| MD5 |
4a702dcdf7020d6cab27cdc86bb33556
|
|
| BLAKE2b-256 |
82c6cda9e357d6c6a17713d885dc197d51ed9c3d8c225508205099f7e915a515
|
File details
Details for the file langchain_mongodb-0.9.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mongodb-0.9.0-py3-none-any.whl
- Upload date:
- Size: 60.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0512f4763cc659e53ba54073b7a03901a02516aff3e9d27f57bd329638ebc02
|
|
| MD5 |
773d7c5244ebb222b7b1f58dde1b9a47
|
|
| BLAKE2b-256 |
9e4971407c8892aa36e3a0ec41fcd0e61e27b5640cf8bb7bf407b1de2ae5d7c2
|