You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/partners/mongodb
Jib c2b1abe91b
mongodb[patch]: Set delete_many only if count_documents is not 0 (#18402)
- [x] **PR message**: ***Delete this entire checklist*** and replace
with
- **Description:** Remove the assert statement on the `count_documents`
in setup_class. It should just delete if there are documents present
    - **Issue:** the issue # Crashes on class setup
    - **Dependencies:** None
    - **Twitter handle:** @mongodb


- [x] **Add tests and docs**: If you're adding a new integration, please
include
  1. N/A


- [ ] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.

Co-authored-by: Jib <jib@byblack.us>
7 months ago
..
langchain_mongodb mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
scripts mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
tests mongodb[patch]: Set delete_many only if count_documents is not 0 (#18402) 7 months ago
.gitignore mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
LICENSE mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
Makefile mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
README.md mongodb[minor]: MongoDB Partner Package -- Porting MongoDBAtlasVectorSearch (#17652) 7 months ago
poetry.lock mongodb[patch]: core 0.1.5 dep (#18348) 7 months ago
pyproject.toml mongodb[patch]: core 0.1.5 dep (#18348) 7 months ago

README.md

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,
)