Socket
Book a DemoInstallSign in
Socket

langchain-mongodb

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langchain-mongodb

An integration package connecting MongoDB and LangChain

0.3.0
pipPyPI
Maintainers
3

from libs.community.tests.unit_tests.chains.test_pebblo_retrieval import retriever

langchain-mongodb

Installation

pip install -U langchain-mongodb

Usage

  • Integrate Atlas Vector Search with LangChain for a walkthrough on using your first LangChain implementation with MongoDB Atlas.

Using MongoDBAtlasVectorSearch

import os
from langchain_mongodb import MongoDBAtlasVectorSearch
from langchain_openai import OpenAIEmbeddings

# Pull MongoDB Atlas URI from environment variables
MONGODB_ATLAS_CONNECTION_STRING = os.environ["MONGODB_CONNECTION_STRING"]
DB_NAME = "langchain_db"
COLLECTION_NAME = "test"
VECTOR_SEARCH_INDEX_NAME = "index_name"

MODEL_NAME = "text-embedding-3-large"
OPENAI_API_KEY =  os.environ["OPENAI_API_KEY"]


vectorstore = MongoDBAtlasVectorSearch.from_connection_string(
    connection_string=MONGODB_ATLAS_CONNECTION_STRING,
    namespace=DB_NAME + "." + COLLECTION_NAME,
    embedding=OpenAIEmbeddings(model=MODEL_NAME),
    index_name=VECTOR_SEARCH_INDEX_NAME,
)

retrieved_docs = vectorstore.similarity_search(
    "How do I deploy MongoDBAtlasVectorSearch in our production environment?")

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.