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.3.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.1.3.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.1.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0853b9d037f1ea962ea212c641efa15f2b36063dd81ad3690d9630f024291305 |
|
MD5 | 58f586c8cf54de93bb03e9262b0e0fd8 |
|
BLAKE2b-256 | e2debf2884fc94293df7f579287815a7809d9aa143be6428a1418c6e9b52c4f0 |
File details
Details for the file langchain_mongodb-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c23595be3835288c92f26e916631fdb47357eb6a9188aa66bdf3d0015661cd7 |
|
MD5 | df068c77bceb21091ee8b1998e8177fe |
|
BLAKE2b-256 | f206050e9d16b5f1ee9f98941872e6f5ba975031cb578d34b6948622ea745bd7 |