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.2.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.1.2.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.1.2.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 | 725dac1603247f0f858ce2a1084c099aa94f0f8b1da3e258be5f1abd2ee51e94 |
|
MD5 | fc24df6b3d49a4a1da36c8c27e5f5411 |
|
BLAKE2b-256 | cd2b318bec3feb16c1da30aac170b745a9cb46c5006f89b400a95001e5d392c0 |
File details
Details for the file langchain_mongodb-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.6 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 | 787e00c1e43231ea09822ff412983f98deebbb38c0279eb8f1c5a93687d0e5f3 |
|
MD5 | 0fde4118c0131f3fdbb38da6399e2759 |
|
BLAKE2b-256 | 18dc5d72c01e8fa9da0b1813efa510bca94c0f31bf399ef8a679f50cf2274eb5 |