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

Uploaded Source

Built Distribution

langchain_mongodb-0.1.4-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mongodb-0.1.4.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for langchain_mongodb-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a04d79ca4abd541c2131ded4599311ce235ea8fa09eeefbb697e2ddaf677f20e
MD5 fb2277bf38f8fc2862752a2171879fa0
BLAKE2b-256 3bc5a18b13040cac637630f72f623732cfe7e8e6f9f578c538bf09098ea33342

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mongodb-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 462942725afb3bd3e266bd134618fed57b133887ba8892f0f0eaf7570acad5da
MD5 937593c26f4dccd76af526ad8338fca1
BLAKE2b-256 877589c21e57359580d8d7c76e5425c6bcfd4cd897456b41067a3ad73b367b7f

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