diff --git a/packages/ragbits-core/src/ragbits/core/embeddings/base.py b/packages/ragbits-core/src/ragbits/core/embeddings/base.py index 7c41e367..7e855d96 100644 --- a/packages/ragbits-core/src/ragbits/core/embeddings/base.py +++ b/packages/ragbits-core/src/ragbits/core/embeddings/base.py @@ -29,7 +29,7 @@ class Embeddings(ConfigurableComponent[EmbeddingsClientOptions], ABC): Abstract client for communication with embedding models. """ - _options_cls: type[EmbeddingsClientOptions] + options_cls: type[EmbeddingsClientOptions] default_module: ClassVar = embeddings configuration_key: ClassVar = "embedder" diff --git a/packages/ragbits-core/src/ragbits/core/embeddings/litellm.py b/packages/ragbits-core/src/ragbits/core/embeddings/litellm.py index 38b1cb0e..d008d3e6 100644 --- a/packages/ragbits-core/src/ragbits/core/embeddings/litellm.py +++ b/packages/ragbits-core/src/ragbits/core/embeddings/litellm.py @@ -29,7 +29,7 @@ class LiteLLMEmbeddings(Embeddings[LiteLLMEmbeddingsOptions]): Client for creating text embeddings using LiteLLM API. """ - _options_cls = LiteLLMEmbeddingsOptions + options_cls = LiteLLMEmbeddingsOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/embeddings/local.py b/packages/ragbits-core/src/ragbits/core/embeddings/local.py index 02076c3d..435eeeb4 100644 --- a/packages/ragbits-core/src/ragbits/core/embeddings/local.py +++ b/packages/ragbits-core/src/ragbits/core/embeddings/local.py @@ -26,7 +26,7 @@ class LocalEmbeddings(Embeddings[LocalEmbeddingsOptions]): Class for interaction with any encoder available in HuggingFace. """ - _options_cls = LocalEmbeddingsOptions + options_cls = LocalEmbeddingsOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/embeddings/noop.py b/packages/ragbits-core/src/ragbits/core/embeddings/noop.py index 47ade9a8..bfd33de7 100644 --- a/packages/ragbits-core/src/ragbits/core/embeddings/noop.py +++ b/packages/ragbits-core/src/ragbits/core/embeddings/noop.py @@ -12,7 +12,7 @@ class NoopEmbeddings(Embeddings): or as a placeholder when an actual embedding model is not required. """ - _options_cls = Options + options_cls = Options @traceable async def embed_text(self, data: list[str], options: EmbeddingsClientOptions | None = None) -> list[list[float]]: # noqa: PLR6301 diff --git a/packages/ragbits-core/src/ragbits/core/embeddings/vertex_multimodal.py b/packages/ragbits-core/src/ragbits/core/embeddings/vertex_multimodal.py index 1fcf3a16..2d84bc00 100644 --- a/packages/ragbits-core/src/ragbits/core/embeddings/vertex_multimodal.py +++ b/packages/ragbits-core/src/ragbits/core/embeddings/vertex_multimodal.py @@ -24,7 +24,7 @@ class VertexAIMultimodelEmbeddings(Embeddings): Client for creating text embeddings using LiteLLM API. """ - _options_cls = Options + options_cls = Options VERTEX_AI_PREFIX = "vertex_ai/" def __init__( diff --git a/packages/ragbits-core/src/ragbits/core/llms/base.py b/packages/ragbits-core/src/ragbits/core/llms/base.py index 62b51f4e..fc7fcd84 100644 --- a/packages/ragbits-core/src/ragbits/core/llms/base.py +++ b/packages/ragbits-core/src/ragbits/core/llms/base.py @@ -26,7 +26,7 @@ class LLM(ConfigurableComponent[LLMClientOptions], ABC): Abstract class for interaction with Large Language Model. """ - _options_cls: type[LLMClientOptions] + options_cls: type[LLMClientOptions] default_module: ClassVar = llms configuration_key: ClassVar = "llm" @@ -39,14 +39,14 @@ def __init__(self, model_name: str, default_options: LLMClientOptions | None = N default_options: Default options to be used. Raises: - TypeError: If the subclass is missing the '_options_cls' attribute. + TypeError: If the subclass is missing the 'options_cls' attribute. """ super().__init__(default_options=default_options) self.model_name = model_name def __init_subclass__(cls) -> None: - if not hasattr(cls, "_options_cls"): - raise TypeError(f"Class {cls.__name__} is missing the '_options_cls' attribute") + if not hasattr(cls, "options_cls"): + raise TypeError(f"Class {cls.__name__} is missing the 'options_cls' attribute") @cached_property @abstractmethod diff --git a/packages/ragbits-core/src/ragbits/core/llms/litellm.py b/packages/ragbits-core/src/ragbits/core/llms/litellm.py index 13c1ebe7..0714bb92 100644 --- a/packages/ragbits-core/src/ragbits/core/llms/litellm.py +++ b/packages/ragbits-core/src/ragbits/core/llms/litellm.py @@ -15,7 +15,7 @@ class LiteLLM(LLM[LiteLLMOptions]): Class for interaction with any LLM supported by LiteLLM API. """ - _options_cls = LiteLLMOptions + options_cls = LiteLLMOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/llms/local.py b/packages/ragbits-core/src/ragbits/core/llms/local.py index 0d469906..42d23979 100644 --- a/packages/ragbits-core/src/ragbits/core/llms/local.py +++ b/packages/ragbits-core/src/ragbits/core/llms/local.py @@ -18,7 +18,7 @@ class LocalLLM(LLM[LocalLLMOptions]): Class for interaction with any LLM available in HuggingFace. """ - _options_cls = LocalLLMOptions + options_cls = LocalLLMOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/utils/config_handling.py b/packages/ragbits-core/src/ragbits/core/utils/config_handling.py index 2ca7c7ad..ef2d3c50 100644 --- a/packages/ragbits-core/src/ragbits/core/utils/config_handling.py +++ b/packages/ragbits-core/src/ragbits/core/utils/config_handling.py @@ -177,7 +177,7 @@ class ConfigurableComponent(Generic[OptionsTypeVar], WithConstructionConfig): Base class for components with configurable options. """ - _options_cls: type[OptionsTypeVar] + options_cls: type[OptionsTypeVar] def __init__(self, default_options: OptionsTypeVar | None = None) -> None: """ @@ -186,7 +186,7 @@ def __init__(self, default_options: OptionsTypeVar | None = None) -> None: Args: default_options: The default options for the component. """ - self.default_options = default_options or self._options_cls() + self.default_options = default_options or self.options_cls() @classmethod def from_config(cls, config: dict[str, Any]) -> ConfigurableComponent: @@ -200,5 +200,5 @@ def from_config(cls, config: dict[str, Any]) -> ConfigurableComponent: An instance of the class initialized with the provided configuration. """ default_options = config.pop("default_options", None) - options = cls._options_cls(**default_options) if default_options else None + options = cls.options_cls(**default_options) if default_options else None return cls(**config, default_options=options) diff --git a/packages/ragbits-core/src/ragbits/core/vector_stores/base.py b/packages/ragbits-core/src/ragbits/core/vector_stores/base.py index 628e5e27..8069508e 100644 --- a/packages/ragbits-core/src/ragbits/core/vector_stores/base.py +++ b/packages/ragbits-core/src/ragbits/core/vector_stores/base.py @@ -40,7 +40,7 @@ class VectorStore(ConfigurableComponent[VectorStoreOptionsType], ABC): A class with an implementation of Vector Store, allowing to store and retrieve vectors by similarity function. """ - _options_cls: type[VectorStoreOptionsType] + options_cls: type[VectorStoreOptionsType] default_module: ClassVar = vector_stores configuration_key: ClassVar = "vector_store" @@ -75,7 +75,7 @@ def from_config(cls, config: dict) -> Self: InvalidConfigError: The metadata_store class can't be found or is not the correct type. """ default_options = config.pop("default_options", None) - options = cls._options_cls(**default_options) if default_options else None + options = cls.options_cls(**default_options) if default_options else None store_config = config.pop("metadata_store", None) store = ( diff --git a/packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py b/packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py index f1b15bab..f5906dde 100644 --- a/packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py +++ b/packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py @@ -16,7 +16,7 @@ class ChromaVectorStore(VectorStore): Vector store implementation using [Chroma](https://docs.trychroma.com). """ - _options_cls = VectorStoreOptions + options_cls = VectorStoreOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py b/packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py index 26245ca1..16cdaa97 100644 --- a/packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py +++ b/packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py @@ -13,7 +13,7 @@ class InMemoryVectorStore(VectorStore): A simple in-memory implementation of Vector Store, storing vectors in memory. """ - _options_cls = VectorStoreOptions + options_cls = VectorStoreOptions def __init__( self, diff --git a/packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py b/packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py index efdfe4b9..77efb9b7 100644 --- a/packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py +++ b/packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py @@ -17,7 +17,7 @@ class QdrantVectorStore(VectorStore): Vector store implementation using [Qdrant](https://qdrant.tech). """ - _options_cls = VectorStoreOptions + options_cls = VectorStoreOptions def __init__( self, diff --git a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/base.py b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/base.py index 8b25e823..560f304c 100644 --- a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/base.py +++ b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/base.py @@ -26,7 +26,7 @@ class Reranker(ConfigurableComponent[RerankerOptionsType], ABC): """ default_module: ClassVar = rerankers - _options_cls: type[RerankerOptionsType] + options_cls: type[RerankerOptionsType] configuration_key: ClassVar = "reranker" @abstractmethod diff --git a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/litellm.py b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/litellm.py index 205b5671..8fcb69b6 100644 --- a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/litellm.py +++ b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/litellm.py @@ -12,7 +12,7 @@ class LiteLLMReranker(Reranker[RerankerOptions]): A [LiteLLM](https://docs.litellm.ai/docs/rerank) reranker for providers such as Cohere, Together AI, Azure AI. """ - _options_cls = RerankerOptions + options_cls = RerankerOptions def __init__(self, model: str, default_options: RerankerOptions | None = None) -> None: """ diff --git a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/noop.py b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/noop.py index 2d0062db..f0e8cd9d 100644 --- a/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/noop.py +++ b/packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/noop.py @@ -10,7 +10,7 @@ class NoopReranker(Reranker[RerankerOptions]): A no-op reranker that does not change the order of the elements. """ - _options_cls = RerankerOptions + options_cls = RerankerOptions @traceable async def rerank( # noqa: PLR6301 diff --git a/packages/ragbits-document-search/tests/unit/test_rerankers.py b/packages/ragbits-document-search/tests/unit/test_rerankers.py index 525494ba..ff127e76 100644 --- a/packages/ragbits-document-search/tests/unit/test_rerankers.py +++ b/packages/ragbits-document-search/tests/unit/test_rerankers.py @@ -15,7 +15,7 @@ class CustomReranker(Reranker): Custom implementation of Reranker for testing. """ - _options_cls = RerankerOptions + options_cls = RerankerOptions async def rerank( # noqa: PLR6301 self, elements: Sequence[Element], query: str, options: RerankerOptions | None = None