-
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
) | ||
``` | ||
|
||
## Usage |
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.
i think part of this readme is duplicated.
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.
I believe the # Usage
and # Configuration
sections are duplicated.
- provider_type: inline::milvus | ||
- provider_type: remote::chromadb | ||
- provider_type: remote::pgvector | ||
- provider_type: remote::mongodb |
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.
you need to also add an image that'll run MongoDB and expose the vector search functionality.
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.
you'll need to add this to the ./github/workflows/integratino-vector-io.tests.yaml
file like here: https://github.com/llamastack/llama-stack/blob/main/.github/workflows/integration-vector-io-tests.yml#L43
provider_id="${env.MONGODB_CONNECTION_STRING:+mongodb_atlas}", | ||
provider_type="remote::mongodb", | ||
config=MongoDBVectorIOConfig.sample_run_config( | ||
f"~/.llama/distributions/{name}", |
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.
you probably want to add the other configuration parameters.
) | ||
``` | ||
## Usage |
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.
BTW I believe the docs are now compiled from this description, so this may be why you have duplication.
|
||
# Handle the deps resolution - if files API exists, pass it, otherwise None | ||
files_api = deps.get(Api.files) | ||
impl = MongoDBVectorIOAdapter(config, deps[Api.inference], files_api) |
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.
need to add models_api
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?
f"Collection name: {self.collection.name}. Error: {str(e)}" | ||
) | ||
# Don't fail completely - just log the error and continue | ||
logger.warning( |
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.
we should raise if we can't start the index because then vector stores doesn't work.
"index": self.config.index_name, | ||
"queryVector": embedding.tolist(), | ||
"path": self.config.path_field, | ||
"numCandidates": k * 10, # Get more candidates for better results |
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.
is this intentional? multiplicative increase seems aggressive, i could understand a constant offset but this feels like it could end up with bad consequences.
self, | ||
config: MongoDBVectorIOConfig, | ||
inference_api, | ||
files_api=None, |
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.
needs models_api
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!
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::mongodb
as 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_d6701643cf7a
collection