Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions docs/modules/storages.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ The `StorageHandler` is tightly integrated with the `RAGEngine` class to support
## Configuration
The `StorageHandler` relies on the `StoreConfig` class (defined in `storages_config.py`) to configure its backends:
- **`DBConfig`**: Configures relational databases (e.g., SQLite) with settings like `db_name`, `path`, `ip`, and `port`.
- **`VectorStoreConfig`**: Configures vector databases (e.g., FAISS, Qdrant) with settings like `vector_name`, `dimensions`, `index_type`, `qdrant_url`, and `qdrant_collection_name`.
- **`VectorStoreConfig`**: Configures vector databases (e.g., FAISS, Qdrant, Milvus) with settings like `vector_name`, `dimensions`, `index_type`, `qdrant_url`, `qdrant_collection_name`, `milvus_uri`, and `milvus_collection_name`.
- **`GraphStoreConfig`**: Configures graph databases (e.g., Neo4j) with settings上午 like `graph_name`, `uri`, `username`, `password`, and `database`.

The configuration is validated using Pydantic, ensuring robust type checking and default values.
Expand Down Expand Up @@ -166,11 +166,33 @@ index = storage_handler.load_index("corpus1")
print(index) # {'corpus_id': 'corpus1', 'content': {...}, 'metadata': {...}}
```

To use Milvus instead of FAISS, install the optional dependency and set `vector_name="milvus"`:

```bash
pip install "evoagentx[milvus]"
```

```python
config = StoreConfig(
dbConfig=DBConfig(db_name="sqlite", path="data/storage.db"),
vectorConfig=VectorStoreConfig(
vector_name="milvus",
dimensions=1536,
milvus_uri="./data/evoagentx_milvus.db",
milvus_collection_name="evoagentx_vectors",
milvus_metric_type="IP",
),
path="data/index_cache"
)
```

`milvus_uri` can point to a Milvus Lite `.db` file, a self-hosted Milvus endpoint such as `http://localhost:19530`, or a Zilliz Cloud endpoint when paired with `milvus_token`.

## Notes
- The `load_memory` and `save_memory` methods are not yet fully implemented and will be developed alongside `LongTermMemory`.
- The `StorageHandler` assumes the database schema is managed by `DBStoreBase` and its factory, ensuring compatibility with `TableType` enums.
- When used with `RAGEngine`, ensure the vector store's dimensions match the embedding model's dimensions to avoid reinitialization issues.
- Error handling is implemented throughout, with logs generated via the `evoagentx.core.logging.logger` module.

## Conclusion
The `StorageHandler` class provides a flexible and extensible interface for managing multiple storage backends in a unified manner. Its integration with `RAGEngine` makes it a key component for RAG pipelines, enabling efficient storage and retrieval of indexed data. By leveraging factory patterns and Pydantic validation, it ensures robustness and scalability for applications requiring complex data management.
The `StorageHandler` class provides a flexible and extensible interface for managing multiple storage backends in a unified manner. Its integration with `RAGEngine` makes it a key component for RAG pipelines, enabling efficient storage and retrieval of indexed data. By leveraging factory patterns and Pydantic validation, it ensures robustness and scalability for applications requiring complex data management.
20 changes: 19 additions & 1 deletion docs/tutorial/rag.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ print("RAGEngine is ready to go!")
- `RetrievalConfig`: Retrieves the top 3 most similar chunks with a similarity score above 0.3.
- **Initialization**: We create the `RAGEngine` instance, ready to process documents.

To use Milvus instead of FAISS, install the optional dependency and replace the vector store configuration:

```bash
pip install "evoagentx[milvus]"
```

```python
vectorConfig=VectorStoreConfig(
vector_name="milvus",
dimensions=1536,
milvus_uri="./data/evoagentx_milvus.db",
milvus_collection_name="rag_tutorial_vectors",
milvus_metric_type="IP",
)
```

Use a Milvus Lite `.db` path for local development, or set `milvus_uri` and `milvus_token` for Milvus server or Zilliz Cloud.

For more details on configuration, see the [RAGEngine documentation](../modules/rag.md).

