From 72bea484c74baf70f4cce89cf26778dcd11e1e54 Mon Sep 17 00:00:00 2001 From: stephantul Date: Wed, 20 Nov 2024 15:51:32 +0100 Subject: [PATCH 1/2] Expose the Backend datatype as part of the public API --- vicinity/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vicinity/__init__.py b/vicinity/__init__.py index 55fbd3c..51507fd 100644 --- a/vicinity/__init__.py +++ b/vicinity/__init__.py @@ -1,7 +1,8 @@ """Small vector store.""" +from vicinity.datatypes import Backend from vicinity.utils import normalize from vicinity.version import __version__ from vicinity.vicinity import Vicinity -__all__ = ["Vicinity", "normalize", "__version__"] +__all__ = ["Backend", "Vicinity", "normalize", "__version__"] From 38ebca6196238b920a67fda97f4196b9b18b0dfb Mon Sep 17 00:00:00 2001 From: stephantul Date: Wed, 20 Nov 2024 15:53:41 +0100 Subject: [PATCH 2/2] feat: allow backend_type to be a string --- vicinity/vicinity.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vicinity/vicinity.py b/vicinity/vicinity.py index 523142e..6571657 100644 --- a/vicinity/vicinity.py +++ b/vicinity/vicinity.py @@ -58,7 +58,7 @@ def from_vectors_and_items( cls: type[Vicinity], vectors: npt.NDArray, items: Sequence[str], - backend_type: Backend = Backend.BASIC, + backend_type: Backend | str = Backend.BASIC, **kwargs: Any, ) -> Vicinity: """ @@ -70,6 +70,7 @@ def from_vectors_and_items( :param **kwargs: Additional arguments to pass to the backend. :return: A Vicinity instance. """ + backend_type = Backend(backend_type) backend_cls = get_backend_class(backend_type) arguments = backend_cls.argument_class(**kwargs) backend = backend_cls.from_vectors(vectors, **arguments.dict())