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

just some more quick fixes #7498

Merged
merged 2 commits into from
Apr 8, 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
2 changes: 2 additions & 0 deletions haystack/utils/callable_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
def serialize_callable(callable_handle: Callable) -> str:
"""
Serializes a callable to its full path.

:param callable_handle: The callable to serialize
:return: The full path of the callable
"""
Expand All @@ -24,6 +25,7 @@ def serialize_callable(callable_handle: Callable) -> str:
def deserialize_callable(callable_handle: str) -> Optional[Callable]:
"""
Deserializes a callable given its full import path as a string.

:param callable_handle: The full path of the callable_handle
:return: The callable
:raises DeserializationError: If the callable cannot be found
Expand Down
7 changes: 7 additions & 0 deletions haystack/utils/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def __str__(self):

@staticmethod
def from_str(string: str) -> "HFGenerationAPIType":
"""
Convert a string to a HFGenerationAPIType enum.

:param string: The string to convert.
:return: The corresponding HFGenerationAPIType enum.

"""
enum_map = {e.value: e for e in HFGenerationAPIType}
mode = enum_map.get(string)
if mode is None:
Expand Down
3 changes: 2 additions & 1 deletion haystack/utils/url_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from urllib.parse import urlparse


def is_valid_http_url(url) -> bool:
def is_valid_http_url(url: str) -> bool:
"""Check if a URL is a valid HTTP/HTTPS URL."""
r = urlparse(url)
return all([r.scheme in ["http", "https"], r.netloc])