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.1.8.tar.gz
(20.3 kB
view details)
Built Distribution
File details
Details for the file langchain_mongodb-0.1.8.tar.gz
.
File metadata
- Download URL: langchain_mongodb-0.1.8.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df9cc3af8ef2d2c943188f464ac4f952cbe90626a8252ce9f8e5af4202e6ebe |
|
MD5 | ca700594df905e78b9506e863e83fe23 |
|
BLAKE2b-256 | 35a99ccf043b373fe6b317eadeeb9fd714b69559a397d7a648e4574c7d07124e |
File details
Details for the file langchain_mongodb-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: langchain_mongodb-0.1.8-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c086a80813cf213b01fb9024243505243bc8892b27e9ca92b4d0753ab53bdd0 |
|
MD5 | 3421743f20eab8730a81075bcc91fb56 |
|
BLAKE2b-256 | 0ed1cf185431e64a218c6732bdf236351309bb978f5419d1a07ea492d3310917 |