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

Uploaded Source

Built Distribution

langchain_mongodb-0.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_mongodb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5ab6e47458d6405e3a3338c5207f2f8ef7ba348d64bca48442a802d66522bd68
MD5 73ddb2842acc057c66bb8e2e7235f84e
BLAKE2b-256 0890d97ba71d2ca42f5030fe28dab7009ed343cf405b381a412a33d7b57343b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mongodb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c10ebbc70d9c93103a759e84eb364f31f876a1d9ee2524df0307c72094fec39
MD5 f16277e54378c6c7c3f9aa9ed7aeb464
BLAKE2b-256 80aedd8c5aba144b662cd2cf81910cb41ce94636380e93768fd2c21189bf813d

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