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.11.0.tar.gz
(356.4 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.11.0.tar.gz.
File metadata
- Download URL: langchain_mongodb-0.11.0.tar.gz
- Upload date:
- Size: 356.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db483f12e8a4fdbbcfb0594881962fd1f0afcb38a3d42ee0d5fe8a2be20e1e86
|
|
| MD5 |
29a88d36d3b9f45ed991d1b6b535be76
|
|
| BLAKE2b-256 |
ba0e03027bbf0ae3ee71d00e32f5c64395cbee05393e6e5dc56e2d88320db542
|
File details
Details for the file langchain_mongodb-0.11.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mongodb-0.11.0-py3-none-any.whl
- Upload date:
- Size: 62.0 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 |
7e1f43684c907d1f1fee4dbc480dd4909b3ebf03b5d3dad105ed9f4a4280d49f
|
|
| MD5 |
bb753605b73f2587fbd8456e37524b7e
|
|
| BLAKE2b-256 |
1ea1a4ef0c7027166540a4aced056b1fd7194e4519932d2a846fd2cfd9f057cb
|