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

Uploaded Source

Built Distribution

langchain_mongodb-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mongodb-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for langchain_mongodb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 677998327cc6a9e82807b068a44d52deb36e99c659fb2747fe837febbea8dd4d
MD5 52c28128255058d8c5d7e433bdb90a22
BLAKE2b-256 bfc7efc9a78049caad013272e0fc49ab3712579a8f22bf2ecfa66d853e65dade

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mongodb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de4d62d778b136f82403e84600a4d4c99ee7c18b3f7977c4f73aa1d6a409613d
MD5 5e69ed99543528093f62585b024c26ae
BLAKE2b-256 349438ed87fc8414a1627b1a36952af90e167a0b46924943b8e1e6b8e9c24848

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