An integration package connecting MongoDB and LangChain
Project description
langchain-mongodb
Installation
pip install -U langchain-mongodb
Usage
- 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][COLLECTION_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
Built Distribution
File details
Details for the file langchain_mongodb-0.2.0.dev1.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.2.0.dev1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 757eeb9979aa937e6679214872b448554957b9ab1c17160ece89a817776aa443 |
|
MD5 | df61242dc3575ff95fa13ada6954e9ee |
|
BLAKE2b-256 | 1e9aa075fc56e255634c260bc085ecc93e251526324b41c0a7d38ac5ed4479fe |
File details
Details for the file langchain_mongodb-0.2.0.dev1-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.2.0.dev1-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00f6c062afdc641a7f42d4ea6a357322e82b817b71fad01d6846709e80457cb7 |
|
MD5 | e0990c5275bc35e7d53bf7fe14f3def9 |
|
BLAKE2b-256 | 2b95fb9086fe68a881ce1f4c251d3216571cecef4cec5088779eecbac0d68cd6 |