-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
130 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 13 additions & 20 deletions
33
packages/ragbits-core/src/ragbits/core/vector_stores/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
import sys | ||
|
||
from ..metadata_stores import get_metadata_store | ||
from ..utils.config_handling import get_cls_from_config | ||
from .base import VectorStore, VectorStoreEntry, VectorStoreOptions, WhereQuery | ||
from .in_memory import InMemoryVectorStore | ||
from ragbits.core.utils.config_handling import get_cls_from_config | ||
from ragbits.core.vector_stores.base import VectorStore, VectorStoreEntry, VectorStoreOptions, WhereQuery | ||
from ragbits.core.vector_stores.in_memory import InMemoryVectorStore | ||
|
||
__all__ = ["InMemoryVectorStore", "VectorStore", "VectorStoreEntry", "WhereQuery"] | ||
__all__ = ["InMemoryVectorStore", "VectorStore", "VectorStoreEntry", "VectorStoreOptions", "WhereQuery"] | ||
|
||
module = sys.modules[__name__] | ||
|
||
|
||
def get_vector_store(vector_store_config: dict) -> VectorStore: | ||
def get_vector_store(config: dict) -> VectorStore: | ||
""" | ||
Initializes and returns a VectorStore object based on the provided configuration. | ||
Args: | ||
vector_store_config: A dictionary containing configuration details for the VectorStore. | ||
config: A dictionary containing configuration details for the VectorStore. | ||
Returns: | ||
An instance of the specified VectorStore class, initialized with the provided config | ||
(if any) or default arguments. | ||
""" | ||
vector_store_cls = get_cls_from_config(vector_store_config["type"], module) | ||
config = vector_store_config.get("config", {}) | ||
if vector_store_config["type"].endswith(("ChromaVectorStore", "QdrantVectorStore")): | ||
return vector_store_cls.from_config(config) | ||
|
||
metadata_store_config = vector_store_config.get("metadata_store_config") | ||
return vector_store_cls( | ||
default_options=VectorStoreOptions(**config.get("default_options", {})), | ||
metadata_store=get_metadata_store(metadata_store_config), | ||
) | ||
Raises: | ||
KeyError: If the provided configuration does not contain a valid "type" key. | ||
InvalidConfigurationError: If the provided configuration is invalid. | ||
NotImplementedError: If the specified VectorStore class cannot be created from the provided configuration. | ||
""" | ||
vector_store_cls = get_cls_from_config(config["type"], sys.modules[__name__]) | ||
return vector_store_cls.from_config(config.get("config", {})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.