feat: add mongodb provider

This commit is contained in:
Young Han 2025-10-10 10:42:42 -07:00
parent d8c82c10c2
commit 885631d071
8 changed files with 61 additions and 5 deletions

View file

@ -25,6 +25,7 @@ distribution_spec:
- provider_type: inline::milvus
- provider_type: remote::chromadb
- provider_type: remote::pgvector
- provider_type: remote::mongodb
files:
- provider_type: inline::localfs
safety:

View file

@ -129,6 +129,19 @@ providers:
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/ci-tests}/pgvector_registry.db
- provider_id: ${env.MONGODB_CONNECTION_STRING:+mongodb_atlas}
provider_type: remote::mongodb
config:
connection_string: ${env.MONGODB_CONNECTION_STRING}
database_name: llama_stack
index_name: vector_index
path_field: embedding
similarity_metric: cosine
max_pool_size: 100
timeout_ms: 30000
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/ci-tests}/mongodb_registry.db
files:
- provider_id: meta-reference-files
provider_type: inline::localfs

View file

@ -26,6 +26,7 @@ distribution_spec:
- provider_type: inline::milvus
- provider_type: remote::chromadb
- provider_type: remote::pgvector
- provider_type: remote::mongodb
files:
- provider_type: inline::localfs
safety:

View file

@ -129,6 +129,19 @@ providers:
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/starter-gpu}/pgvector_registry.db
- provider_id: ${env.MONGODB_CONNECTION_STRING:+mongodb_atlas}
provider_type: remote::mongodb
config:
connection_string: ${env.MONGODB_CONNECTION_STRING}
database_name: llama_stack
index_name: vector_index
path_field: embedding
similarity_metric: cosine
max_pool_size: 100
timeout_ms: 30000
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/starter-gpu}/mongodb_registry.db
files:
- provider_id: meta-reference-files
provider_type: inline::localfs

View file

@ -26,6 +26,7 @@ distribution_spec:
- provider_type: inline::milvus
- provider_type: remote::chromadb
- provider_type: remote::pgvector
- provider_type: remote::mongodb
files:
- provider_type: inline::localfs
safety:

View file

@ -129,6 +129,19 @@ providers:
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/starter}/pgvector_registry.db
- provider_id: ${env.MONGODB_CONNECTION_STRING:+mongodb_atlas}
provider_type: remote::mongodb
config:
connection_string: ${env.MONGODB_CONNECTION_STRING}
database_name: llama_stack
index_name: vector_index
path_field: embedding
similarity_metric: cosine
max_pool_size: 100
timeout_ms: 30000
kvstore:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/starter}/mongodb_registry.db
files:
- provider_id: meta-reference-files
provider_type: inline::localfs

View file

@ -28,6 +28,9 @@ from llama_stack.providers.inline.vector_io.sqlite_vec.config import (
)
from llama_stack.providers.registry.inference import available_providers
from llama_stack.providers.remote.vector_io.chroma.config import ChromaVectorIOConfig
from llama_stack.providers.remote.vector_io.mongodb.config import (
MongoDBVectorIOConfig,
)
from llama_stack.providers.remote.vector_io.pgvector.config import (
PGVectorVectorIOConfig,
)
@ -113,6 +116,7 @@ def get_distribution_template(name: str = "starter") -> DistributionTemplate:
BuildProvider(provider_type="inline::milvus"),
BuildProvider(provider_type="remote::chromadb"),
BuildProvider(provider_type="remote::pgvector"),
BuildProvider(provider_type="remote::mongodb"),
],
"files": [BuildProvider(provider_type="inline::localfs")],
"safety": [
@ -222,6 +226,13 @@ def get_distribution_template(name: str = "starter") -> DistributionTemplate:
password="${env.PGVECTOR_PASSWORD:=}",
),
),
Provider(
provider_id="${env.MONGODB_CONNECTION_STRING:+mongodb_atlas}",
provider_type="remote::mongodb",
config=MongoDBVectorIOConfig.sample_run_config(
f"~/.llama/distributions/{name}",
),
),
],
"files": [files_provider],
},
@ -295,5 +306,13 @@ def get_distribution_template(name: str = "starter") -> DistributionTemplate:
"azure",
"Azure API Type",
),
"MONGODB_CONNECTION_STRING": (
"",
"MongoDB Atlas connection string (e.g., mongodb+srv://user:pass@cluster.mongodb.net/)",
),
"MONGODB_DATABASE_NAME": (
"llama_stack",
"MongoDB database name",
),
},
)