Skip to content

+MongoDB Vector Support #2367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

ranfysvalle02
Copy link

Description

Add MongoDB as a VectorDB.

Fixes # (issue)

#1166

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

There is working code that highlights how to use, and the output.

Please delete options that are not relevant.

  • Unit Test
  • Test Script
config = {
    "vector_store": {
        "provider": "mongodb",
        "config": {
            "mdb_uri": "mongodb://0.0.0.0/?directConnection=true",
            "dbname": "DEMO",
            "collection_name": "TEST",
            "get_embedding": get_embedding,
            "embedding_model_dims": len(get_embedding("0")),
        }
    }
}
m = Memory.from_config(config)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

Copy link

vercel bot commented Mar 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
multimodal-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 3:19am

@ranfysvalle02
Copy link
Author

@Dev-Khant could you please take a look at this one?


class MongoVectorConfig(BaseModel):
dbname: str = Field("mydatabase", description="Name of the MongoDB database")
collection_name: str = Field("mycollection", description="Name of the MongoDB collection")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set the default name as mem0

Copy link
Member

@Dev-Khant Dev-Khant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the relevant docs and tests for it. Thanks.



class MongoVectorConfig(BaseModel):
dbname: str = Field("mydatabase", description="Name of the MongoDB database")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set the name as mem0_db

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!


from mem0.vector_stores.base import VectorStoreBase

from mdb_toolkit import CustomMongoClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this library needed here, why can't pymongo be used directly?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@ranfysvalle02
Copy link
Author

@Dev-Khant will add this soon! Sorry for delay

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2025

CLA assistant check
All committers have signed the CLA.

dgupta18 added 2 commits April 8, 2025 17:29
Adding initial tests, updating use of get_embeddings

Remove accidental formatting to unrelated files

Fixing tests

Fixing docs, adding comment

Remove get_embeddings
@dgupta18
Copy link

Hi @Dev-Khant , this PR is ready for re-review when you get a second!

@ranfysvalle02 ranfysvalle02 requested a review from Dev-Khant April 10, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants