-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathfactory.py
More file actions
25 lines (19 loc) · 842 Bytes
/
factory.py
File metadata and controls
25 lines (19 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from typing import Dict, Type
from vectorcode.cli_utils import Config, DbType
from vectorcode.db.base import VectorStore
from vectorcode.db.chroma import ChromaVectorStore
from vectorcode.db.local import LocalChromaVectorStore
class VectorStoreFactory:
"""Factory for creating vector store instances."""
_stores: Dict[DbType, Type[VectorStore]] = {
DbType.chromadb: ChromaVectorStore,
DbType.local: LocalChromaVectorStore,
}
@classmethod
def create_store(cls, configs: Config) -> VectorStore:
"""Create a vector store instance based on configuration."""
store_type = configs.db_type
if store_type not in cls._stores:
raise ValueError(f"Unsupported vector store type: {store_type}")
store_class = cls._stores[store_type]
return store_class(configs)