-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: mongodb vector io #3772
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
base: main
Are you sure you want to change the base?
feat: mongodb vector io #3772
Conversation
| logger.info(f"Creating collection '{self.collection.name}'") | ||
| # Create collection by inserting a dummy document | ||
| dummy_doc = {"_id": "__dummy__", "dummy": True} | ||
| self.collection.insert_one(dummy_doc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why insert a dummy record and delete it? was this for testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point!
The "dummy document pattern" in MongoDB is not for testing but is a necessary workaround because:
- MongoDB collections are lazily created - They only exist in the database after the first document is inserted
- You can't create indexes on non-existent collections - The code needs to create vector search indexes immediately
- The workaround: Insert a temporary document to force collection creation, then delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried to add some comments throughout, you will need some adjustments now that #3803 has landed.
You also need to update the vector-io action to enable the integration tests. along with that you need to update the skip_if_provider_doesnt_support_openai_vector_stores test in ./tests/integration/vector_io/test_openai_vector_stores.py.
This is definitely great to see so thanks for contributing this! BTW I"M not sure if you've seen MongoDB does has an external provided implementation here: https://github.com/mongodb-partners/mongodb-llama-stack.
They actually created a PR quite some time ago here: https://github.com/llamastack/llama-stack/pull/1603/files but the stack has changed some since then. Think we'll be able to get this in though!
Resolved conflicts: - Integrated MongoDB provider with newly added Qdrant and Weaviate providers - Updated distribution configs to include all three providers - Merged build.yaml and run.yaml configs for ci-tests, starter, and starter-gpu distributions - Updated starter.py to include MongoDB, Qdrant, and Weaviate provider initialization - Added MongoDB provider files to src/ directory structure - Updated MongoDB provider to use new VectorStore API (was VectorDB) - Updated MongoDB config to use KVStoreReference instead of KVStoreConfig - Applied auto-formatting changes from pre-commit hooks
- Fixed mypy type error in MongoDB aggregate pipeline - Auto-formatted code with ruff - Generated provider documentation - Applied formatting to YAML files
…MongoDB vector IO sample_run_config
… models_api dependency
…add models_api dependency
…Vector Stores mixin compatibility
…failure handling - Changed insert_chunks and query_chunks parameter from vector_db_id to vector_store_id - Updated method names: register_vector_db -> register_vector_store, unregister_vector_db -> unregister_vector_store - Updated types: VectorDB -> VectorStore, VectorDBsProtocolPrivate -> VectorStoresProtocolPrivate, VectorDBWithIndex -> VectorStoreWithIndex - Added support for individual connection parameters (host, port, username, password) with precedence over connection_string - Changed kvstore config to use KVStoreReference with kvstore_impl for initialization - Added graceful connection failure handling with clean warning messages - Tests now skip gracefully when MongoDB is not running instead of erroring
Distribution codegen hook automatically added host, port, username, and password parameters to MongoDB vector IO provider configuration in distribution templates.
|
This pull request has merge conflicts that must be resolved before it can be merged. @seyeong-han please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
What does this PR do?
This pull request adds support for MongoDB Atlas as a remote vector database provider to Llama Stack, enabling cloud-native vector search functionality. The changes introduce configuration, documentation, and integration for MongoDB Atlas Vector Search across the codebase, including distribution templates, provider registry, and sample configurations.
MongoDB Atlas Vector Search Integration
remote::mongodbas a supported vector database provider in distribution build/run YAML files for starter, starter-gpu, and CI-tests, allowing MongoDB Atlas to be used for vector storage and search. [1] [2] [3] [4] [5] [6]MongoDBVectorIOConfig. [1] [2] [3] [4]Provider Implementation
llama_stack/providers/remote/vector_io/mongodb, including adapter loading logic and a pydantic-based configuration class for connection and search options. [1] [2]Documentation
Provider Registry
llama_stack/providers/registry/vector_io.py, including metadata, pip dependencies, and a detailed description for discoverability.Miscellaneous
Test Plan
Example RAG with response API
Get MongoDB connection key and Fireworks API key
Run llama-stack server with Fireworks API
--> Result
MongoDB Atlas

llama_stack.vs_f09d3c4b_0163_43b2_8f49_d6701643cf7acollection