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.1.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.1.1.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.1.1.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 | 5ab6e47458d6405e3a3338c5207f2f8ef7ba348d64bca48442a802d66522bd68 |
|
MD5 | 73ddb2842acc057c66bb8e2e7235f84e |
|
BLAKE2b-256 | 0890d97ba71d2ca42f5030fe28dab7009ed343cf405b381a412a33d7b57343b8 |
File details
Details for the file langchain_mongodb-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.1.1-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 | 5c10ebbc70d9c93103a759e84eb364f31f876a1d9ee2524df0307c72094fec39 |
|
MD5 | f16277e54378c6c7c3f9aa9ed7aeb464 |
|
BLAKE2b-256 | 80aedd8c5aba144b662cd2cf81910cb41ce94636380e93768fd2c21189bf813d |