feat: Add db_name field to MilvusDBConfig and MilvusDB initialization (#3229)

This commit is contained in:
Vimpas
2025-08-06 02:16:34 +08:00
committed by GitHub
parent 7fac6311f4
commit 7a0dc7391e
4 changed files with 7 additions and 2 deletions
+2
View File
@@ -14,6 +14,7 @@ config = {
"embedding_model_dims": "123",
"url": "127.0.0.1",
"token": "8e4b8ca8cf2c67",
"db_name": "my_database",
}
}
}
@@ -39,3 +40,4 @@ Here's the parameters available for configuring Milvus Database:
| `collection_name` | The name of the collection | `mem0` |
| `embedding_model_dims` | Dimensions of the embedding model | `1536` |
| `metric_type` | Metric type for similarity search | `L2` |
| `db_name` | Name of the database | `""` |
+1 -1
View File
@@ -110,7 +110,7 @@
[Qdrant](https://docs.mem0.ai/components/vectordbs/dbs/qdrant): Integrate Qdrant vector database by configuring the Memory client with provider settings like collection_name, host, port, and other parameters - supports both local and remote deployments with options for persistent storage and custom client configurations.
[Pinecone](https://docs.mem0.ai/components/vectordbs/dbs/pinecone): Integrate Pinecone's managed vector database by configuring the Memory client with serverless or pod deployment options, supporting high-performance vector search with customizable embedding dimensions, distance metrics, and cloud providers (AWS/GCP/Azure) - requires PINECONE_API_KEY and matching embedding model dimensions (e.g. 1536 for OpenAI).
[Milvus](https://docs.mem0.ai/components/vectordbs/dbs/milvus): Integrate Milvus open-source vector database by configuring the Memory client with provider settings like url (default localhost:19530), token (for Zilliz cloud), collection_name, embedding_model_dims (default 1536) and metric_type - supports both local and cloud deployments for AI applications of any scale.
[Milvus](https://docs.mem0.ai/components/vectordbs/dbs/milvus): Integrate Milvus open-source vector database by configuring the Memory client with provider settings like url (default localhost:19530), token (for Zilliz cloud), collection_name, embedding_model_dims (default 1536), metric_type and db_name (database name) - supports both local and cloud deployments for AI applications of any scale.
[Weaviate](https://docs.mem0.ai/components/vectordbs/dbs/weaviate): Integrate Weaviate open-source vector search engine by configuring the Memory client with provider settings like collection_name (default: mem0), cluster_url, auth_client_secret and embedding_model_dims (default: 1536) - enables efficient storage and retrieval of high-dimensional vector embeddings.
[Chroma](https://docs.mem0.ai/components/vectordbs/dbs/chroma): Integrate Chroma AI-native open-source vector database by configuring the Memory client with provider settings like collection_name (default: mem0), path (default: db), host, port, and client - enables simple storage and search of embeddings with focus on speed and ease of use.
[Faiss](https://docs.mem0.ai/components/vectordbs/dbs/faiss): Integrate Faiss, a high-performance library for similarity search and clustering of dense vectors, by configuring the Memory client with settings like collection_name, path, and distance_strategy (euclidean/cosine/inner_product) - supports efficient local vector search with in-memory or persistent storage options and is optimized for large-scale production use.
+1
View File
@@ -25,6 +25,7 @@ class MilvusDBConfig(BaseModel):
collection_name: str = Field("mem0", description="Name of the collection")
embedding_model_dims: int = Field(1536, description="Dimensions of the embedding model")
metric_type: str = Field("L2", description="Metric type for similarity search")
db_name: str = Field("", description="Name of the database")
@model_validator(mode="before")
@classmethod
+3 -1
View File
@@ -30,6 +30,7 @@ class MilvusDB(VectorStoreBase):
collection_name: str,
embedding_model_dims: int,
metric_type: MetricType,
db_name: str,
) -> None:
"""Initialize the MilvusDB database.
@@ -39,11 +40,12 @@ class MilvusDB(VectorStoreBase):
collection_name (str): Name of the collection (defaults to mem0).
embedding_model_dims (int): Dimensions of the embedding model (defaults to 1536).
metric_type (MetricType): Metric type for similarity search (defaults to L2).
db_name (str): Name of the database (defaults to "").
"""
self.collection_name = collection_name
self.embedding_model_dims = embedding_model_dims
self.metric_type = metric_type
self.client = MilvusClient(uri=url, token=token)
self.client = MilvusClient(uri=url, token=token, db_name=db_name)
self.create_col(
collection_name=self.collection_name,
vector_size=self.embedding_model_dims,