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
langchain_mongodb-0.4.0.tar.gz
(167.1 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.4.0.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.4.0.tar.gz
- Upload date:
- Size: 167.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a9d0cefe7e2b32d50d2941121fd098baccbaf65e1848aca2d0593a3480b04b6 |
|
MD5 | c8c908ef6e870957b9e9c7158f846b99 |
|
BLAKE2b-256 | 6000dbdb1cea82a0cf2e8dee4156ad49f30b4fcfaebd05e9b01ee7e8450c1ebe |
File details
Details for the file langchain_mongodb-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.4.0-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab9000ff87b3c8c8f9e6f2c34f1324e0e333d949ac985f4b9b18c3b5bd32393e |
|
MD5 | eebfb5f3514aeb51ed55d712137ca152 |
|
BLAKE2b-256 | cbecabcfbb8065a6c42a553c53f4ad6f088a7d2f06ce7e0c7f2bd297a22a97e4 |