## 2. Indexing and Querying Documents
Expand Down Expand Up @@ -458,4 +476,4 @@ Congratulations! You’ve built your first RAG system with `RAGEngine`. Here are

For a complete example, refer to the [RAGEngine example](../../examples/rag.py).

Happy building with EvoAgentX!
Happy building with EvoAgentX!
13 changes: 10 additions & 3 deletions evoagentx/storages/storages_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ class DBConfig(BaseConfig):

class VectorStoreConfig(BaseConfig):
"""
Configuration for vector databases, supporting FAISS and Qdrant.
Configuration for vector databases, supporting FAISS, Qdrant, and Milvus.
"""
vector_name: str = Field(default="faiss", description="Name of the vector database provider (e.g., 'faiss', 'qdrant')")
vector_name: str = Field(default="faiss", description="Name of the vector database provider (e.g., 'faiss', 'qdrant', 'milvus')")
dimensions: Optional[int] = Field(default=1536, description="Dimension of the embedding vectors")
index_type: Optional[str] = Field(default="flat_l2", description="Index type for FAISS (e.g., 'flat_l2', 'ivf_flat')")
qdrant_url: Optional[str] = Field(default=None, description="URL for Qdrant server (e.g., 'http://localhost:6333')")
qdrant_api_key: Optional[str] = Field(default=None, description="API key for Qdrant authentication")
qdrant_collection_name: Optional[str] = Field(default="default_collection", description="Name of the Qdrant collection")
milvus_uri: Optional[str] = Field(default="./milvus.db", description="Milvus URI. Use a local .db path for Milvus Lite or an HTTP endpoint for Milvus server/Zilliz Cloud.")
milvus_token: Optional[str] = Field(default=None, description="Token for Milvus server or Zilliz Cloud authentication")
milvus_db_name: Optional[str] = Field(default=None, description="Milvus database name")
milvus_collection_name: Optional[str] = Field(default="evoagentx_vectors", description="Name of the Milvus collection")
milvus_metric_type: Optional[str] = Field(default="IP", description="Milvus vector metric type, such as IP, COSINE, or L2")
milvus_consistency_level: Optional[str] = Field(default="Session", description="Milvus consistency level")
milvus_overwrite: Optional[bool] = Field(default=False, description="Drop and recreate the Milvus collection during initialization")


class GraphStoreConfig(BaseConfig):
Expand All @@ -48,4 +55,4 @@ class StoreConfig(BaseConfig):
vectorConfig: Optional[VectorStoreConfig] = Field(None, description="Configuration for the vector store")
graphConfig: Optional[GraphStoreConfig] = Field(None, description="Optional configuration for the graph store")
# For file storage
path: Optional[str] = Field(default="/index_cache", description="directory path for storing the index")
path: Optional[str] = Field(default="/index_cache", description="directory path for storing the index")
9 changes: 8 additions & 1 deletion evoagentx/storages/vectore_stores/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def create(self, store_type: str, store_config: Dict[str, Any] = None) -> Vector
# raise ValueError("Qdrant requires a valid URL")
# client = QdrantClient(url=qdrant_url, api_key=qdrant_api_key)
# vector_store = QdrantVectorStore(client=client, collection_name=collection_name)
elif store_type == VectorStoreType.MILVUS:
dimensions = store_config.get("dimensions")
if not dimensions or not isinstance(dimensions, int):
raise ValueError("Milvus requires a valid dimension")
from .milvus import MilvusVectorStoreWrapper

vector_store = MilvusVectorStoreWrapper(**store_config)
else:
raise ValueError(f"Unsupported vector store type: {store_type}")
logger.info(f"Created vector store: {store_type}")
return vector_store
return vector_store
3 changes: 2 additions & 1 deletion evoagentx/storages/vectore_stores/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class VectorStoreType(str, Enum):
FAISS = "faiss"
MILVUS = "milvus"


class VectorStoreBase(ABC):
Expand All @@ -19,4 +20,4 @@ def get_vector_store(self) -> BasePydanticVectorStore:
@abstractmethod
async def aload(self):
"""Asynchronously load a single node into the vector store."""
pass
pass
Loading