Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose the Backend datatype as part of the public API #27

Merged
merged 2 commits into from
Nov 20, 2024
Merged
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
3 changes: 2 additions & 1 deletion vicinity/__init__.py
Original file line number Diff line number Diff line change
@@ -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__"]
3 changes: 2 additions & 1 deletion vicinity/vicinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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())
Expand Down