Skip to main content

An integration package connecting MongoDB and LangChain

Project description

langchain-mongodb

Installation

pip install -U langchain-mongodb

Usage

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


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.7.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

langchain_mongodb-0.1.7-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mongodb-0.1.7.tar.gz.

File metadata

  • Download URL: langchain_mongodb-0.1.7.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for langchain_mongodb-0.1.7.tar.gz
Algorithm Hash digest
SHA256 6ed1739c92b914a0edf7d585f52adfc3fc60d3cf37542791df3e76fc88431b0e
MD5 2ada845b43ce8dcbd19250910c910fbe
BLAKE2b-256 63bff050c8fd56a7b50e25440d3824b4a8120ad75b99e85127663ccf2903447e

See more details on using hashes here.

File details

Details for the file langchain_mongodb-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mongodb-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8066a3ed728f75deeb679721d421f9ac90e5ca2ad8289a0fa1e2ac5e57b24207
MD5 71c65df6c287b2c03e5c6b087267c6c3
BLAKE2b-256 009318e3ad9fc530e03b44c90cd71e60863f1975d643c66b79b258243a9564cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page