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][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


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

Uploaded Source

Built Distribution

langchain_mongodb-0.1.9-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mongodb-0.1.9.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for langchain_mongodb-0.1.9.tar.gz
Algorithm Hash digest
SHA256 6320eea93334d7b71fb6f2070cb88f25a36abe1fea98c8db7bbf7bf852d9d715
MD5 6e340e67505d74f556b6e7c431d0ec7c
BLAKE2b-256 e4942a51237359d2a2ea967feb681b23f1f8ed86dc01ad548d92d9eed798295d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mongodb-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9a29cfadac13264073b7c585ba623bf38af081d246a1e00e608cac477b1d0982
MD5 c9c65d1be8c414adbd6037e5706018a9
BLAKE2b-256 ed3f88f2655768c524b1c248eaf601da3833d8413f29896e8e41a5ba4bafd526

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