An integration package connecting MongoDB and LangChain
Project description
langchain-mongodb
Installation
pip install -U langchain-mongodb
Usage
- See integrations doc for more in-depth usage instructions.
- See Getting Started with the LangChain Integration for a walkthrough on using your first LangChain implementation with MongoDB Atlas.
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,
)
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.1.5.tar.gz
(11.5 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.1.5.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.1.5.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed7bf55a8e495f9576441e4f2d639cc72d947097f90746baa8161714f26b8f54 |
|
MD5 | c02b427e7c0fec4723c7b05035a7e7dc |
|
BLAKE2b-256 | 2ec853a535cf122469d271ea08f7afa3db6ef1846fa4f9269d8a2db6a0d72e1a |
File details
Details for the file langchain_mongodb-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.1.5-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c3a6993cad7b81dcc2a0854c2ef60605031b1f8464140dc098071472c5aa1a |
|
MD5 | 37451c952fbbed566e7f494061c5e239 |
|
BLAKE2b-256 | e74b08c1af0d2dee81b4b5d9a3bad18069d7ce2966a712e2077977483a26aa9d |